]> git.kaiwu.me - haproxy.git/commit
BUG/MINOR: hlua: release private Lua rule data on teardown
authorM9nx <flowmoner@gmail.com>
Mon, 24 Aug 2026 04:15:42 +0000 (07:15 +0300)
committerChristopher Faulet <cfaulet@haproxy.com>
Mon, 21 Sep 2026 05:52:25 +0000 (07:52 +0200)
commit3316314ee8613bc510733b2c151715c6bdbf5981
tree70a0c7679d40bedfc74bbae81042d3005efea435
parentd75b8423483883561eea79e3dcd5f5210382856a
BUG/MINOR: hlua: release private Lua rule data on teardown

Lua actions and services allocate a `struct hlua_rule` (and sometimes an
arguments array) while parsing the configuration. The resulting private
structure is stored in the generic `act_rule` structure.

However, these parsers failed to register a `release_ptr` callback. As a
result, when `free_act_rule()` destroys the parent rule during proxy
teardown (e.g. at process exit or soft-reload deinit), it leaks the
Lua-private allocation. This is exposed by LeakSanitizer when validating
configurations that use Lua rules (e.g. `examples/games.cfg -c`).

This is a configuration/process-lifetime data leak rather than a
per-request or per-connection leak. It does not accumulate during normal
runtime operation.

This patch fixes the issue by adding a common release callback and
assigning it in all three Lua parsers that allocate this structure
(`action_register_lua`, `action_register_service_http`, and
`action_register_service_tcp`). The callback frees the `hlua_rule`
and any owned argument strings, while deliberately leaving the borrowed
`hlua_function` untouched.

This fixes issue #3480.

Backport status: may be backported to all supported versions.
src/hlua.c