[PPL-devel] Re: [Yap-users] Throwing Prolog exceptions from C code

Roberto Bagnara bagnara at cs.unipr.it
Tue Jun 18 07:45:20 CEST 2002


Vitor Santos Costa wrote:
> Sorry for the delay.
> 
>  There were indeed problems when using YapRunGoal, as it was only
> tested from the top-level. YapThrow and YapCallProlog seemed to be
> working fine.
> 
>  This is a program I used for testing (I updated some changes to the
>  CVS version). Do you mind checking if it works for you? If it
>  doesn't, please tell me. If it does, then I think I'll need some more
>  info to track your bug.

Dear Vitor,

I have temporarily included your code into our YAP module (see near the end of
http://www.cs.unipr.it/cgi-bin/cvsweb.cgi/ppl/interfaces/Prolog/YAP/ppl_yap.cc?rev=1.31&content-type=text/x-cvsweb-markup
It seems that the external predicates are not behaving as expected.
I enclose under the signature the log of a gdb session.
Please let me know what should I do to help in identifying the problem.
All the best

      Roberto

P.S.  Very recently, a problem with the exception mechanism of GNU Prolog
       was identified.  Roughly speaking, to make things work both GNU Prolog
       and foreign code have to be compiled with -fomit-frame-pointer,
       or both of them have to be compiled without using that option.
       Does this ring a bell?

-- 
Prof. Roberto Bagnara
Computer Science Group
Department of Mathematics, University of Parma, Italy
http://www.cs.unipr.it/~bagnara/
mailto:bagnara at cs.unipr.it

$ gdb yap
(gdb) r
Starting program: /usr/local/bin/yap
[ Restoring file startup ]
[ YAP version Yap-4.3.22 ]
    ?- load_foreign_files(['ppl_yap'], [], init).

yes
    ?- x(a).
[ No handler for error f(hello,_96,a) ]
    ?-  x2(a).

no
    ?-  ux(a).


Program received signal SIGSEGV, Segmentation fault.
0x08051469 in StaticGetAPropHavingLock (ae=0x16911100, kind=65535)
     at Yatom.h:108
108 
{
(gdb) info stack
#0  0x08051469 in StaticGetAPropHavingLock (ae=0x16911100, kind=65535)
     at Yatom.h:108
#1  0x080514b1 in GetAProp (a=0x16911100, kind=65535) at C/adtdefs.c:264
#2  0x0809af4d in writeTerm (t=135986733, p=1200, depth=1, rinfixarg=0)
     at C/write.c:446
#3  0x0809b853 in plwrite (t=135986733, mywrite=0x807ef10 <format_putc>,
     flags=4) at C/write.c:675
#4  0x08080a67 in format (tail=135986987, args=34, sno=2) at C/iopreds.c:4227
#5  0x08080f7a in p_format2 () at C/iopreds.c:4356
#6  0x080a602a in absmi (inp=0) at C/absmi.c:5719
#7  0x0806c9ec in exec_absmi (top=1) at C/exec.c:881
#8  0x0806cbf2 in do_goal (CodeAdr=0x80f2130 "", arity=0, pt=0x0,
     args_to_save=0, top=1) at C/exec.c:942
#9  0x0806d254 in RunTopGoal (t=214610) at C/exec.c:1128
#10 0x080504da in YapRunGoal (t=214610) at C/c_interface.c:704
#11 0x0804eb41 in do_top_goal (Goal=214610) at console/yap.c:122
#12 0x0804f2e1 in exec_top_level (BootMode=1, filename=0x0)
     at console/yap.c:457
#13 0x0804f35f in main (argc=1, argv=0xbffff994) at console/yap.c:483
#14 0x42017499 in __libc_start_main () from /lib/i686/libc.so.6
(gdb) r
The program being debugged has been started already.
Start it from the beginning? (y or n) y
Starting program: /usr/local/bin/yap
[ Restoring file startup ]
[ YAP version Yap-4.3.22 ]
    ?- load_foreign_files(['ppl_yap'], [], init).

yes
    ?- g(X=2).

no
    ?- g(fail).

no
    ?- g(throw(a)).

[ No handler for error a ]
    ?- h2(X=2).

no
    ?- h2(fail).
[ YAP version Yap-4.3.22 ]
    ?- h2(throw(a)).
[ YAP version Yap-4.3.22 ]
    ?-
Program exited normally.
(gdb) q
$




More information about the PPL-devel mailing list