<div dir="ltr"><br><div class="gmail_extra"><div class="gmail_quote">On Wed, Aug 20, 2014 at 4:36 PM, Alexander Kjeldaas <span dir="ltr"><<a href="mailto:alexander.kjeldaas@gmail.com" target="_blank">alexander.kjeldaas@gmail.com</a>></span> wrote:<br>

<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div class="gmail_extra"><div class="gmail_quote"><div>Reading errno directly after the FFI call can eliminate heap overflows, but the async exception and timer issues still seem possible.<br>



<span class=""></span><span class=""></span></div></div></div></div>
</blockquote></div><br></div><div class="gmail_extra">I have played around a bit and I can't understand what's going on with this anymore. Check out this example: <a href="https://gist.github.com/abbradar/76dafcee1807c9c5ac4d">https://gist.github.com/abbradar/76dafcee1807c9c5ac4d</a>. Compile it with "ghc test_c.c test.hs". I used "mask_" here to check if it can fix the problem.<br>

<br></div><div class="gmail_extra">There will be multiple <span id="result_box" class="" lang="en"><span class="">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.<br>

<br></span></span></div><div class="gmail_extra"><span id="result_box" class="" lang="en"><span class="">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?<br>

</span></span></div></div>