Re: segmentation fault in lj_vm_growstack_f

  • From: ZNV <mejedi@xxxxxxxxx>
  • To: luajit@xxxxxxxxxxxxx
  • Date: Fri, 10 Aug 2018 13:26:58 +0200

If I remember correctly, we don’t have the logic that switches to
another task in a C function which called by LuaJIT. The OpenSSL co-routine
(fiber) switched always by Nginx’s code.

Still not convinced. Certificate callback is invoked in a context of
OpenSSL fiber. The callback invokes Lua. Is it possible that Lua calls
something from OpenSSL that causes it to switch to a different fiber or
return to Nginx?

It is relatively easy to verify the hypothesis: put a breakpoint in a
function OpenSSL uses for fiber switching, and print the stack. Once
crashed, inspect the output, if there was ANY luajit calls on ANY of the
captured stacks, then that's the culprit.

(FYI:
https://stackoverflow.com/questions/6517423/how-to-do-an-specific-action-when-a-certain-breakpoint-is-hit-in-gdb
)

пт, 10 авг. 2018 г. в 12:06, tokers <zchao1995@xxxxxxxxx>:

Hello!

Thanks for the response!

So you are having a situation like this:

1) Lua calls a C function (via Lua C api or FFI, doesn't matter for now).
2) That C function performs task switching (switches to a different C
stack/execution state in the same thread).
3) Now another C function is executing.
4) It invokes Lua, or returns to Lua.

LuaJIT is not expecting this kind of reentrancy. Don't do it. Just don’t!

If I remember correctly, we don’t have the logic that switches to
another task in a C function which called by LuaJIT. The OpenSSL
co-routine (fiber) switched always by Nginx’s code.

If you are doing task-switching in a lua-C function, this will work,
since lua-C function calls are never JIT-compiled. Make sure that the
following patches are applied to your LuaJIT:


https://github.com/tarantool/luajit/commit/ed412cd9f55fe87fd32a69c86e1732690fc5c1b0

https://github.com/tarantool/luajit/commit/5ccd25d740476a37d414733b5192d5be0ef06173

Thanks for the patches, I will try it!


Other related posts: