Subject: Re: syslog_r (Re: CVS commit: src/lib/libc)
To: Elad Efrat <elad@NetBSD.org>
From: SODA Noriyuki <soda@sra.co.jp>
List: tech-userlevel
Date: 10/26/2006 15:21:27
>>>>> On Thu, 26 Oct 2006 07:30:59 +0200, Elad Efrat <elad@NetBSD.org> said:

> the OpenBSD implementation is documented to be signal-safe, but that
> might be because functions it relies on were also made signal-safe, at
> least there.
>
> take a look at their signal(3):
>
> http://www.openbsd.org/cgi-bin/man.cgi?query=signal&sektion=3

The OpenBSD documentation is wrong.

For example, the snprintf() function indirectly calls __dtoa() via
following path:
	snprintf() -> vfprintf() -> cvt() -> __dtoa()
And the __dtoa() implemenation modifies lots of static data as you see
in the following source:
	http://www.openbsd.org/cgi-bin/cvsweb/src/lib/libc/stdlib/strtod.c?rev=1.28&content-type=text/x-cvsweb-markup
e.g. __dtoa() modifies freelist[].

The snprintf() function is not async-signal-safe, even on OpenBSD.
-- 
soda