From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from [87.239.111.99] (localhost [127.0.0.1]) by dev.tarantool.org (Postfix) with ESMTP id F21C1AFDAC1; Thu, 11 Apr 2024 17:45:39 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org F21C1AFDAC1 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=tarantool.org; s=dev; t=1712846740; bh=KzjgvkbcroDISSRHgpuupr7nTLDg7pvgSWqqW3bG670=; h=Date:To:Cc:References:In-Reply-To:Subject:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From:Reply-To:From; b=TIwIq4VgeyrAM6hXCHFMaSzNSwPiKIkB/3GUivTX80yYIxgQjgZA096Dj8XzNxsX2 XDw3D2qemasSaFfXkZ9+ybHvJhkeYrYDKVtejr21dwOl0iT7rSzbPHgJOEoa9/HFLc n8xSCx9bpz6J1faPa4LtFqKD6ANLeiK49pxWtDF0= Received: from smtp31.i.mail.ru (smtp31.i.mail.ru [95.163.41.72]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by dev.tarantool.org (Postfix) with ESMTPS id 55237AFDAC1 for ; Thu, 11 Apr 2024 17:45:38 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org 55237AFDAC1 Received: by smtp31.i.mail.ru with esmtpa (envelope-from ) id 1ruvgH-0000000DN5r-0YLK; Thu, 11 Apr 2024 17:45:37 +0300 Date: Thu, 11 Apr 2024 17:45:35 +0300 To: Sergey Kaplun Cc: Maxim Kokryashkin , tarantool-patches@dev.tarantool.org Message-ID: References: <20240411130057.1144616-1-m.kokryashkin@tarantool.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Mailru-Src: smtp X-4EC0790: 10 X-7564579A: EEAE043A70213CC8 X-77F55803: 4F1203BC0FB41BD91C726AF9233A4C6FA8143870728B8272760BE0FCA97B72EC1313CFAB8367EF908E2BE116634AD74D9A3CA2F218FDF189D7246FBA2AA80B992331FFDCA63C694D9EFABB7F86B8FC03CEE4813122F9A0DF X-7FA49CB5: FF5795518A3D127A4AD6D5ED66289B5278DA827A17800CE792C68BF9CD4C0E9EEA1F7E6F0F101C67BD4B6F7A4D31EC0BCC500DACC3FED6E28638F802B75D45FF8AA50765F7900637BC6099E116BE74F18638F802B75D45FF36EB9D2243A4F8B5A6FCA7DBDB1FC311F39EFFDF887939037866D6147AF826D809E9F6B3446333466277CEEF9BA68CF9FF0297937E5FE8A8CC7F00164DA146DAFE8445B8C89999728AA50765F7900637CAEE156C82D3D7D9389733CBF5DBD5E9C8A9BA7A39EFB766F5D81C698A659EA7CC7F00164DA146DA9985D098DBDEAEC8062BEEFFB5F8EA3EF6B57BC7E6449061A352F6E88A58FB86F5D81C698A659EA73AA81AA40904B5D9A18204E546F3947CAD74539164518AE56136E347CC761E074AD6D5ED66289B523666184CF4C3C14F6136E347CC761E07725E5C173C3A84C37CBB0FBB5CE38B96BA3038C0950A5D36B5C8C57E37DE458B330BD67F2E7D9AF16D1867E19FE14079C09775C1D3CA48CFED8438A78DFE0A9E1DD303D21008E298D5E8D9A59859A8B6B372FE9A2E580EFC725E5C173C3A84C37725542EFDE5E0D335872C767BF85DA2F004C90652538430E4A6367B16DE6309 X-C1DE0DAB: 0D63561A33F958A5207089E7EBE9422E5002B1117B3ED6965E9B25BE7467F8D8AD0703CEB2EF9A27823CB91A9FED034534781492E4B8EEAD220496FFA5CD4785BDAD6C7F3747799A X-C8649E89: 1C3962B70DF3F0ADE00A9FD3E00BEEDF3FED46C3ACD6F73ED3581295AF09D3DF87807E0823442EA2ED31085941D9CD0AF7F820E7B07EA4CF0DA7F6905D47750565D11A81A40A18B0A1CDD4037A373F5E7EDE4424E6CFB9C97649A938D59E33ED43A9A4803F78FBB9442E43BB33B9826B54890A08E1315550357044BC10B738335F4332CA8FE04980913E6812662D5F2A54F6898A6FDCBDC72A617DFBE5FEC2C6383653B6C8D9AE0FD16FCAA6493B703A X-D57D3AED: 3ZO7eAau8CL7WIMRKs4sN3D3tLDjz0dLbV79QFUyzQ2Ujvy7cMT6pYYqY16iZVKkSc3dCLJ7zSJH7+u4VD18S7Vl4ZUrpaVfd2+vE6kuoey4m4VkSEu530nj6fImhcD4MUrOEAnl0W826KZ9Q+tr5ycPtXkTV4k65bRjmOUUP8cvGozZ33TWg5HZplvhhXbhDGzqmQDTd6OAevLeAnq3Ra9uf7zvY2zzsIhlcp/Y7m53TZgf2aB4JOg4gkr2bioja81YqLNwFpk5/+zeT+En1Q== X-Mailru-Sender: 7940E2A4EB16C9976F80DCDCD59EC227B9D8F4030F901D3BAC8EDD30083ED68EC4AF13623E4ADD18E2527C969975515CFF9FCECFB8D89CB6C77752E0C033A69E235A20A81F3B0E39AB3C5F247CB2F7F93A5DB60FBEB33A8A0DA7A0AF5A3A8387 X-Mras: Ok Subject: Re: [Tarantool-patches] [PATCH luajit v2] Fix command-line argv handling. X-BeenThere: tarantool-patches@dev.tarantool.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Tarantool development patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , From: Maxim Kokryashkin via Tarantool-patches Reply-To: Maxim Kokryashkin Errors-To: tarantool-patches-bounces@dev.tarantool.org Sender: "Tarantool-patches" 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 #include #include @@ -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]); ===