[Ecls-list] Segmentation faults/detected access to ...address

Juan Jose Garcia-Ripoll juanjose.garciaripoll at googlemail.com
Sat Mar 13 22:51:11 UTC 2010


On Sat, Mar 13, 2010 at 5:08 PM, Seth Burleigh <seth at tewebs.com> wrote:

>
>      cl_object evaled = cl_safe_eval(obj,(cl_object)env,Cnil);
>

This line is wrong. The "environment" that cl_safe_eval() takes is not the
Lisp environment but the enviroment in which the form is compiled and
evaluated -- similar to the &env that a macro takes --. This was an
important source of problems, leaving the lisp library in an unstable state.

As for the rest, the segmentation faults you saw were a symptom that
something very wrong was going on, and it was caused by a chain of errors
caused when the debugger was entereed. In other words, ext:safe-eval was not
fully protected. I have changed the way forms are executed and hopefully now
the debugger will not be started at all.

Your example, with a minor change, seems to work

>>(prin "HI")

NIL
>>(cos 1.0)

0.54030234
>>(/ 2 0)

NIL
>>2.0

2.0
>>

Juanjo

#include <ecl/ecl.h>
#include <stdio.h>
#include <string.h>

int main(int argc, char **argv)  {
 cl_boot(argc, argv);
 cl_env_ptr env = ecl_process_env();
 while (1) {
   printf("\n>>");
   int nbytes = 100;
   char *str = (char*)malloc(nbytes);
   nbytes = fgets(str, nbytes, stdin) - str;
   if (strcmp(str,"exit\n")==0 ) {
     break;
   }

   cl_object obj = c_string_to_object(str);

   //uncommented code below produced unprotected access error
   //puts(obj==OBJNULL);

   CL_CATCH_ALL_BEGIN(env) {
     cl_object evaled = cl_safe_eval(obj,Cnil,Cnil);
     cl_pprint(1,evaled);
   } CL_CATCH_ALL_IF_CAUGHT {
     puts("ERROR");
   } CL_CATCH_ALL_END;

   free(str);
 }
 cl_shutdown();
}



-- 
Instituto de Física Fundamental, CSIC
c/ Serrano, 113b, Madrid 28006 (Spain)
http://juanjose.garciaripoll.googlepages.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mailman.common-lisp.net/pipermail/ecl-devel/attachments/20100313/9cbd784e/attachment.html>


More information about the ecl-devel mailing list