From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: From: Vladislav Shpilevoy Subject: [PATCH 3/8] console: fix a bug in interactive readline usage Date: Mon, 16 Apr 2018 21:39:13 +0300 Message-Id: <634d1f3fd9f96b7302a77a9508705206d115bd82.1523903144.git.v.shpilevoy@tarantool.org> In-Reply-To: References: In-Reply-To: References: To: tarantool-patches@freelists.org Cc: vdavydov.dev@gmail.com List-ID: Spurious wakeups are possible in console, that makes readline think that there are some data on stdin. Waked up readline returns garbage instead of string, that crashes a server on assertion in Lua. Closes #3343 --- src/box/lua/console.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/box/lua/console.c b/src/box/lua/console.c index d27d7ecac..7a5ac5550 100644 --- a/src/box/lua/console.c +++ b/src/box/lua/console.c @@ -221,8 +221,9 @@ lbox_console_readline(struct lua_State *L) */ rl_callback_handler_install(prompt, console_push_line); top = lua_gettop(L); - while (top == lua_gettop(L) && - coio_wait(STDIN_FILENO, COIO_READ, TIMEOUT_INFINITY)) { + while (top == lua_gettop(L)) { + while (coio_wait(STDIN_FILENO, COIO_READ, + TIMEOUT_INFINITY) == 0); rl_callback_read_char(); } -- 2.15.1 (Apple Git-101)