]> git.ipfire.org Git - thirdparty/haproxy.git/commit
BUG/MEDIUM: memory: Add a rwlock before freeing memory.
authorOlivier Houchard <cognet@ci0.org>
Sat, 1 Feb 2020 16:49:31 +0000 (17:49 +0100)
committerOlivier Houchard <cognet@ci0.org>
Sat, 1 Feb 2020 17:08:34 +0000 (18:08 +0100)
commit04f5fe87d3d3a222b89420f8c1231461f55ebdeb
tree8c9d1fed40fbe634ebeb114f861b9cf2a0a1990b
parent8af97eb4a19c1d3c0849b5e5e5d350d63f819032
BUG/MEDIUM: memory: Add a rwlock before freeing memory.

When using lockless pools, add a new rwlock, flush_pool. read-lock it when
getting memory from the pool, so that concurrenct access are still
authorized, but write-lock it when we're about to free memory, in
pool_flush() and pool_gc().
The problem is, when removing an item from the pool, we unreference it
to get the next one, however, that pointer may have been free'd in the
meanwhile, and that could provoke a crash if the pointer has been unmapped.
It should be OK to use a rwlock, as normal operations will still be able
to access the pool concurrently, and calls to pool_flush() and pool_gc()
should be pretty rare.

This should be backported to 2.1, 2.0 and 1.9.
include/common/memory.h
src/memory.c