subtle bug - known?

Discuss any Chipmunk bugs here.
Post Reply
ideal57
Posts: 23
Joined: Fri Apr 03, 2009 4:36 pm
Contact:

subtle bug - known?

Post by ideal57 »

If I call

Code: Select all

cpSpaceHashEach(space->activeShapes, &funky, NULL);
and somewhere deep inside funky call

Code: Select all

    cpSpaceRemoveBody(space, shape->body);
    cpBodyFree(shape->body);
    
    cpSpaceRemoveShape(space, shape);
    cpShapeFree(shape);
In

Code: Select all

cpHashSetEach(cpHashSet *set, cpHashSetIterFunc func, void *data)
{
	for(int i=0; i<set->size; i++)
  {
		cpHashSetBin *bin;
    for(bin = set->table[i]; bin; bin = bin->next)
    {
      func(bin->elt, data); **************
    }
	}
}
If the deleted object is in the same bin as another, it crashes here, as the linked list has been changed out from under the loop. Maybe it needs documenting or I missed it somewhere...
User avatar
slembcke
Site Admin
Posts: 4166
Joined: Tue Aug 14, 2007 7:13 pm
Contact:

Re: subtle bug - known?

Post by slembcke »

Are you removing the shape in a collision callback? That has been a known limitation for years. The new documentation hasn't been kept up as well as I should have kept it though. It's entirely possible that I didn't mention it at all. :-\

This thread should give you some answers:
http://www.slembcke.net/forums/viewtopi ... 1982#p1982
Can't sleep... Chipmunks will eat me...
Check out our latest projects! -> http://howlingmoonsoftware.com/wordpress/
Post Reply

Who is online

Users browsing this forum: No registered users and 11 guests