]> git.ipfire.org Git - thirdparty/haproxy.git/commit
BUG/MINOR: hlua: SET_SAFE_LJMP misuse in hlua_event_runner()
authorAurelien DARRAGON <adarragon@haproxy.com>
Mon, 15 May 2023 16:46:44 +0000 (18:46 +0200)
committerChristopher Faulet <cfaulet@haproxy.com>
Wed, 17 May 2023 14:48:40 +0000 (16:48 +0200)
commit7428adaf0da600e9b80fc3857d24483656cb4f45
tree000186f1e799cd58f1ae595f8614c1665a60f95d
parent06e9c81bd078b14dfc7d728b027fe42e5dc4755c
BUG/MINOR: hlua: SET_SAFE_LJMP misuse in hlua_event_runner()

When hlua_event_runner() pauses the subscription (ie: if the consumer
can't keep up the pace), hlua_traceback() is used to get the current
lua trace (running context) to provide some info to the user.

However, as hlua_traceback() may raise an error (__LJMP) is set, it is
used within a SET_SAFE_LJMP() / RESET_SAFE_LJMP() combination to ensure
lua errors are properly handled and don't result in unexpected behavior.

But the current usage of SET_SAFE_LJMP() within the function is wrong
since hlua_traceback() will run a second time (unprotected) if the
first (protected) attempt fails. This is undefined behavior and could
even lead to crashes.

Hopefully it is very hard to trigger this code path, thus we can consider
this as a minor bug.

Also using this as an opportunity to enhance the message report to make
it more meaningful to the user.

This should fix GH #2159.

It is a 2.8 specific bug, no backport needed unless c84899c636
("MEDIUM: hlua/event_hdl: initial support for event handlers") gets
backported.
src/hlua.c