[PPL-devel] Re: Raising Prolog exceptions from C code (2nd attempt)
bagnara at cs.unipr.it
Mon Jun 10 19:47:52 CEST 2002
Daniele Peri wrote:
> Fri, 2002-06-07 19:25, Roberto Bagnara wrote:
>>in my application (http://www.cs.unipr.it/ppl/) and I observe exactly
>>the same segmentation violations and illegal instructions.
>>May it be because Pl_Exec_Continuation is implemented by means
>>of setjmp/longjmp and I am doing something that is incompatible
>>with them? What can it be?
> I hope not to bother anyone telling again that this problem seems very
> similar to the one I experienced with my applications using GTK. I found
> that such problems arise when linking code compiled without using frame
> pointer (like many distribution libraries) and gprolog compiled with all
> the default optimizations (among them the use of frame pointer).
> Problems actually appear just with callbacks in the case of GTK so I
> think your hypothesis could be right. I made some test in gdb
> discovering a complete mess in the stack after a call from a GTK
> callback. In some cases I could make things work by modifying manually
> the stack pointer. I discussed it with Daniel Diaz but I haven't had the
> time to test it thoroughly as Daniel asked me. My simple solution, so
> far, is to compile GNUProlog and the "critic" libraries or source-code
> all in the same way.
thanks for your message. Your analysis works!
I use the GMP library which, by default, is compiled with
-fomit-frame-pointer. And I use the PPL library
(http://www.cs.unipr.it/ppl/) that, by default, is compiled
I have first tried to compile PPL with -fomit-frame-pointer
and then I discovered the bug of GCC 3.0.x whereby
C++ exceptions don't work with -fomit-frame-pointer.
Then I have tried compiling everything without -fomit-frame-pointer
and everything works OK: I can throw C++ exceptions, catch them
in C++ to convert them into GNU Prolog exceptions that can then
correctly be caught by Prolog code.
I really feel this is a strong limitation of GNU Prolog:
we cannot ask our users to recompile every library they use
so as to make sure that -fomit-frame-pointer is used or
left out consistently in all the builds.
Daniel, do you envisage any solution to this problem?
Can we do something to help?
All the best
Prof. Roberto Bagnara
Computer Science Group
Department of Mathematics, University of Parma, Italy
mailto:bagnara at cs.unipr.it
More information about the PPL-devel