Dimitris,<div><br></div><div>(From only looking very generally at your code,)</div><div><br></div><div>May this be a stack unwinding problem?</div><div><br></div><div>If you unwind a stack other than in the same order it was wound in the first place, your Gambit process will terminate or at least crash.</div>

<div><br></div><div>Example:</div><div><br></div><div>You have a lambda A that invokes C-lambda B that invokes lambda C.</div><div><br></div><div>Also, a lambda D that invokes C-lambda E that invokes lambda F.</div><div>
<br>
</div><div>If you invoke A and A invokes B and B invokes C,</div><div><br></div><div>and then say, Gambit switches thread, and that Gambit thread invokes D which invokes E which invokes F,</div><div><br></div><div>and then, say, Gambit switches thread again, and that Gambit thread returns from C to B.</div>

<div><br>Then your Gambit process is toast.</div><div><br></div><div>To handle this you can switch off Gambit's threading system when you're in B or E for the course of your C and F calls respectively. Note that switching off Gambit's threading system means that some or several of Gambit's built-in IO primitives would block forever.</div>

<div><br></div><div>See the "How to work with external libraries" Wiki page for how to switch it off.</div><div><br></div><div>Was this of help?</div><div><br></div><div>Mikael<br><br><div class="gmail_quote">2013/2/23 Dimitris Vyzovitis <span dir="ltr"><<a href="mailto:vyzo@hackzen.org" target="_blank">vyzo@hackzen.org</a>></span><br>

<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">I am running into an abrupt exit with error code 71 (OSError) when<br>
multiple (scheme) threads are making ffi calls that upcall to scheme.<br>
<br>
A simplified scenario (see attached file) is as follows:<br>
2 or more threads make an ffi call.<br>
The ffi call is a longer running procedure, that makes upcalls into<br>
scheme procedures that do I/O.<br>
This results in the program exiting abruptly with error code 71, and<br>
no context information regarding the error (even when compiled and<br>
running with full debugging).<br>
<br>
For an illustration of the problem, see the attached file.<br>
<br>
The following should print dots indefinitely, but instead quickly<br>
terminates with 71.<br>
<br>
$ gsc exit71.scm<br>
$  gsi -e "(begin (load \"exit71\") (main))"<br>
....<plenty of dots>.... $ echo $?<br>
71<br>
<br>
This is with gambit-4.6.6, system is GNU/Linux x86-64.<br>
<br>
-- vyzo<br>
<br>_______________________________________________<br>
Gambit-list mailing list<br>
<a href="mailto:Gambit-list@iro.umontreal.ca">Gambit-list@iro.umontreal.ca</a><br>
<a href="https://webmail.iro.umontreal.ca/mailman/listinfo/gambit-list" target="_blank">https://webmail.iro.umontreal.ca/mailman/listinfo/gambit-list</a><br>
<br></blockquote></div><br></div>