sb(PI,Line,Id) :-
% get src file
pi_head(PI,Head), clause(Head,_,Ref),
clause_property(Ref,file(File)),
% set breakpoint
set_breakpoint(File,Line,1,Id).
8 ?- sb(mod:somepred/1,1229,I).
[...]received fatal signal 11 (segv)
C-stack trace labeled "crash":
[0] save_backtrace() at :? [0x7f03031884f1]
[1] print_c_backtrace() at :? [0x7f03031885ad]
[2] sigCrashHandler() at :? [0x7f03031886bd]
[3] __restore_rt() at sigaction.c:? [0x7f0302f3cda0]
[4] pl_clause_from_source4_va() at pl-srcfile.c:? [0x7f03031499ca]
[5] PL_next_solution___LD() at :? [0x7f0303191c02]
[6] query_loop() at :? [0x7f03031d3d88]
[7] prologToplevel() at :? [0x7f03031d3c1b]
[8] PL_toplevel() at ??:? [0x7f03031e89eb]
[9] swipl(+0x10b1) [0x55dfe77370b1]
[10] __libc_start_main() at ??:? [0x7f0302f27b25]
[11] swipl(+0x10ee) [0x55dfe77370ee]
Prolog stack:
[13] system:$clause_from_source/4 [PC=1 in supervisor]
[12] prolog_breakpoints:set_breakpoint/5 [PC=25 in clause 1]
[10] sb/3 [PC=30 in clause 1]
[9] $toplevel:toplevel_call/1 [PC=3 in clause 1]
[8] $toplevel:stop_backtrace/2 [PC=4 in clause 1]
[7] $tabling:$wfs_call/2 [PC=17 in clause 1]
[5] $toplevel:$execute_goal2/3 [PC=31 in clause 1]
[3] $toplevel:$query_loop/0 [PC=39 in clause 2]
[2] $toplevel:$runtoplevel/0 [PC=19 in clause 1]
[1] $toplevel:$toplevel/0 [PC=3 in clause 1]
[0] system:$c_call_prolog/0 [PC=0 in top query clause]
Running on_halt hooks with status 139
Killing 1530697 with default signal handlers
I am getting a crash when trying to set a breakpoint; this happens with the graphical debugger also; it happens with one prolog source code file, unfortunately I can’t reproduce it with a smaller file, but hopefully the above gives enough information to track down the problem. Running the latest SWI-Prolog (8.5.4-13-g9d2babb2c).
I tried to make a small reproducible version but it didn’t reproduce with the smaller source. I will try to bisect the code and see if I can make it reproducible with a small sample. It will most likely be some days.
It doesn’t need to be small. The way to find this is first to try enabling addresssanitizer (see CMAKE.md) and see whether we have to do with memory corruption. If not, I typically add a little C function that checks for the error condition and insert that at some places in the source to find where the issue is introduced. Can be tedious
That rings a bell. Note that thread_local always implies dynamic. Pushed a fix. Can’t verify it fixes the crash, but it was surely wrong code and could explain a crash.