[Tarantool-patches] [PATCH v2] lua/utils: fix fiber->fid print in cord_on_yield

Cyrill Gorcunov gorcunov at gmail.com
Fri May 14 13:32:51 MSK 2021


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 at 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



More information about the Tarantool-patches mailing list