git: libthread_xu - Clean up the red zone on library unload
Matthew Dillon
dillon at crater.dragonflybsd.org
Wed Apr 16 10:04:57 PDT 2014
commit 0dc5e56d98ab5fc55416a204886f8b132cc9b7f1
Author: Matthew Dillon <dillon at apollo.backplane.com>
Date: Wed Apr 16 10:01:14 2014 -0700
libthread_xu - Clean up the red zone on library unload
* If the main program is not linked against -pthread but dynamically
loads a shared library that is via dlopen(), then dlclose()'s it,
libthread_xu leaves red-zone and cached thread stacks dangling.
The second attempt to (indirectly) load libthread_xu then fails with a
red-zone panic.
* Add a destructor for libthread_xu to unmap the red-zone and to clean out
any cached thread stacks.
* Note that neither libthread_xu nor most other large libraries are designed
to be unloaded. That is, even if loading/unloading works, numerous libraries
will almost certainly leak memory. This change prevents the fatal error but
doesn't fix the general memory leakage problem.
IMHO Only libraries designed to be unloadable should be unloaded.
Reported-by: Vasily Postnicov <shamaz.mazum at gmail.com>
Summary of changes:
lib/libthread_xu/thread/thr_init.c | 28 +++++++++++++++++++++++++---
lib/libthread_xu/thread/thr_private.h | 1 +
lib/libthread_xu/thread/thr_stack.c | 12 ++++++++++++
3 files changed, 38 insertions(+), 3 deletions(-)
http://gitweb.dragonflybsd.org/dragonfly.git/commitdiff/0dc5e56d98ab5fc55416a204886f8b132cc9b7f1
--
DragonFly BSD source repository
More information about the Commits
mailing list