Tarantool development patches archive
 help / color / mirror / Atom feed
* [Tarantool-patches] [PATCH] lua/utils: fix fiber->fid print in Lua tracing
@ 2021-05-14 10:19 Cyrill Gorcunov via Tarantool-patches
  2021-05-14 10:32 ` [Tarantool-patches] [PATCH v2] lua/utils: fix fiber->fid print in cord_on_yield Cyrill Gorcunov via Tarantool-patches
  0 siblings, 1 reply; 7+ messages in thread
From: Cyrill Gorcunov via Tarantool-patches @ 2021-05-14 10:19 UTC (permalink / raw)
  To: tml; +Cc: Vladislav Shpilevoy

This fixes a nit in commit 6af473778
(fiber: use uint64_t for fiber IDs).

Since lua_pushfstring doesn't support %llu format it
breaks the test

app-tap/gh-1700-abort-recording-on-fiber-switch.test.lua

Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
---
branch gorcunov/gh-5846-fid-name-fix

 src/lua/utils.c | 11 +++++++----
 1 file changed, 7 insertions(+), 4 deletions(-)

diff --git a/src/lua/utils.c b/src/lua/utils.c
index 0fbe700fc..6e5b6e8e8 100644
--- a/src/lua/utils.c
+++ b/src/lua/utils.c
@@ -1341,6 +1341,7 @@ void cord_on_yield(void)
 	 * code misbehaviour and failures, so stop its execution.
 	 */
 	if (unlikely(tvref(g->jit_base))) {
+		char buf[256];
 		/*
 		 * XXX: mcode is executed only in scope of Lua
 		 * world and one can obtain the corresponding Lua
@@ -1348,10 +1349,12 @@ void cord_on_yield(void)
 		 */
 		struct lua_State *L = fiber()->storage.lua.stack;
 		assert(L != NULL);
-		lua_pushfstring(L, "fiber %llu is switched while running the"
-				" compiled code (it's likely a function with"
-				" a yield underneath called via LuaJIT FFI)",
-				(long long)fiber()->fid);
+		snprintf(buf, sizeof(buf),
+			 "fiber %llu is switched while running the"
+			 " compiled code (it's likely a function with"
+			 " a yield underneath called via LuaJIT FFI)",
+			 (long long)fiber()->fid);
+		lua_pushstring(L, buf);
 		if (g->panic)
 			g->panic(L);
 		exit(EXIT_FAILURE);
-- 
2.31.1


^ permalink raw reply	[flat|nested] 7+ messages in thread

* [Tarantool-patches] [PATCH v2] lua/utils: fix fiber->fid print in cord_on_yield
  2021-05-14 10:19 [Tarantool-patches] [PATCH] lua/utils: fix fiber->fid print in Lua tracing Cyrill Gorcunov via Tarantool-patches
@ 2021-05-14 10:32 ` Cyrill Gorcunov via Tarantool-patches
  2021-05-14 10:41   ` Igor Munkin via Tarantool-patches
  0 siblings, 1 reply; 7+ messages in thread
From: Cyrill Gorcunov via Tarantool-patches @ 2021-05-14 10:32 UTC (permalink / raw)
  To: tml; +Cc: Vladislav Shpilevoy

This fixes a nit in commit 6af473778
(fiber: use uint64_t for fiber IDs).

Since lua_pushfstring doesn't support %llu format it
breaks the test

app-tap/gh-1700-abort-recording-on-fiber-switch.test.lua

Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
---
branch gorcunov/gh-5846-fid-name-fix
 src/lua/utils.c | 20 +++++++++++++-------
 1 file changed, 13 insertions(+), 7 deletions(-)

diff --git a/src/lua/utils.c b/src/lua/utils.c
index 0fbe700fc..3ce821374 100644
--- a/src/lua/utils.c
+++ b/src/lua/utils.c
@@ -1341,6 +1341,7 @@ void cord_on_yield(void)
 	 * code misbehaviour and failures, so stop its execution.
 	 */
 	if (unlikely(tvref(g->jit_base))) {
+		char buf[256];
 		/*
 		 * XXX: mcode is executed only in scope of Lua
 		 * world and one can obtain the corresponding Lua
@@ -1348,10 +1349,12 @@ void cord_on_yield(void)
 		 */
 		struct lua_State *L = fiber()->storage.lua.stack;
 		assert(L != NULL);
-		lua_pushfstring(L, "fiber %llu is switched while running the"
-				" compiled code (it's likely a function with"
-				" a yield underneath called via LuaJIT FFI)",
-				(long long)fiber()->fid);
+		snprintf(buf, sizeof(buf),
+			 "fiber %llu is switched while running the"
+			 " compiled code (it's likely a function with"
+			 " a yield underneath called via LuaJIT FFI)",
+			 (long long)fiber()->fid);
+		lua_pushstring(L, buf);
 		if (g->panic)
 			g->panic(L);
 		exit(EXIT_FAILURE);
@@ -1376,11 +1379,14 @@ void cord_on_yield(void)
 	 * GC hook is active and the platform is forced to stop.
 	 */
 	if (unlikely(g->hookmask & HOOK_GC)) {
+		char buf[128];
 		struct lua_State *L = fiber()->storage.lua.stack;
 		assert(L != NULL);
-		lua_pushfstring(L, "fiber %d is switched while running GC"
-				" finalizer (i.e. __gc metamethod)",
-				fiber()->fid);
+		snprintf(buf, sizeof(buf),
+			 "fiber %llu is switched while running GC"
+			 " finalizer (i.e. __gc metamethod)",
+			 (long long)fiber()->fid);
+		lua_pushstring(L, buf);
 		if (g->panic)
 			g->panic(L);
 		exit(EXIT_FAILURE);
-- 
2.31.1


^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [Tarantool-patches] [PATCH v2] lua/utils: fix fiber->fid print in cord_on_yield
  2021-05-14 10:32 ` [Tarantool-patches] [PATCH v2] lua/utils: fix fiber->fid print in cord_on_yield Cyrill Gorcunov via Tarantool-patches
@ 2021-05-14 10:41   ` Igor Munkin via Tarantool-patches
  2021-05-14 12:15     ` [Tarantool-patches] [PATCH v3] " Cyrill Gorcunov via Tarantool-patches
  0 siblings, 1 reply; 7+ messages in thread
From: Igor Munkin via Tarantool-patches @ 2021-05-14 10:41 UTC (permalink / raw)
  To: Cyrill Gorcunov; +Cc: tml, Vladislav Shpilevoy

Cyrill,

Thanks for the fixes! Just a couple of nits.

On 14.05.21, Cyrill Gorcunov via Tarantool-patches wrote:
> This fixes a nit in commit 6af473778
> (fiber: use uint64_t for fiber IDs).

If you want to mention this commit, please use the full hash and enclose
the commit subject into single quotes: it's the common way used in repo.
You can find an example here[1] (but GitHub strips the hash while
rendering the webpage).

> 
> Since lua_pushfstring doesn't support %llu format it
> breaks the test

Minor: It would be nice to refer Lua Reference Manual[2] then.

> 
> app-tap/gh-1700-abort-recording-on-fiber-switch.test.lua
> 
> Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
> ---
> branch gorcunov/gh-5846-fid-name-fix
>  src/lua/utils.c | 20 +++++++++++++-------
>  1 file changed, 13 insertions(+), 7 deletions(-)
> 
> diff --git a/src/lua/utils.c b/src/lua/utils.c
> index 0fbe700fc..3ce821374 100644
> --- a/src/lua/utils.c
> +++ b/src/lua/utils.c
> @@ -1341,6 +1341,7 @@ void cord_on_yield(void)
>  	 * code misbehaviour and failures, so stop its execution.
>  	 */
>  	if (unlikely(tvref(g->jit_base))) {
> +		char buf[256];
>  		/*
>  		 * XXX: mcode is executed only in scope of Lua
>  		 * world and one can obtain the corresponding Lua
> @@ -1348,10 +1349,12 @@ void cord_on_yield(void)
>  		 */
>  		struct lua_State *L = fiber()->storage.lua.stack;
>  		assert(L != NULL);
> -		lua_pushfstring(L, "fiber %llu is switched while running the"
> -				" compiled code (it's likely a function with"
> -				" a yield underneath called via LuaJIT FFI)",
> -				(long long)fiber()->fid);
> +		snprintf(buf, sizeof(buf),
> +			 "fiber %llu is switched while running the"
> +			 " compiled code (it's likely a function with"
> +			 " a yield underneath called via LuaJIT FFI)",
> +			 (long long)fiber()->fid);

Why do you cast the value to long long (i.e. signed value), but use the
unsigned %llu modifier? This might be OK, but it's not clear to me.

> +		lua_pushstring(L, buf);
>  		if (g->panic)
>  			g->panic(L);
>  		exit(EXIT_FAILURE);
> @@ -1376,11 +1379,14 @@ void cord_on_yield(void)
>  	 * GC hook is active and the platform is forced to stop.
>  	 */
>  	if (unlikely(g->hookmask & HOOK_GC)) {
> +		char buf[128];
>  		struct lua_State *L = fiber()->storage.lua.stack;
>  		assert(L != NULL);
> -		lua_pushfstring(L, "fiber %d is switched while running GC"
> -				" finalizer (i.e. __gc metamethod)",
> -				fiber()->fid);
> +		snprintf(buf, sizeof(buf),
> +			 "fiber %llu is switched while running GC"
> +			 " finalizer (i.e. __gc metamethod)",
> +			 (long long)fiber()->fid);
> +		lua_pushstring(L, buf);
>  		if (g->panic)
>  			g->panic(L);
>  		exit(EXIT_FAILURE);
> -- 
> 2.31.1
> 

[1]: https://github.com/tarantool/tarantool/commit/b990d36
[2]: https://www.lua.org/manual/5.1/manual.html#lua_pushfstring

-- 
Best regards,
IM

^ permalink raw reply	[flat|nested] 7+ messages in thread

* [Tarantool-patches] [PATCH v3] lua/utils: fix fiber->fid print in cord_on_yield
  2021-05-14 10:41   ` Igor Munkin via Tarantool-patches
@ 2021-05-14 12:15     ` Cyrill Gorcunov via Tarantool-patches
  2021-05-17  7:36       ` Igor Munkin via Tarantool-patches
                         ` (2 more replies)
  0 siblings, 3 replies; 7+ messages in thread
From: Cyrill Gorcunov via Tarantool-patches @ 2021-05-14 12:15 UTC (permalink / raw)
  To: Igor Munkin; +Cc: tml, Vladislav Shpilevoy

On Fri, May 14, 2021 at 01:41:15PM +0300, Igor Munkin wrote:
> Cyrill,
> 
> Thanks for the fixes! Just a couple of nits.
> 
> On 14.05.21, Cyrill Gorcunov via Tarantool-patches wrote:
> > This fixes a nit in commit 6af473778
> > (fiber: use uint64_t for fiber IDs).
> 
> If you want to mention this commit, please use the full hash and enclose

I don't understand why you need a full hash? When the reference is generated
the git makes sure that id being generated is long enough among existing
commits to be parseble. But sure, no problem.

> the commit subject into single quotes: it's the common way used in repo.
> You can find an example here[1] (but GitHub strips the hash while
> rendering the webpage).
> 
> > 
> > Since lua_pushfstring doesn't support %llu format it
> > breaks the test
> 
> Minor: It would be nice to refer Lua Reference Manual[2] then.

Sure, thanks!

> > +		snprintf(buf, sizeof(buf),
> > +			 "fiber %llu is switched while running the"
> > +			 " compiled code (it's likely a function with"
> > +			 " a yield underneath called via LuaJIT FFI)",
> > +			 (long long)fiber()->fid);
> 
> Why do you cast the value to long long (i.e. signed value), but use the
> unsigned %llu modifier? This might be OK, but it's not clear to me.

Because only _size_ of argument does matter, and language standart
guarantees that signed and unsigned arguments are counterparts. Thus
instead of big "unsigned long long" specificator you can write a
shorthand "long long".

Force pushed an update.
---
From: Cyrill Gorcunov <gorcunov@gmail.com>
Date: Fri, 14 May 2021 13:18:13 +0300

This fixes a nit in commit 6af4737789042b1e6673c421686bb4394a61f4a1
("fiber: use uint64_t for fiber IDs").

Since lua_pushfstring doesn't support %llu format [1] it
breaks the test

app-tap/gh-1700-abort-recording-on-fiber-switch.test.lua

[1] https://www.lua.org/manual/5.1/manual.html#lua_pushfstring

Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
---
 src/lua/utils.c | 20 +++++++++++++-------
 1 file changed, 13 insertions(+), 7 deletions(-)

diff --git a/src/lua/utils.c b/src/lua/utils.c
index 0fbe700fc..3ce821374 100644
--- a/src/lua/utils.c
+++ b/src/lua/utils.c
@@ -1341,6 +1341,7 @@ void cord_on_yield(void)
 	 * code misbehaviour and failures, so stop its execution.
 	 */
 	if (unlikely(tvref(g->jit_base))) {
+		char buf[256];
 		/*
 		 * XXX: mcode is executed only in scope of Lua
 		 * world and one can obtain the corresponding Lua
@@ -1348,10 +1349,12 @@ void cord_on_yield(void)
 		 */
 		struct lua_State *L = fiber()->storage.lua.stack;
 		assert(L != NULL);
-		lua_pushfstring(L, "fiber %llu is switched while running the"
-				" compiled code (it's likely a function with"
-				" a yield underneath called via LuaJIT FFI)",
-				(long long)fiber()->fid);
+		snprintf(buf, sizeof(buf),
+			 "fiber %llu is switched while running the"
+			 " compiled code (it's likely a function with"
+			 " a yield underneath called via LuaJIT FFI)",
+			 (long long)fiber()->fid);
+		lua_pushstring(L, buf);
 		if (g->panic)
 			g->panic(L);
 		exit(EXIT_FAILURE);
@@ -1376,11 +1379,14 @@ void cord_on_yield(void)
 	 * GC hook is active and the platform is forced to stop.
 	 */
 	if (unlikely(g->hookmask & HOOK_GC)) {
+		char buf[128];
 		struct lua_State *L = fiber()->storage.lua.stack;
 		assert(L != NULL);
-		lua_pushfstring(L, "fiber %d is switched while running GC"
-				" finalizer (i.e. __gc metamethod)",
-				fiber()->fid);
+		snprintf(buf, sizeof(buf),
+			 "fiber %llu is switched while running GC"
+			 " finalizer (i.e. __gc metamethod)",
+			 (long long)fiber()->fid);
+		lua_pushstring(L, buf);
 		if (g->panic)
 			g->panic(L);
 		exit(EXIT_FAILURE);
-- 
2.31.1


^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [Tarantool-patches] [PATCH v3] lua/utils: fix fiber->fid print in cord_on_yield
  2021-05-14 12:15     ` [Tarantool-patches] [PATCH v3] " Cyrill Gorcunov via Tarantool-patches
@ 2021-05-17  7:36       ` Igor Munkin via Tarantool-patches
  2021-05-17  8:22       ` Igor Munkin via Tarantool-patches
  2021-05-17  8:22       ` Alexander V. Tikhonov via Tarantool-patches
  2 siblings, 0 replies; 7+ messages in thread
From: Igor Munkin via Tarantool-patches @ 2021-05-17  7:36 UTC (permalink / raw)
  To: Cyrill Gorcunov; +Cc: tml, Vladislav Shpilevoy

Cyrill,

On 14.05.21, Cyrill Gorcunov wrote:
> On Fri, May 14, 2021 at 01:41:15PM +0300, Igor Munkin wrote:
> > Cyrill,
> > 
> > Thanks for the fixes! Just a couple of nits.
> > 
> > On 14.05.21, Cyrill Gorcunov via Tarantool-patches wrote:
> > > This fixes a nit in commit 6af473778
> > > (fiber: use uint64_t for fiber IDs).
> > 
> > If you want to mention this commit, please use the full hash and enclose
> 
> I don't understand why you need a full hash? When the reference is generated
> the git makes sure that id being generated is long enough among existing
> commits to be parseble. But sure, no problem.

Fun fact: I see no words regarding this in our contribution guide, so I
have no answer for you, only examples.

> 
> > the commit subject into single quotes: it's the common way used in repo.
> > You can find an example here[1] (but GitHub strips the hash while
> > rendering the webpage).
> > 
> > > 
> > > Since lua_pushfstring doesn't support %llu format it
> > > breaks the test
> > 
> > Minor: It would be nice to refer Lua Reference Manual[2] then.
> 
> Sure, thanks!
> 
> > > +		snprintf(buf, sizeof(buf),
> > > +			 "fiber %llu is switched while running the"
> > > +			 " compiled code (it's likely a function with"
> > > +			 " a yield underneath called via LuaJIT FFI)",
> > > +			 (long long)fiber()->fid);
> > 
> > Why do you cast the value to long long (i.e. signed value), but use the
> > unsigned %llu modifier? This might be OK, but it's not clear to me.
> 
> Because only _size_ of argument does matter, and language standart
> guarantees that signed and unsigned arguments are counterparts. Thus
> instead of big "unsigned long long" specificator you can write a
> shorthand "long long".

I see now, thanks for clarification!

> 
> Force pushed an update.

Now LGTM, thanks.

> ---
> From: Cyrill Gorcunov <gorcunov@gmail.com>
> Date: Fri, 14 May 2021 13:18:13 +0300
> 
> This fixes a nit in commit 6af4737789042b1e6673c421686bb4394a61f4a1
> ("fiber: use uint64_t for fiber IDs").
> 
> Since lua_pushfstring doesn't support %llu format [1] it
> breaks the test
> 
> app-tap/gh-1700-abort-recording-on-fiber-switch.test.lua
> 
> [1] https://www.lua.org/manual/5.1/manual.html#lua_pushfstring
> 
> Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
> ---
>  src/lua/utils.c | 20 +++++++++++++-------
>  1 file changed, 13 insertions(+), 7 deletions(-)
> 
> diff --git a/src/lua/utils.c b/src/lua/utils.c
> index 0fbe700fc..3ce821374 100644
> --- a/src/lua/utils.c
> +++ b/src/lua/utils.c
> @@ -1341,6 +1341,7 @@ void cord_on_yield(void)
>  	 * code misbehaviour and failures, so stop its execution.
>  	 */
>  	if (unlikely(tvref(g->jit_base))) {
> +		char buf[256];
>  		/*
>  		 * XXX: mcode is executed only in scope of Lua
>  		 * world and one can obtain the corresponding Lua
> @@ -1348,10 +1349,12 @@ void cord_on_yield(void)
>  		 */
>  		struct lua_State *L = fiber()->storage.lua.stack;
>  		assert(L != NULL);
> -		lua_pushfstring(L, "fiber %llu is switched while running the"
> -				" compiled code (it's likely a function with"
> -				" a yield underneath called via LuaJIT FFI)",
> -				(long long)fiber()->fid);
> +		snprintf(buf, sizeof(buf),
> +			 "fiber %llu is switched while running the"
> +			 " compiled code (it's likely a function with"
> +			 " a yield underneath called via LuaJIT FFI)",
> +			 (long long)fiber()->fid);
> +		lua_pushstring(L, buf);
>  		if (g->panic)
>  			g->panic(L);
>  		exit(EXIT_FAILURE);
> @@ -1376,11 +1379,14 @@ void cord_on_yield(void)
>  	 * GC hook is active and the platform is forced to stop.
>  	 */
>  	if (unlikely(g->hookmask & HOOK_GC)) {
> +		char buf[128];
>  		struct lua_State *L = fiber()->storage.lua.stack;
>  		assert(L != NULL);
> -		lua_pushfstring(L, "fiber %d is switched while running GC"
> -				" finalizer (i.e. __gc metamethod)",
> -				fiber()->fid);
> +		snprintf(buf, sizeof(buf),
> +			 "fiber %llu is switched while running GC"
> +			 " finalizer (i.e. __gc metamethod)",
> +			 (long long)fiber()->fid);
> +		lua_pushstring(L, buf);
>  		if (g->panic)
>  			g->panic(L);
>  		exit(EXIT_FAILURE);
> -- 
> 2.31.1
> 

-- 
Best regards,
IM

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [Tarantool-patches] [PATCH v3] lua/utils: fix fiber->fid print in cord_on_yield
  2021-05-14 12:15     ` [Tarantool-patches] [PATCH v3] " Cyrill Gorcunov via Tarantool-patches
  2021-05-17  7:36       ` Igor Munkin via Tarantool-patches
@ 2021-05-17  8:22       ` Igor Munkin via Tarantool-patches
  2021-05-17  8:22       ` Alexander V. Tikhonov via Tarantool-patches
  2 siblings, 0 replies; 7+ messages in thread
From: Igor Munkin via Tarantool-patches @ 2021-05-17  8:22 UTC (permalink / raw)
  To: Cyrill Gorcunov; +Cc: tml, Vladislav Shpilevoy

Cyrill,

I've checked the patch into master.

On 14.05.21, Cyrill Gorcunov wrote:

<snipped>

> ---
> From: Cyrill Gorcunov <gorcunov@gmail.com>
> Date: Fri, 14 May 2021 13:18:13 +0300
> 
> This fixes a nit in commit 6af4737789042b1e6673c421686bb4394a61f4a1
> ("fiber: use uint64_t for fiber IDs").
> 
> Since lua_pushfstring doesn't support %llu format [1] it
> breaks the test
> 
> app-tap/gh-1700-abort-recording-on-fiber-switch.test.lua
> 
> [1] https://www.lua.org/manual/5.1/manual.html#lua_pushfstring
> 
> Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
> ---
>  src/lua/utils.c | 20 +++++++++++++-------
>  1 file changed, 13 insertions(+), 7 deletions(-)
> 
> diff --git a/src/lua/utils.c b/src/lua/utils.c
> index 0fbe700fc..3ce821374 100644
> --- a/src/lua/utils.c
> +++ b/src/lua/utils.c
> @@ -1341,6 +1341,7 @@ void cord_on_yield(void)
>  	 * code misbehaviour and failures, so stop its execution.
>  	 */
>  	if (unlikely(tvref(g->jit_base))) {
> +		char buf[256];
>  		/*
>  		 * XXX: mcode is executed only in scope of Lua
>  		 * world and one can obtain the corresponding Lua
> @@ -1348,10 +1349,12 @@ void cord_on_yield(void)
>  		 */
>  		struct lua_State *L = fiber()->storage.lua.stack;
>  		assert(L != NULL);
> -		lua_pushfstring(L, "fiber %llu is switched while running the"
> -				" compiled code (it's likely a function with"
> -				" a yield underneath called via LuaJIT FFI)",
> -				(long long)fiber()->fid);
> +		snprintf(buf, sizeof(buf),
> +			 "fiber %llu is switched while running the"
> +			 " compiled code (it's likely a function with"
> +			 " a yield underneath called via LuaJIT FFI)",
> +			 (long long)fiber()->fid);
> +		lua_pushstring(L, buf);
>  		if (g->panic)
>  			g->panic(L);
>  		exit(EXIT_FAILURE);
> @@ -1376,11 +1379,14 @@ void cord_on_yield(void)
>  	 * GC hook is active and the platform is forced to stop.
>  	 */
>  	if (unlikely(g->hookmask & HOOK_GC)) {
> +		char buf[128];
>  		struct lua_State *L = fiber()->storage.lua.stack;
>  		assert(L != NULL);
> -		lua_pushfstring(L, "fiber %d is switched while running GC"
> -				" finalizer (i.e. __gc metamethod)",
> -				fiber()->fid);
> +		snprintf(buf, sizeof(buf),
> +			 "fiber %llu is switched while running GC"
> +			 " finalizer (i.e. __gc metamethod)",
> +			 (long long)fiber()->fid);
> +		lua_pushstring(L, buf);
>  		if (g->panic)
>  			g->panic(L);
>  		exit(EXIT_FAILURE);
> -- 
> 2.31.1
> 

-- 
Best regards,
IM

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [Tarantool-patches] [PATCH v3] lua/utils: fix fiber->fid print in cord_on_yield
  2021-05-14 12:15     ` [Tarantool-patches] [PATCH v3] " Cyrill Gorcunov via Tarantool-patches
  2021-05-17  7:36       ` Igor Munkin via Tarantool-patches
  2021-05-17  8:22       ` Igor Munkin via Tarantool-patches
@ 2021-05-17  8:22       ` Alexander V. Tikhonov via Tarantool-patches
  2 siblings, 0 replies; 7+ messages in thread
From: Alexander V. Tikhonov via Tarantool-patches @ 2021-05-17  8:22 UTC (permalink / raw)
  To: Cyrill Gorcunov; +Cc: tarantool-patches

Hi Cyrill, thanks for the patch, it LGTM.

On Fri, May 14, 2021 at 03:15:14PM +0300, Cyrill Gorcunov via Tarantool-patches wrote:
> On Fri, May 14, 2021 at 01:41:15PM +0300, Igor Munkin wrote:
> > Cyrill,
> > 
> > Thanks for the fixes! Just a couple of nits.
> > 
> > On 14.05.21, Cyrill Gorcunov via Tarantool-patches wrote:
> > > This fixes a nit in commit 6af473778
> > > (fiber: use uint64_t for fiber IDs).
> > 
> > If you want to mention this commit, please use the full hash and enclose
> 
> I don't understand why you need a full hash? When the reference is generated
> the git makes sure that id being generated is long enough among existing
> commits to be parseble. But sure, no problem.
> 
> > the commit subject into single quotes: it's the common way used in repo.
> > You can find an example here[1] (but GitHub strips the hash while
> > rendering the webpage).
> > 
> > > 
> > > Since lua_pushfstring doesn't support %llu format it
> > > breaks the test
> > 
> > Minor: It would be nice to refer Lua Reference Manual[2] then.
> 
> Sure, thanks!
> 
> > > +		snprintf(buf, sizeof(buf),
> > > +			 "fiber %llu is switched while running the"
> > > +			 " compiled code (it's likely a function with"
> > > +			 " a yield underneath called via LuaJIT FFI)",
> > > +			 (long long)fiber()->fid);
> > 
> > Why do you cast the value to long long (i.e. signed value), but use the
> > unsigned %llu modifier? This might be OK, but it's not clear to me.
> 
> Because only _size_ of argument does matter, and language standart
> guarantees that signed and unsigned arguments are counterparts. Thus
> instead of big "unsigned long long" specificator you can write a
> shorthand "long long".
> 
> Force pushed an update.
> ---
> From: Cyrill Gorcunov <gorcunov@gmail.com>
> Date: Fri, 14 May 2021 13:18:13 +0300
> 
> This fixes a nit in commit 6af4737789042b1e6673c421686bb4394a61f4a1
> ("fiber: use uint64_t for fiber IDs").
> 
> Since lua_pushfstring doesn't support %llu format [1] it
> breaks the test
> 
> app-tap/gh-1700-abort-recording-on-fiber-switch.test.lua
> 
> [1] https://www.lua.org/manual/5.1/manual.html#lua_pushfstring
> 
> Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
> ---
>  src/lua/utils.c | 20 +++++++++++++-------
>  1 file changed, 13 insertions(+), 7 deletions(-)
> 
> diff --git a/src/lua/utils.c b/src/lua/utils.c
> index 0fbe700fc..3ce821374 100644
> --- a/src/lua/utils.c
> +++ b/src/lua/utils.c
> @@ -1341,6 +1341,7 @@ void cord_on_yield(void)
>  	 * code misbehaviour and failures, so stop its execution.
>  	 */
>  	if (unlikely(tvref(g->jit_base))) {
> +		char buf[256];
>  		/*
>  		 * XXX: mcode is executed only in scope of Lua
>  		 * world and one can obtain the corresponding Lua
> @@ -1348,10 +1349,12 @@ void cord_on_yield(void)
>  		 */
>  		struct lua_State *L = fiber()->storage.lua.stack;
>  		assert(L != NULL);
> -		lua_pushfstring(L, "fiber %llu is switched while running the"
> -				" compiled code (it's likely a function with"
> -				" a yield underneath called via LuaJIT FFI)",
> -				(long long)fiber()->fid);
> +		snprintf(buf, sizeof(buf),
> +			 "fiber %llu is switched while running the"
> +			 " compiled code (it's likely a function with"
> +			 " a yield underneath called via LuaJIT FFI)",
> +			 (long long)fiber()->fid);
> +		lua_pushstring(L, buf);
>  		if (g->panic)
>  			g->panic(L);
>  		exit(EXIT_FAILURE);
> @@ -1376,11 +1379,14 @@ void cord_on_yield(void)
>  	 * GC hook is active and the platform is forced to stop.
>  	 */
>  	if (unlikely(g->hookmask & HOOK_GC)) {
> +		char buf[128];
>  		struct lua_State *L = fiber()->storage.lua.stack;
>  		assert(L != NULL);
> -		lua_pushfstring(L, "fiber %d is switched while running GC"
> -				" finalizer (i.e. __gc metamethod)",
> -				fiber()->fid);
> +		snprintf(buf, sizeof(buf),
> +			 "fiber %llu is switched while running GC"
> +			 " finalizer (i.e. __gc metamethod)",
> +			 (long long)fiber()->fid);
> +		lua_pushstring(L, buf);
>  		if (g->panic)
>  			g->panic(L);
>  		exit(EXIT_FAILURE);
> -- 
> 2.31.1
> 

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2021-05-17  8:43 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-05-14 10:19 [Tarantool-patches] [PATCH] lua/utils: fix fiber->fid print in Lua tracing Cyrill Gorcunov via Tarantool-patches
2021-05-14 10:32 ` [Tarantool-patches] [PATCH v2] lua/utils: fix fiber->fid print in cord_on_yield Cyrill Gorcunov via Tarantool-patches
2021-05-14 10:41   ` Igor Munkin via Tarantool-patches
2021-05-14 12:15     ` [Tarantool-patches] [PATCH v3] " Cyrill Gorcunov via Tarantool-patches
2021-05-17  7:36       ` Igor Munkin via Tarantool-patches
2021-05-17  8:22       ` Igor Munkin via Tarantool-patches
2021-05-17  8:22       ` Alexander V. Tikhonov via Tarantool-patches

Tarantool development patches archive

This inbox may be cloned and mirrored by anyone:

	git clone --mirror https://lists.tarantool.org/tarantool-patches/0 tarantool-patches/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 tarantool-patches tarantool-patches/ https://lists.tarantool.org/tarantool-patches \
		tarantool-patches@dev.tarantool.org.
	public-inbox-index tarantool-patches

Example config snippet for mirrors.


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git