[Tarantool-patches] [PATCH luajit v2] Fix command-line argv handling.
Maxim Kokryashkin
m.kokryashkin at tarantool.org
Thu Apr 11 17:45:35 MSK 2024
Hi, Sergey!
Thanks for the patch!
Fixed, branch is force-pushed:
===
diff --git a/test/tarantool-c-tests/CMakeLists.txt b/test/tarantool-c-tests/CMakeLists.txt
index 7ae440e2..5f789ad8 100644
--- a/test/tarantool-c-tests/CMakeLists.txt
+++ b/test/tarantool-c-tests/CMakeLists.txt
@@ -36,9 +36,9 @@ add_test_suite_target(tarantool-c-tests
DEPENDS libluajit libtest tarantool-c-tests-build
)
-# XXX: The tarantool-c-tests target cannot be linked with the LuaJIT
-# library when it is built as shared. The test suite is disabled for
-# the dynamic build mode.
+# XXX: The tarantool-c-tests target cannot be linked with the
+# LuaJIT library when it is built as shared. The test suite is
+# disabled for the dynamic build mode.
if(BUILDMODE STREQUAL "dynamic")
message("Dynamic build mode, tarantool-c-tests suite is empty")
return()
diff --git a/test/tarantool-tests/CMakeLists.txt b/test/tarantool-tests/CMakeLists.txt
index 05deb534..0d5f3774 100644
--- a/test/tarantool-tests/CMakeLists.txt
+++ b/test/tarantool-tests/CMakeLists.txt
@@ -128,7 +128,8 @@ file(GLOB_RECURSE tests ${CMAKE_CURRENT_SOURCE_DIR} "*${LUA_TEST_SUFFIX}")
foreach(test_path ${tests})
get_filename_component(test_name ${test_path} NAME)
- if(test_name STREQUAL "fix-argv-handling.test.lua" AND NOT BUILDMODE STREQUAL "dynamic")
+ if(test_name STREQUAL "fix-argv-handling.test.lua"
+ AND NOT BUILDMODE STREQUAL "dynamic")
continue()
endif()
diff --git a/test/tarantool-tests/fix-argv-handling.test.lua b/test/tarantool-tests/fix-argv-handling.test.lua
index 57e5f169..fd558705 100644
--- a/test/tarantool-tests/fix-argv-handling.test.lua
+++ b/test/tarantool-tests/fix-argv-handling.test.lua
@@ -5,9 +5,9 @@ local test = tap.test('fix-argv-handling'):skipcond({
test:plan(1)
--- XXX: Since the Linux kernel 5.18-rc1 release, `argv` is
--- forced to a single empty string if it is empty [1], so
--- the issue is not reproducible on new kernels.
+-- XXX: Since the Linux kernel 5.18-rc1 release, `argv` is forced
+-- to a single empty string if it is empty [1], so the issue is
+-- not reproducible on new kernels.
--
-- [1]: https://lore.kernel.org/all/20220201000947.2453721-1-keescook@chromium.org/
@@ -19,7 +19,7 @@ local cmd = utils.exec.luabin(arg)
-- `luaL_newstate`.
local output = execlib.empty_argv_exec(cmd)
--- Without the patch, the test fails with a segmentation fault instead of
--- returning an error.
+-- Without the patch, the test fails with a segmentation fault
+-- instead of returning an error.
test:like(output, 'cannot create state', 'correct argv handling')
test:done(true)
diff --git a/test/tarantool-tests/fix-argv-handling/execlib.c b/test/tarantool-tests/fix-argv-handling/execlib.c
index ef8217d4..a8d5f16c 100644
--- a/test/tarantool-tests/fix-argv-handling/execlib.c
+++ b/test/tarantool-tests/fix-argv-handling/execlib.c
@@ -1,7 +1,7 @@
+#define _GNU_SOURCE
#include "lua.h"
#include "lauxlib.h"
-#define _GNU_SOURCE
#include <fcntl.h>
#include <stdio.h>
#include <stdlib.h>
@@ -22,7 +22,7 @@ static int empty_argv_exec(struct lua_State *L)
{
const char *path = luaL_checkstring(L, -1);
int pipefds[2] = {};
- char *const argv[] = {NULL};
+ char *const argv[] = {NULL};
char buf[BUF_SIZE];
CHECKED(pipe2(pipefds, O_CLOEXEC));
@@ -32,15 +32,15 @@ static int empty_argv_exec(struct lua_State *L)
if (pid == 0) {
/*
- * Mock the `luaL_newstate` with
- * an error-injected version.
+ * Mock the `luaL_newstate` with an error-injected
+ * version.
*/
setenv("LD_PRELOAD", "mynewstate.so", 1);
- CHECKED(dup2(pipefds[1], 1));
- CHECKED(dup2(pipefds[1], 2));
+ CHECKED(dup2(pipefds[1], STDOUT_FILENO));
+ CHECKED(dup2(pipefds[1], STDERR_FILENO));
/*
- * Pipes are closed on the exec
- * call because of the O_CLOEXEC flag.
+ * Pipes are closed on the exec call because of
+ * the O_CLOEXEC flag.
*/
CHECKED(execvp(path, argv));
}
@@ -48,7 +48,6 @@ static int empty_argv_exec(struct lua_State *L)
close(pipefds[1]);
CHECKED(waitpid(pid, NULL, 0));
-
CHECKED(read(pipefds[0], buf, BUF_SIZE));
close(pipefds[0]);
===
More information about the Tarantool-patches
mailing list