]> git.ipfire.org Git - thirdparty/haproxy.git/commit
BUG/MEDIUM: hlua: Be able to garbage collect uninitialized lua sockets
authorChristopher Faulet <cfaulet@haproxy.com>
Fri, 16 Feb 2024 14:00:54 +0000 (15:00 +0100)
committerChristopher Faulet <cfaulet@haproxy.com>
Fri, 16 Feb 2024 14:48:08 +0000 (15:48 +0100)
commit38534d344bdcdbfee72291b847087d0424f56529
tree0ce56443e53ec252b78b8646373938b3d9e3eb89
parentcd7e73efae643940153b891d3333b6042db14244
BUG/MEDIUM: hlua: Be able to garbage collect uninitialized lua sockets

It is poosible to create a lua socket without performing any connect. In
this case, the lua socket is released because of the garbage collector.
However, the garbarge collector does not release the applet, it wakes it
up. Since commit 751b59c40b ("BUG/MEDIUM: hlua: Initialize appctx used by a
lua socket on connect only"), the applet initialization is performed on
connect. So, here, it is possible to wake an uninitialized applet. It is an
unexpected case for the applet's I/O handler, leading to a segfault because
some resources are not initialized (the stream's target in this case).

So, now, in the lua socket GC function, we take care to immediately release
uninitialized applets. At worst, the release itself is delayed. But it is
safe because we are sure the applet's I/O handler will never be executed.

In addition, we take case to increment the GC counter when the lua socket is
created. The way, uninitialized lua socket are released more quickly.

This patch should fix the issue #2451. It must be backported as far as 2.6.
src/hlua.c