subtle bug - known?

Discuss any Chipmunk bugs here.

subtle bug - known?

Postby ideal57 » Mon Apr 20, 2009 7:40 pm

If I call

Code: Select all
cpSpaceHashEach(space->activeShapes, &funky, NULL);

and somewhere deep inside funky call

Code: Select all
    cpSpaceRemoveBody(space, shape->body);
    cpSpaceRemoveShape(space, shape);


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...
Posts: 23
Joined: Fri Apr 03, 2009 4:36 pm

Re: subtle bug - known?

Postby slembcke » Mon Apr 20, 2009 11:07 pm

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:
Can't sleep... Chipmunks will eat me...
Check out our latest projects! ->
User avatar
Site Admin
Posts: 4164
Joined: Tue Aug 14, 2007 7:13 pm

Return to Bugs

Who is online

Users browsing this forum: No registered users and 1 guest