Tarantool development patches archive
 help / color / mirror / Atom feed
From: Kirill Shcherbatov <kshcherbatov@tarantool.org>
To: tarantool-patches@freelists.org
Cc: vdavydov.dev@gmail.com, Kirill Shcherbatov <kshcherbatov@tarantool.org>
Subject: [PATCH v1 1/1] box: fix crash in ncurses on fedora 28
Date: Wed,  8 Aug 2018 16:52:28 +0300	[thread overview]
Message-ID: <eb5323504261a57a84fa99e8072a89c8c919e1d7.1533736169.git.kshcherbatov@tarantool.org> (raw)

Tarantool has been crashing when trying to go into an
interactive loop in ncurses-libs/libtinfo library via
lbox_console_readline. This SIGABORT caused by stack
probing code that present in new ncurses distributions.

  lea r11,[rsp-frameSize]
label:
  sub rsp,pageSize
  or QWORD PTR [rsp],0x0
  cmp rsp,r11
  jne label

Where frameSize is 0x8000 and pageSize is 0x1000 for
version we've dedugged.
Code above tests marker value on pages start.
0x8000 frameSize is a precompiled ncurse's binary
internal value.
This third-party library is called by tarantool
fiber that have fiber stack of size 2*0x8000.
To the moment of crash, stack memory distributed:
ncurses   stack usage 0x91A8  bytes
total     stack usage 0x9488  bytes

We have to increase interactive console main loop
fiber stack to work with third-party libraries normally.

Closes #3418.
---
Branch: https://github.com/tarantool/tarantool/tree/kshch/gh-3418-crash-on-fedora
Issue: https://github.com/tarantool/tarantool/issues/3418

 src/lua/init.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/src/lua/init.c b/src/lua/init.c
index a0a7f63..217640f 100644
--- a/src/lua/init.c
+++ b/src/lua/init.c
@@ -610,8 +610,10 @@ tarantool_lua_run_script(char *path, bool interactive,
 	 * To work this problem around we must run init script in
 	 * a separate fiber.
 	 */
-
-	script_fiber = fiber_new(title, run_script_f);
+	struct fiber_attr fiber_attr =
+		{.stack_size = 0x8000 * 4,
+		 .flags = FIBER_DEFAULT_FLAGS | FIBER_CUSTOM_STACK};
+	script_fiber = fiber_new_ex(title, &fiber_attr, run_script_f);
 	if (script_fiber == NULL)
 		panic("%s", diag_last_error(diag_get())->errmsg);
 	fiber_start(script_fiber, tarantool_L, path, interactive,
-- 
2.7.4

             reply	other threads:[~2018-08-08 13:52 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-08-08 13:52 Kirill Shcherbatov [this message]
2018-08-08 18:27 ` Vladimir Davydov
2018-08-15 18:15 ` [tarantool-patches] " Kirill Shcherbatov

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=eb5323504261a57a84fa99e8072a89c8c919e1d7.1533736169.git.kshcherbatov@tarantool.org \
    --to=kshcherbatov@tarantool.org \
    --cc=tarantool-patches@freelists.org \
    --cc=vdavydov.dev@gmail.com \
    --subject='Re: [PATCH v1 1/1] box: fix crash in ncurses on fedora 28' \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox