Date: Fri, 28 Oct 2005 10:33:46 -0400 From: John Baldwin <jhb@freebsd.org> To: Stefan Farfeleder <stefanf@freebsd.org> Cc: cvs-src@freebsd.org, src-committers@freebsd.org, cvs-all@freebsd.org Subject: Re: cvs commit: src/bin/sh memalloc.c memalloc.h miscbltin.c Message-ID: <200510281033.48001.jhb@freebsd.org> In-Reply-To: <200510281045.j9SAjJmR096150@repoman.freebsd.org> References: <200510281045.j9SAjJmR096150@repoman.freebsd.org>
next in thread | previous in thread | raw e-mail | index | archive | help
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
userland.
--
John Baldwin <jhb@FreeBSD.org> <>< http://www.FreeBSD.org/~jhb/
"Power Users Use the Power to Serve" = http://www.FreeBSD.org
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200510281033.48001.jhb>
