slembcke/Chipmunk2D

Stackoverflow in SubtreeInsert when adding too many shapes to a space.

Opened this issue · 0 comments

viblo commented

When I add too many shapes to a space I get a stack overflow happening in SubtreeInsert in cpBBTree.c. Looks like its because SubtreeInsert which inserts items into the tree is recursive and the tree depth becomes to big.

When I test this on my Windows machine I can add between 10000 to 50000 shapes before it overflows. I am not sure if it has any practical usage to have that many shapes, but maybe a simple compromise would be to limit the amount of shapes in the tree structure with an assert instead of crashing with stack overflow?

A user of Pymunk reported this some time back in viblo/pymunk#168