
AFAIK "errno" is handled explicitly in the RTS:
https://ghc.haskell.org/trac/ghc/browser/ghc/rts/Schedule.c#L484
-Sylvain
2014-08-26 16:22 GMT+02:00 Nikolay Amiantov
On Wed, Aug 20, 2014 at 4:36 PM, Alexander Kjeldaas < alexander.kjeldaas@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@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe