chicken-users
[Top][All Lists]
Advanced

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

Re: [Chicken-users] difference between ##sys#error and posix-error?


From: John Cowan
Subject: Re: [Chicken-users] difference between ##sys#error and posix-error?
Date: Thu, 29 Sep 2011 11:04:24 -0400
User-agent: Mutt/1.5.18 (2008-05-17)

Alaric Snell-Pym scripsit:

> Ooof, is that correct? IIRC, strerror isn't thread safe. We may not be
> using POSIX threads, but might Chicken not schedule a new thread between
> strerror and string-append, which might itself call strerror and thus
> produce an invalid error message? I'm not sure at what points the
> scheduler is actually able to preempt.

The problem is actually worse than that: a call to a C library earlier
in the program might have spawned[*] an OS thread that has itself
called strerror, corrupting the internal buffer.  Any program that
allows the user to invoke arbitrary libraries must assume that it is
running more than one OS thread.

[*] I say "spawned" because OS threads are denizens of the uttermost
depths of Hell.

> The solution, if that is a potential problem, is strerror_r, where you
> pass in your own string buffer.

That is what must be done.

-- 
Babies are born as a result of the              John Cowan
mating between men and women, and most          http://www.ccil.org/~cowan
men and women enjoy mating.                     address@hidden
    --Isaac Asimov in Earth: Our Crowded Spaceship



reply via email to

[Prev in Thread] Current Thread [Next in Thread]