]> git.ipfire.org Git - thirdparty/haproxy.git/commit
BUG/MEDIUM: lua: Always init the lua stack before referencing the context
authorChristopher Faulet <cfaulet@haproxy.com>
Wed, 24 Mar 2021 14:03:01 +0000 (15:03 +0100)
committerChristopher Faulet <cfaulet@haproxy.com>
Wed, 24 Mar 2021 15:36:36 +0000 (16:36 +0100)
commit1e8433f594de4b860e5205fdd6cb40d91ff58f17
tree3cded58b88ce157524b4d12ba23ee163506a3bd0
parentcc2c4f8f4c1d8613b481d1b346e083a9d2462811
BUG/MEDIUM: lua: Always init the lua stack before referencing the context

When a lua context is allocated, its stack must be initialized to NULL
before attaching it to its owner (task, stream or applet).  Otherwise, if
the watchdog is fired before the stack is really created, that may lead to a
segfault because we try to dump the traceback of an uninitialized lua stack.

It is easy to trigger this bug if a lua script do a blocking call while
another thread try to initialize a new lua context. Because of the global
lua lock, the init is blocked before the stack creation. Of course, it only
happens if the script is executed in the shared global context.

This patch must be backported as far as 2.0.
src/hlua.c