This is the mail archive of the guile@cygnus.com mailing list for the Guile project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

gh_eval_str("(amb)") =SIGSEGV?


The 'amb' evaluator called without any arguments via gh_eval_str crashes
libguile programs.
I have tried with libguile that was checked out in Jul99 and with an
older copy from SuSE 6.1.

Summary:
char *s;
...
while(1){
  s=gimme_some();
  gh_eval_str(s);
  free(s);
}
That works fine until s is "(amb)". Then gh_eval_str trashes 's' and
changes
its address so that free(s) segfaults.

The problem is reproduced in 'learn0.c' which is from
guile-doc/tut/guile-tut.html. See the links at the bottom for info
on how to get learn0.c and amb.scm.
Everything will work ok until you type "(amb)".

/* modified fragment from program learn0.c */
while (fgets(input_str, 199, stdin) != NULL) {
    char *s=strdup(input_str); /* just for demonstration*/
    gh_eval_str(s);
    free(s);
}
/*******end**********/
Try the following:
(load 'amb.scm)
(amb 1 2 3 4 5 6 7 8 9 10) ;==>1
(amb 'a 'b 'c); ==>a
(amb)

How is one expected to free s? The program where this problem was
noticed calls
gh_eval_str with malloc:ed strings and is always crashing each time user
types "(amp)":

Breakpoint 9, parse_scheme (str=0x8160478 "(amb)", w=-1) at
our_guile.c:2447
(gdb) step
gh_eval_str_with_catch (scheme_code=0x8160478 "(amb)", handler=0x8055da0
<exception_handler>) at gh_eval.c:78
(gdb) cont
Breakpoint 10, parse_scheme (str=0x814bf20 "h\023\b\232", w=-1) at
our_guile.c:2448
(gdb) cont
__libc_free (mem=0x814bf20) at malloc.c:2842
(gdb) cont
Program received signal SIGSEGV, Segmentation fault.

Links to learn0.c and amb.scm:
<a href="http://members.xoom.com/sprimerix/tmp">
http://members.xoom.com/sprimerix/tmp3
</a> for both. amb evaluator is from
<a href="http://www.cs.rice.edu/~dorai/t-y-scheme/t-y-scheme.html">Teach
You
rself Scheme in Fixnum Days</a>.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]