Access Violation with abolish
"Gustavo Brown - INCO" <[email protected]> Wed, 1 Jul 2015 17:05:30 -0300
| Newsgroups | gmane.comp.gnu.prolog.bugs |
|---|---|
| Message-ID | <4AECDEB74B144950873BBD2AA9A9B69C@VirtualXP99969> |
This is a multi-part message in MIME format.
--===============4854430536011641814==
Content-Type: multipart/alternative;
boundary="----=_NextPart_000_0732_01D0B420.22536BF0"
This is a multi-part message in MIME format.
------=_NextPart_000_0732_01D0B420.22536BF0
Content-Type: text/plain;
charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable
I am getting an access violation when trying to abolish some facts.
All the functions involved are from the file dynam_supp.c file (BipsPL)
Inspecting the code (dynam_supp.c) I think the problem is that there is =
a special marker (ALL_MUST_BE_ERASED) with value 2 that is used in =
Erase_All to mark that you want to erase all clauses(in member =
first_erased_cl).
However, when Clean_Erased_Clauses() is called it may be the case that =
the the first_erased_cl is also marked to keep (because it is still used =
in the local stack) leading to keep member first_erased_cl with =
ALL_MUST_BE_ERASED and not its previous value.
Now, if PlDelete_Dynamic_Clause is called (e.g. due to a retract), then =
member next_erased_cl might be copied with that special value =
ALL_MUST_BE_ERASED.
Then if Clean_Erased_Clauses() is called again and now this snippet =
fails
for (clause =3D dyn->first_erased_cl; clause; clause =3D clause1)
{
clause1 =3D clause->next_erased_cl;
size_of_erased -=3D clause->term_size;
Unlink_Clause(clause);
Free_Clause(clause);
}
because clause->next_erased_cl might hold ALL_MUST_BE_ERASED instead of =
NULL, which is the stopping condition of that for loop.
Using GNU Prolog 1.4.4
Regards,
Gustavo
------=_NextPart_000_0732_01D0B420.22536BF0
Content-Type: text/html;
charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META content=3D"text/html; charset=3Diso-8859-1" =
http-equiv=3DContent-Type>
<META name=3DGENERATOR content=3D"MSHTML 8.00.6001.23588">
<STYLE></STYLE>
</HEAD>
<BODY bgColor=3D#ffffff>
<DIV><FONT size=3D2 face=3DArial>I am getting an access violation when =
trying to=20
abolish some facts.</FONT></DIV>
<DIV><FONT size=3D2 face=3DArial>All the functions involved are from the =
file=20
dynam_supp.c file (BipsPL)</FONT></DIV>
<DIV><FONT size=3D2 face=3DArial></FONT> </DIV>
<DIV><FONT size=3D2 face=3DArial>Inspecting the code (dynam_supp.c) I =
think the=20
problem is that there is a special marker (ALL_MUST_BE_ERASED) with =
value 2 that=20
is used in Erase_All to mark that you want to erase all clauses(in =
member=20
first_erased_cl).</FONT></DIV>
<DIV><FONT size=3D2 face=3DArial>However, when Clean_Erased_Clauses() is =
called it=20
may be the case that the the first_erased_cl is also marked to keep =
(because it=20
is still used in the local stack) leading to keep member first_erased_cl =
with=20
ALL_MUST_BE_ERASED and not its previous value.</FONT></DIV>
<DIV><FONT size=3D2 face=3DArial></FONT> </DIV>
<DIV><FONT size=3D2 face=3DArial>Now, if PlDelete_Dynamic_Clause is =
called (e.g. due=20
to a retract), then member next_erased_cl might be copied with that =
special=20
value ALL_MUST_BE_ERASED.</FONT></DIV>
<DIV><FONT size=3D2 face=3DArial></FONT> </DIV>
<DIV><FONT size=3D2 face=3DArial>Then if Clean_Erased_Clauses() is =
called again and=20
now this snippet fails</FONT></DIV><FONT size=3D2 face=3DArial>for =
(clause =3D=20
dyn->first_erased_cl; clause; clause =3D =
clause1)<BR> {<BR> =20
clause1 =3D clause->next_erased_cl;<BR> size_of_erased =
-=3D=20
clause->term_size;<BR> =
Unlink_Clause(clause);<BR> =20
Free_Clause(clause);<BR> }</FONT>
<DIV><FONT size=3D2 face=3DArial></FONT> </DIV>
<DIV><FONT size=3D2 face=3DArial>because clause->next_erased_cl might =
hold=20
ALL_MUST_BE_ERASED instead of NULL, which is the stopping condition of =
that for=20
loop.</FONT></DIV>
<DIV><FONT size=3D2 face=3DArial></FONT> </DIV>
<DIV><FONT size=3D2 face=3DArial>Using GNU Prolog 1.4.4</FONT></DIV>
<DIV><FONT size=3D2 face=3DArial></FONT> </DIV>
<DIV><FONT size=3D2 face=3DArial>Regards,</FONT></DIV>
<DIV><FONT size=3D2 face=3DArial> =
Gustavo</FONT></DIV></BODY></HTML>
------=_NextPart_000_0732_01D0B420.22536BF0--
--===============4854430536011641814==
Content-Type: text/plain; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Content-Disposition: inline
_______________________________________________
Bug-prolog mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/bug-prolog
--===============4854430536011641814==--