[plt-scheme] embedding - crash after scheme_basic_env

From: Kevin Tew (tewk at cs.utah.edu)
Date: Wed Mar 3 14:11:56 EST 2010

Fixed in svn

The logger config parameter wasn't being initialized for subsequent 
interpreters.

diff --git a/src/mzscheme/src/env.c b/src/mzscheme/src/env.c
index 8bfe025..df7a8de 100644
--- a/src/mzscheme/src/env.c
+++ b/src/mzscheme/src/env.c
@@ -270,6 +270,7 @@ Scheme_Env *scheme_restart_instance() {
   scheme_init_port_config();
   scheme_init_port_fun_config();
   scheme_init_error_config();
+  scheme_init_logger_config();
 #ifndef NO_SCHEME_EXNS
   scheme_init_exn_config();
 #endif



Dave Griffiths wrote:
> Hi all,
>
> I've found a problem which manifests itself in 4.2.4. 
>
> Using scheme_main_stack_setup I create a new interpreter using
> scheme_basic_env, and everything works as expected. However, after
> creating a new interpreter, and passing a string with an error such as
> "(modulo 1 2 3)" I get a crash inside the error logger.
>
> I suspect something needs to happen to the new Scheme_Env after it's
> been created. Here is some code which reproduces the crash:
>
> #define MZ_PRECISE_GC
>
> #include "scheme.h"
> #include "base.c"
> #include <iostream>
> using namespace std;
>
> static Scheme_Env *e;
>
> void register_interpreter()
> {
>     MZ_GC_DECL_REG(0);
>     MZ_GC_REG();
>     MZ_REGISTER_STATIC(e);
>     MZ_GC_UNREG();  
> }
>
> void make_interpreter()
> {
>    Scheme_Object *v = NULL;
>     
>    MZ_GC_DECL_REG(1);
>    MZ_GC_VAR_IN_REG(0, v);
>    MZ_GC_REG();
>     
>    e=scheme_basic_env();
>     
>    declare_modules(e);
>    v = scheme_intern_symbol("scheme/base");
>    scheme_namespace_require(v);    
>    MZ_GC_UNREG();
> }
>
> void interpret(const char *code)
> {  
>     mz_jmp_buf * volatile save = NULL, fresh;
>     
>     MZ_GC_DECL_REG(1);
>     MZ_GC_VAR_IN_REG(0, save);
>     MZ_GC_REG();
>     
>     save = scheme_current_thread->error_buf;
>     scheme_current_thread->error_buf = &fresh;
>     if (scheme_setjmp(scheme_error_buf)) {
>         scheme_current_thread->error_buf = save;
>         MZ_GC_UNREG();
>         return; /* There was an error */
>     } else {
>         scheme_eval_string(code, e);       
>     }   
>     
>     MZ_GC_UNREG();
> }
>
> static int run(void *data)
> {
>     register_interpreter();
>     
>     make_interpreter();
>     interpret("(modulo 1 2 3)"); // <- returns error as expected
>     make_interpreter();
>     interpret("(modulo 1 2 3)"); // <- crash!
>     
>     return 0;
> }
>
> int main(int argc, char *argv[])
> {
>     return scheme_main_stack_setup(1, run, NULL);
> }
>
>
> _________________________________________________
>   For list-related administrative tasks:
>   http://list.cs.brown.edu/mailman/listinfo/plt-scheme
>   



Posted on the users mailing list.