[Haskell-cafe] Locking of threads in one OS thread

Sylvain Henry hsyl20 at gmail.com
Tue Aug 26 14:59:42 UTC 2014

AFAIK "errno" is handled explicitly in the RTS:


2014-08-26 16:22 GMT+02:00 Nikolay Amiantov <nikoamia at gmail.com>:

> On Wed, Aug 20, 2014 at 4:36 PM, Alexander Kjeldaas <
> alexander.kjeldaas at gmail.com> wrote:
>> Reading errno directly after the FFI call can eliminate heap overflows,
>> but the async exception and timer issues still seem possible.
> I have played around a bit and I can't understand what's going on with
> this anymore. Check out this example:
> https://gist.github.com/abbradar/76dafcee1807c9c5ac4d. Compile it with
> "ghc test_c.c test.hs". I used "mask_" here to check if it can fix the
> problem.
> There will be multiple discrepancies seen between written and read values
> because of threads preemption if my_errno is used. However, if you use
> "errno" (change #define for that) instead, everything seems good.
> Anyway, it looks like getErrno and friends rely on this magical behaviour
> of errno -- if some other library which uses global error state like
> "my_errno" in example is used (I remember SDL doing that, and I have also
> done it myself), there should be problems without some way to temporary
> disable threads preemption, which I haven't found. Hence -- should I maybe
> post a bug report about this?
> _______________________________________________
> Haskell-Cafe mailing list
> Haskell-Cafe at haskell.org
> http://www.haskell.org/mailman/listinfo/haskell-cafe
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.haskell.org/pipermail/haskell-cafe/attachments/20140826/6923bf40/attachment.html>

More information about the Haskell-Cafe mailing list