[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: strerror vs. threads
From: |
Eric Blake |
Subject: |
Re: strerror vs. threads |
Date: |
Tue, 24 May 2011 13:07:16 -0600 |
User-agent: |
Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.2.17) Gecko/20110428 Fedora/3.1.10-1.fc14 Lightning/1.0b3pre Mnenhy/0.8.3 Thunderbird/3.1.10 |
On 05/24/2011 12:52 PM, Simon Josefsson wrote:
>> POSIX explicitly allows strerror to use a static buffer, and that's
>> _exactly_ what gnulib's implementation does on out-of-range input.
>> Which means that "Unknown error (-1)" of thread 1 and "Unknown error
>> (-2)" of thread 2 are calling sprintf on the same memory at the same
>> time, and you will get indeterminate results.
>
> Which begs the question why the error messages needs to be different for
> different unknown errors? Is that required by POSIX?
Not required, but heavily recommended, and guaranteed by several common
platforms. And since "Error: " is much more confusing than "Error:
Unknown error -1", especially at tracking down a bug at why errno is set
to some weird value, it was worth documenting that we guarantee that
behavior as one of the points of the gnulib strerror replacement.
If you don't ever pass out-of-range errno values to strerror, then you
probably don't care about thread-safety of the out-of-range buffer, but
there is still the question of whether all existing implementations are
thread-safe even on in-range errno values.
--
Eric Blake address@hidden +1-801-349-2682
Libvirt virtualization library http://libvirt.org
signature.asc
Description: OpenPGP digital signature
- Re: new files imported without new modules added, (continued)
- Re: new files imported without new modules added, Sam Steingold, 2011/05/24
- Re: new files imported without new modules added, Eric Blake, 2011/05/24
- Re: new files imported without new modules added, Sam Steingold, 2011/05/24
- Re: new files imported without new modules added, Eric Blake, 2011/05/24
- Re: new files imported without new modules added, Sam Steingold, 2011/05/24
- strerror vs. threads [was: new files imported without new modules added], Eric Blake, 2011/05/24
- Re: strerror vs. threads [was: new files imported without new modules added], Simon Josefsson, 2011/05/24
- Re: strerror vs. threads,
Eric Blake <=
- Re: strerror vs. threads, Paul Eggert, 2011/05/24
- Re: strerror vs. threads, Simon Josefsson, 2011/05/24
- Re: strerror vs. threads, Eric Blake, 2011/05/24
- Re: strerror vs. threads, Simon Josefsson, 2011/05/25
- Re: strerror vs. threads, Eric Blake, 2011/05/25
- coping with conflicting strerror_r signatures [was: strerror vs. threads], Eric Blake, 2011/05/25
- Re: strerror vs. threads [was: new files imported without new modules added], Sam Steingold, 2011/05/24
- Re: strerror vs. threads [was: new files imported without new modules added], Eric Blake, 2011/05/24
- [PATCH 1/2] perror: call strerror_r directly, Eric Blake, 2011/05/24
- [PATCH 2/2] strerror: drop strerror_r dependency, Eric Blake, 2011/05/24