tech-userlevel archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

malloc() signal safety?



Is there any interest in making malloc-family calls optionally
signal-safe?  Specifically, for work, in 9.1, I added a way for
userland to cause malloc-family calls to sigprocmask(SIG_BLOCK) with an
application-specified signal mask before starting (and
sigprocmask(SIG_SETMASK) to restore the mask before returning).

Obviously, two syscalls per call is a price.  But for some use cases it
may be worth it.  And if the application doesn't request it, the only
cost is a variable test and conditional branch, twice per call.

The source-code cost is 84 added lines in
external/bsd/jemalloc/dist/src/jemalloc.c and 31 added lines in
lib/libc/stdlib/jemalloc.c - the latter may be unneessary.  The
namespace-pollution cost is two globally visible functions in libc,
which my implementation calls malloc_set_signalmask and
malloc_no_signalmask.

/~\ The ASCII				  Mouse
\ / Ribbon Campaign
 X  Against HTML		mouse%rodents-montreal.org@localhost
/ \ Email!	     7D C8 61 52 5D E7 2D 39  4E F1 31 3E E8 B3 27 4B


Home | Main Index | Thread Index | Old Index