I do not have time for a longer answer right now but note two things:<br><br>- Segmentation faults in arbitrary code can not be graciously handled by ECL. Instead it just looks for the outermost CATCH_ALL statement and jumps there. Since there is no such statement surrounding c_string_to_object(), it just quits.<br>
<br>- puts() accesses the content of its argument. if you use puts(obj == OBJNULL) it is like using puts(1) which tries to access the memory location (char*)1 causing a segmentation fault or an access violation -- it depends on the OS.<br>
<br>Juanjo<br><br>On Sat, Mar 13, 2010 at 5:08 PM, Seth Burleigh <span dir="ltr"><<a href="mailto:seth@tewebs.com">seth@tewebs.com</a>></span> wrote:<br><div class="gmail_quote"><blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">
So, i decided that I would try to get a c REPL going which would also<br>
catch any errors with incorrectly entered code (not go into the<br>
debugger). Cool stuff , ecl:)<br>
Anyways, I found that whenever I entered an statement which would<br>
generate an error, like the letter a, the program exits with a<br>
segmentation fault. Im not exactly sure why entering an invalid<br>
statement would generate one. I was also wondering if ecl was supposed<br>
to catch all segmentation faults which resuled from lisp code executing<br>
inside of it? According to this:<br>
<a href="http://ecls.sourceforge.net/new-manual/re41.html" target="_blank">http://ecls.sourceforge.net/new-manual/re41.html</a><br>
SIGSEGV should be caught automatically? I noticed that if i used<br>
cl_eval, everything would work, it would just go into the debugger.<br>
Also, I noticed that if i uncommented the code below it would produce a<br>
"Detected acccess to an invalid or protected memory address" and would<br>
throw me into the lisp debugger. I know this has something to do with<br>
'puts' expecting a constant char* while the statement obj==OBJNULL<br>
returns an int, but I would like to understand what exactly is causing<br>
this error.<br>
<br>
Heres the code:<br>
<br>
#include <ecl/ecl.h><br>
#include <stdio.h><br>
#include <string.h><br>
<br>
int main(int argc, char **argv)  {<br>
  cl_boot(argc, argv);<br>
  cl_env_ptr env = ecl_process_env();<br>
  while (1) {<br>
    printf(">>");<br>
    int nbytes = 100;<br>
    char *str = (char*)malloc(nbytes);<br>
    getline(&str,&nbytes,stdin);<br>
    if (strcmp(str,"exit\n")==0 ) {<br>
      break;<br>
    }<br>
<br>
    cl_object obj = c_string_to_object(str);<br>
<br>
    //uncommented code below produced unprotected access error<br>
    //puts(obj==OBJNULL);<br>
<br>
    CL_CATCH_ALL_BEGIN(env) {<br>
      cl_object evaled = cl_safe_eval(obj,(cl_object)env,Cnil);<br>
      cl_pprint(1,evaled);<br>
    } CL_CATCH_ALL_IF_CAUGHT {<br>
      puts("ERROR");<br>
    } CL_CATCH_ALL_END;<br>
  }<br>
  cl_shutdown();<br>
}<br>
<br>
<br>
<br>
------------------------------------------------------------------------------<br>
Download Intel&#174; Parallel Studio Eval<br>
Try the new software tools for yourself. Speed compiling, find bugs<br>
proactively, and fine-tune applications for parallel performance.<br>
See why Intel Parallel Studio got high marks during beta.<br>
<a href="http://p.sf.net/sfu/intel-sw-dev" target="_blank">http://p.sf.net/sfu/intel-sw-dev</a><br>
_______________________________________________<br>
Ecls-list mailing list<br>
<a href="mailto:Ecls-list@lists.sourceforge.net">Ecls-list@lists.sourceforge.net</a><br>
<a href="https://lists.sourceforge.net/lists/listinfo/ecls-list" target="_blank">https://lists.sourceforge.net/lists/listinfo/ecls-list</a><br>
</blockquote></div><br><br clear="all"><br>-- <br>Instituto de Física Fundamental, CSIC<br>c/ Serrano, 113b, Madrid 28006 (Spain) <br><a href="http://juanjose.garciaripoll.googlepages.com">http://juanjose.garciaripoll.googlepages.com</a><br>