[plt-scheme] bus error on exit

From: Robert Nikander (nikander at nc.rr.com)
Date: Wed Nov 7 16:54:27 EST 2007

On Nov 7, 2007, at 7:39 AM, Matthew Flatt wrote:

> At Sun, 4 Nov 2007 15:13:00 -0500, Robert Nikander wrote:
>> I've embedded mzscheme, and my main program calls exit() from a non-
>> scheme thread, which leads to a bus error in
>> 'scheme_do_close_managed' in thread.c.  Is there a recommended way to
>> shutdown the embedded mzscheme in this situation?
> I don't yet have any good ideas for this.
> MzScheme could provide a way to let you disable the work it does via
> atexit(), which is mostly just to flush output ports. Would that be
> enough?

Yes I think that would be fine, but I should clarify my situation, in  
case I gave the impression that I can't call functions from within  
the scheme thread before "exit" gets called -- I can do that, because  
I get notified of the impending exit.  I don't want to call "exit"  
itself, but that does stop the bus error.   I don't know if that  
changes your answer.  I was thinking something like the following  
might be possible...

     void scheme_self_terminate()
         run atexit actions
         disable atexit actions
         if I care about freeing memory:
             free all allocated memory

... which could also be used when the embedding OS process wants to  
keep running.  Otherwise, disabling the atexit handlers should work  
for my situation.


Posted on the users mailing list.