diff options
author | mpeterv <mpeterval@gmail.com> | 2015-02-24 23:36:59 +0300 |
---|---|---|
committer | mpeterv <mpeterval@gmail.com> | 2015-02-24 23:36:59 +0300 |
commit | 65f61fa6047a09347972af1214f45149be311fb6 (patch) | |
tree | fbf87271a50509898e48ee0ca2cdc6d83a3b5ae7 | |
parent | be58bb0bf683c5c15589ecf68367a1fbaa9e0a8f (diff) | |
download | lanes-65f61fa6047a09347972af1214f45149be311fb6.tar.gz lanes-65f61fa6047a09347972af1214f45149be311fb6.tar.bz2 lanes-65f61fa6047a09347972af1214f45149be311fb6.zip |
Fix segfault in LG_lane_new
STACK_END macro was used to check stack size of child Lua state _after_
its thread was launched. That could lead to the check failing as the child
thread started manipulating the stack. The macro then called lua_error
on the child state from the parent thread, causing a segfault as Lua C API
is not thread-safe.
The fix is to place STACK_END statements before THREAD_CREATE statement.
-rw-r--r-- | src/lanes.c | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/src/lanes.c b/src/lanes.c index 9b95469..8852687 100644 --- a/src/lanes.c +++ b/src/lanes.c | |||
@@ -2419,13 +2419,13 @@ LUAG_FUNC( lane_new) | |||
2419 | lua_sethook( L2, cancel_hook, LUA_MASKCOUNT, cancelstep_idx); | 2419 | lua_sethook( L2, cancel_hook, LUA_MASKCOUNT, cancelstep_idx); |
2420 | } | 2420 | } |
2421 | 2421 | ||
2422 | STACK_END( L, 1); | ||
2423 | STACK_END( L2, 1 + nargs); | ||
2424 | |||
2422 | DEBUGSPEW_CODE( fprintf( stderr, INDENT_BEGIN "lane_new: launching thread\n" INDENT_END)); | 2425 | DEBUGSPEW_CODE( fprintf( stderr, INDENT_BEGIN "lane_new: launching thread\n" INDENT_END)); |
2423 | THREAD_CREATE( &s->thread, lane_main, s, priority); | 2426 | THREAD_CREATE( &s->thread, lane_main, s, priority); |
2424 | 2427 | ||
2425 | DEBUGSPEW_CODE( -- U->debugspew_indent_depth); | 2428 | DEBUGSPEW_CODE( -- U->debugspew_indent_depth); |
2426 | |||
2427 | STACK_END( L, 1); | ||
2428 | STACK_END( L2, 1 + nargs); | ||
2429 | return 1; | 2429 | return 1; |
2430 | } | 2430 | } |
2431 | 2431 | ||