[plt-scheme] Embedding MzScheme Segfault

From: Lee Begg (llnz at paradise.net.nz)
Date: Tue Jun 21 20:45:12 EDT 2005

Hello

I'm embedding MzScheme in a C++ program. The program is/was/will be 
multithreaded.

The second time it starts using MzScheme, I get a segfault.

The start of the function TpMzScheme::evalDesign follows:

void TpMzScheme::evalDesign(Design* d){
  Scheme_Env *e;
  e = scheme_basic_env();
  if (scheme_setjmp(scheme_error_buf)) {
    Logger::getLogger()->warning("MzScheme Error");
  } else {
    Scheme_Object* temp = 
     scheme_eval_string("(load \"componentstrut.scm\")",e); //line 51
.... (more calls to scheme_eval_string())

It segfaults on the last line (line 51) above.  I thought that 
scheme_basic_env() created a fresh environment for MzScheme.  I don't do 
anything special at the end of the method, as I couldn't find any 
documentation that says to do anything.  I did try scheme_collect_garbage() 
after setting temp and e to NULL but it didn't change anything. GDB backtrace 
below.

What am I doing wrong?

Later
Lee Begg


Program received signal SIGSEGV, Segmentation fault.
(gdb) where
#0  0x0000002a9598c3db in scheme_call_enable_break () 
from /usr/lib/plt/lib/libmzscheme-209.so
#1  0x0000002a95942c6f in scheme_dynamic_wind () 
from /usr/lib/plt/lib/libmzscheme-209.so
#2  0x0000002a9598c839 in scheme_call_enable_break () 
from /usr/lib/plt/lib/libmzscheme-209.so
#3  0x0000002a95933581 in scheme_do_eval () 
from /usr/lib/plt/lib/libmzscheme-209.so
#4  0x0000002a9598c8e3 in scheme_call_enable_break () 
from /usr/lib/plt/lib/libmzscheme-209.so
#5  0x0000002a95942c6f in scheme_dynamic_wind () 
from /usr/lib/plt/lib/libmzscheme-209.so
#6  0x0000002a9598ca1b in scheme_load_with_clrd () 
from /usr/lib/plt/lib/libmzscheme-209.so
#7  0x0000002a9598ca44 in scheme_load_with_clrd () 
from /usr/lib/plt/lib/libmzscheme-209.so
#8  0x0000002a95933581 in scheme_do_eval () 
from /usr/lib/plt/lib/libmzscheme-209.so
#9  0x0000002a95935ada in scheme_eval_multi () 
from /usr/lib/plt/lib/libmzscheme-209.so
#10 0x0000002a9593efbb in top_level_do () 
from /usr/lib/plt/lib/libmzscheme-209.so
#11 0x0000002a9593f112 in scheme_top_level_do () 
from /usr/lib/plt/lib/libmzscheme-209.so
#12 0x0000002a95935b84 in scheme_eval_multi () 
from /usr/lib/plt/lib/libmzscheme-209.so
#13 0x0000002a95935bc6 in scheme_eval_compiled () 
from /usr/lib/plt/lib/libmzscheme-209.so
#14 0x0000002a959358d8 in scheme_eval () 
from /usr/lib/plt/lib/libmzscheme-209.so
#15 0x0000002a95936db9 in scheme_eval_string_all () 
from /usr/lib/plt/lib/libmzscheme-209.so
#16 0x0000002a95936dfe in scheme_eval_string () 
from /usr/lib/plt/lib/libmzscheme-209.so
#17 0x000000000042f683 in TpMzScheme::evalDesign (this=0x565c00, d=0x6b1170) 
at tpmzscheme.cpp:51
#18 0x00000000004262be in Design::eval (this=0x6b1170) at design.cpp:121
#19 0x0000000000427949 in DesignStore::addDesign (this=0x55f8d0, d=0x6b1170) 
at designstore.cpp:135
#20 0x000000000042e8aa in MiniSec::onPlayerAdded (this=0x55f8b0, 
player=0x565860) at minisec.cpp:377
#21 0x00000000004046cb in Game::findPlayer (this=0x55f7b0, name=0x565730 
"test", pass=0x565820 "test") at game.cpp:148
#22 0x0000000000422cf8 in PlayerConnection::login (this=0x564000) at 
playerconnection.cpp:117
#23 0x0000000000422aea in PlayerConnection::process (this=0x564000) at 
playerconnection.cpp:74
#24 0x000000000040cdf2 in Network::masterLoop (this=0x54f140) at net.cpp:196
#25 0x000000000040274b in main (argc=1, argv=0x7fbffff6e8) at main.cpp:67
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: not available
URL: <http://lists.racket-lang.org/users/archive/attachments/20050622/26221419/attachment.sig>

Posted on the users mailing list.