[Gc] Problems with interior pointers

Carsten Kehler Holst kehler at pdc.dk
Tue Jun 2 09:47:37 PDT 2009


Found the solution in a fix from February 2006.

Which only showed that our solution weren't updated the whole way to
6.8.

Hope no one wasted time on this one.

Regards

Carsten Kehler Holst

Prolog Development Center

 

From: gc-bounces at napali.hpl.hp.com [mailto:gc-bounces at napali.hpl.hp.com]
On Behalf Of Carsten Kehler Holst
Sent: 29. maj 2009 18:10
To: gc at napali.hpl.hp.com
Subject: [Gc] Problems with interior pointers

 

 

We are having a problem with interior pointers not holding on to a
structure.

It might be solved in the current version of the gc. If that is the case
we would be very thankful for a pointer in the right direction.

We are running a slightly modified version of 6.8.

 

 

The problem comes if you allocate a structure larger than 4096 and refer
to it with an interior pointer that points beyond position 1014 but
within 4096.

Such a structure are almost immediately reclaimed and the data thus
overwritten.

 

I have included a small visual-prolog predicate that illustrate the
problem below (I hope it is readable for non-prolog folks).

 

Any help is much appreciated.

 

Regards

Carsten Kehler Holst

Prolog Development Center.

 

class facts
    s : (string FirstChar, string Tail).

class predicates
    test : ().
clauses    
    test():-
        Char = randomChar(),
        NewS = string::create(2048, Char),  % has to be bigger than 2047
for it to fail
        string::front(NewS, 600, _HeadOfString, TailOfString), % has to
be smaller than 2048 for it to fail (and bigger than 507 !!!)
        assert(s(Char, TailOfString)), % save the interior pointer
TailOfString
        OverWritten = [s(C,S)||s(C,S), not(string::hasPrefix(S, C,_)),
retractall(s(C,S))], % find overwritten strings (not starting with the
Char that filled them)
        if OverWritten = [s(C1,S1)|_] then
            stdIO::write("failed : ", C1, " overwritten with ", S1,
"\n")
        end if,
        test().
    
class predicates
    randomChar : () -> string SingleCharString.
clauses
    randomChar() = list::nth(math::random(25),
["a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r"
,"s","t","u","v","w", "x","y","z"]).

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://napali.hpl.hp.com/pipermail/gc/attachments/20090602/6008e8f5/attachment-0001.htm


More information about the Gc mailing list