Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

crash space add more then 40000 shapes #168

Open
zipandrar opened this issue Jul 10, 2019 · 4 comments
Open

crash space add more then 40000 shapes #168

zipandrar opened this issue Jul 10, 2019 · 4 comments

Comments

@zipandrar
Copy link

zipandrar commented Jul 10, 2019

this is a example source.py

crashTest.zip

#when the num is 30000 it work well
#when the num is more than 40000 or 100000, it will get crashed in the line space.add(body, shape)
#is it a bug or memeroy not enough??? but i think no one need more than 30000 bodies or shapes....

#i like pymunk.... ... in my test ,it is about 10x faster than pybox2d... ...

#faster and clear.... thanks to all of chipmunk's developers and thanks to all of pymunk's developers...

@viblo
Copy link
Owner

viblo commented Jul 10, 2019

Thanks for the report! Which version of pymunk, python and what OS do you use?
I tried myself and got crashes on CPython 2.7 32 and 64bit and CPython 3.7 on Windows, but on CPython 2.7 64bits on Ubuntu I cant get it to crash.

@zipandrar
Copy link
Author

win7_64bit
Cpython2.7.10_32bit
pymunk_5.3.2

hmmm.so it is a memory problem.... it very very enough with 30000 shapes too....

@viblo viblo reopened this Jul 11, 2019
@viblo
Copy link
Owner

viblo commented Jul 11, 2019

Lets keep this open a bit, just to keep track of it while I test a bit more.
It seems to only happen for static and kinematic bodies, not dynamic ones. And the exception happens inside the chipmunk library code, in the cpArrayContains function.

@viblo
Copy link
Owner

viblo commented Dec 21, 2022

An update to this: I did some more investigation of this old ticket, and it turns out that nowadays its stack overflow in the spatial tree that causes error. I have reported it to the Chipmunk issue tracker, but given how slow that project moves nowadays I dont expect a fix soon.

There is a workaround, use the spatial hash instead (space.use_spatial_hash(...)). Using this I could not get it to crash as easily.

If you or someone else has a proper use case which this crash prevents I can take another look, otherwise I think I wont try too hard to make a fix..

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants