[chuck-users] Emptying two arrays with the same object causes "failed assertion `m_ref_count > 0'"

Stefan Blixt stefan.blixt at gmail.com
Sat May 22 07:39:33 EDT 2010


Here's some code:

-------------------------------------
class MyThing {
int x;
}
// Two identical arrays, typewise
MyThing arga[0];
MyThing argb[0];

// Create an instance
MyThing thing;
5 => thing.x;

// Push it into arga
arga << thing;
// Push it into argb
argb << thing;

<<< "n=", arga[0].x >>>;
<<< "n=", argb[0].x >>>;

// clear arga
0 => arga.size;
// clear argb - crash!
0 => argb.size;
-------------------------------------

when I run it I get:

-------------------------------------
$ chuck test.
ck
n= 5
n= 5
chuck_oo.cpp:120: failed assertion `m_ref_count > 0'
Abort trap
-------------------------------------

It seems that that 0 => arga.size decrements a reference count for thing,
causing it to be freed, and then when the same thing is attempted for argb,
it crashes. Possibly some reference increment missing when doing argb <<
thing ?

/Stefan

-- 
Release me, insect, or I will destroy the Cosmos!
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.cs.princeton.edu/pipermail/chuck-users/attachments/20100522/829527dc/attachment.htm>


More information about the chuck-users mailing list