On 10/28/2015 05:05 PM, Marijn Schraagen wrote:
> After installing from source (swipl-devel/src with the COFLAGS as well
> as swipl-devel/packages/cpp with default settings) I now have version
> 7.3.9-48-g4431f35-DIRTY.
>
> Without the -d chk_secure the behaviour is the same as before (using
> either plain command line or gdb): normal run for a number of iterations
> and then a Prolog System Error.
>
> With -d chk_secure the behaviour is different. First, there are some
> warnings on initial functions using assertz:
> |
> 0x7f884f8685e8=local(2746):noton attvar chain
> [DATA INCONSISTENCY:attvar:noton attvar chain:0x4f8685e8]
> |
> repeated a couple of times.
Are you using constraints? If not, this is most likely some data
corruption already.
> Then, when entering the loop, the execution already fails in the first
> iteration (instead of after several iterations as before). Errors like:
> |
> [DATA INCONSISTENCY:Termat 0x7ffff7e9fb78noton globalstack]
> [DATA INCONSISTENCY:Illegalfunctor:0x196c0e]
> [DATA INCONSISTENCY:Illegalterm at:0x7ffff7e9fb88:0x7a908d]
> [DATA INCONSISTENCY:functor withmark:0x4910d]
> [DATA INCONSISTENCY:Illegalreference pointer at 0xf7e9fc18-->0xf7e9fb70]
> |
> occur during PL_close_query.
>
> Then, after
> |
> PL_recorded(rec,term_x)
> PL_erase(rec)
> PL_cons_functor(term1,funct2,term_x,...)
> PL_call(term1,NULL)
> |
> the following errors are shown:
> |
> !Illegalcell inglobalstack (up)at 0x7ffff7e954a0=global(1168)(*=[M]term
> at global(1163))
> !Illegalcell inglobalstack (up)at
> 0x7ffff7e954a8=global(1169)(*=[M]functor [|]/2)
> ...
> !Illegalcell inglobalstack (down)at 0x7ffff7e97cb0(*=0x4912d)
> ...
> |
> followed by
> |
> [Thread1(main)at
> WedOct2814:33:532015]pl-gc.c:3663:checkStacks:Assertionfailed:scan_global(0)
> C-stack trace labeled "assert_fail":
> [0]save_backtrace()at
> /home/marijn/install/swipl-devel/src/os/pl-cstack.c:307[0x7ffff7b72e82]
> [1]__assert_fail()at
> /home/marijn/install/swipl-devel/src/pl-thread.c:6040[0x7ffff7b2733f]
> [2]checkStacks()at
> /home/marijn/install/swipl-devel/src/pl-gc.c:3664[0x7ffff7ac1f86]
> [3]PL_open_query()at
> /home/marijn/install/swipl-devel/src/pl-wam.c:2214[0x7ffff7a7a836]
> [4]callProlog()at
> /home/marijn/install/swipl-devel/src/pl-pro.c:318[0x7ffff7ae0a3a]
> [5]PL_call()at
> /home/marijn/install/swipl-devel/src/pl-fli.c:3645[0x7ffff7a76edd]
> Programreceived signal SIGABRT,Aborted.
This is probably caused by the already corrupt data after the
PL_close_query().
> |
>
> The (simplified) program flow is shown below. Interestingly, the error
> occurs on the second run of the for-loop, when i=1.
>
> |
> initial_functions_using_assertz();
>
> PlCall("consult('
pprint.pl')";//official SWI-Prolog pretty print library
> functor_t funct2 =PL_new_functor(PL_new_atom("print_term"),2);
> term_t nl =PL_new_term_ref();
> PL_put_nil(nl);
>
> PL_new_term_ref,PL_new_functor,PL_pred forfurther variables
> record_t rec;
> qid_t qr;
>
> while(iterations){
> for(inti=0;i<2;i++){
> PL_put_integer(term_i,i);
> PL_cons_functor(term_f,funct1,term_a,term_b,term_i);
The scoping of these term references might be critical. You typically
need PL_open_foreign_frame() and PL_close/discard_foreign_frame() to
avoid resource leakage.
Can you make the entire program available somewhere?
Cheers --- Jan
> qr =PL_open_query(NULL,PL_Q_NORMAL,pred1,term_f);
> boolrec_defined =false;