[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Fwd: possible memory leak in v1.4.5

From: Omer Brandis
Subject: Fwd: possible memory leak in v1.4.5
Date: Mon, 29 Jul 2019 19:58:38 +0300

1) I seem to have encountered a memory leak.

I'm new to prolog,Gnu prolog, thus I'm hoping its my error and if so, i'd appreciate some guidance.

I'm using gnu prolog v 1.4.5
I'm building a cpp to prolog wrapper (using gcc (Ubuntu 5.4.0-6ubuntu1~16.04.9) 5.4.0 ).
I'm trying to read a list of compounds. each compound is itself a compound
for example list = [ c1(Value1,c2(value2,c3(Value3,Value4),c3(Value5,Value6)),c2(Value7,c3(value8,Value9),c3(Value10,Value10))) ]
note that in some cases there are several occurrences of a compound/term  ( C1 has two instances of c2. c2 has 2 instances of c3)).

i've managed to :
a. execute a Pl_Query_Call to get the data
b. parse and iterate the list data (using Pl_List_Length and Pl_Rd_Proper_List)
c. unify with c1 using Pl_Un_Compound_Check ( and access value1)
d. unify with c2 using Pl_Un_Compound_Check ( ana access values 2,7).

e. but when i add the code for unification with c3 , i encounter the following error "Fatal Error: Segmentation Violation (bad address: 0x852)"
more specifically
unification with c3 works i access values 3 & 4 successfully, but then i get the segfault when the second unification attempt with c2 is attempted ( so i can't access value7).

parsing c1 for all c2 compounds is done in a loop,
the same code works when unification with c3 is not present/attempted .

( i perform Pl_Mk_Variable for each itme of the 3 parameter of Pl_Un_Compound_Check - inside the loop,
and i fear this is causing the problem. )

2) i have a question regarding memory deallocation done by Pl_end_query.
lets say for example that i have :

func1 ()
PlTerm ArgArray[1];
        ArgArray = Pl_Mk_Variable();




how can pl_end_query(PL_RECOVER) free the memory if its address was stored on the stack and is no longer available?

Please advise,
Omer Brandis.

reply via email to

[Prev in Thread] Current Thread [Next in Thread]