cvs commit: src/bin/sh memalloc.c memalloc.h miscbltin.c

John Baldwin jhb at
Fri Oct 28 08:45:36 PDT 2005

On Friday 28 October 2005 06:45 am, Stefan Farfeleder wrote:
> stefanf     2005-10-28 10:45:19 UTC
>   FreeBSD src repository
>   Modified files:
>     bin/sh               memalloc.c memalloc.h miscbltin.c
>   Log:
>   Protect malloc, realloc and free calls with INT{ON,OFF} directly in
> chkalloc, ckrealloc and ckfree (added), respectively.  sh jumps out of the
> signal handler using longjmp which is obviously a bad idea during malloc
> calls.
>   Note: I think there is still a small race here because volatile
> sig_atomic_t only guarantees atomic reads and writes while we're doing
> increments and decrements.
>   Protect a setmode call with INT{ON,OFF} as it calls malloc internally.
>   PR:             45478
>   Patch from:     Nate Eldredge

If you are just doing a simple reference count you can use an int and use 
either the refcount API from sys/refcount.h or the atomic_foo_int() 
operations directly from machine/atomic.h.  Those should all work fine in 

John Baldwin <jhb at>  <><
"Power Users Use the Power to Serve"  =

More information about the cvs-src mailing list