Bug 41 - swi-prolog overrides all assertions by defining __assert_fail
: swi-prolog overrides all assertions by defining __assert_fail
Status: CONFIRMED
Product: SWI-Prolog
Classification: Unclassified
Component: core
: unspecified
: PC Linux
: Highest normal
Assigned To: Jan Wielemaker
:
:
:
  Show dependency treegraph
 
Reported: 2012-06-27 17:14 CEST by Ambroz Bizjak
Modified: 2012-06-27 17:14 CEST (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Ambroz Bizjak 2012-06-27 17:14:29 CEST
The swipl dynamic library defines the glibc function __assert_fail. This has
the effect that all assertion failures in a program linked to the swipl library
are handled by swipl's assertion failure handler. See:
http://www.swi-prolog.org/git/pl-devel.git/blob/HEAD:/src/pl-thread.c#l5477

This is a problem, because if an assertion failure occurs in a program
embedding SWI-Prolog while the prolog engine is not initialized, the assert
handler will call PL_thread_self(), which will crash.

A possible solution is for SWI-Prolog to use its own assert macro internally
which does whatever it needs to do (and which is only used when the engine is
initialized), and leave the normal assert() behavior unchanged.