-
Notifications
You must be signed in to change notification settings - Fork 189
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
Windows fatal exception: access violation - shapes.py line 65 #209
Comments
While running the code today i got a similar error with a more detailed stack trace. Looks like the problem is related to multiprocessing.
|
Do you call into Pymunk from multiple threads? Pymunk is not threadsafe, so if you call its methods from multiple threads it might break. |
Thanks for the reply and for developing this great library. I'm not sure what you mean by call into Pymunk but I'll give you a brief step-by-step summary of what the code does.
At no point do two threads interact with a single space. The processes are independent from each other. The code is on GitHub - https://github.com/OolongJunSun/Crawl-Eat-Die-Repeat |
I tried your code and managed to reproduce the error. To check the threading theory I rewrote the pool to use a for loop instead, but it seems like it can still happen, but maybe less often. More investigation needed. |
Really appreciate you going to the effort. I've found that reducing the number of pymunk objects causes less frequent crashes. When i first reported the problem i had Other than that I still can't nail down anything that causes the crash to be more or less likely to happen. |
What does |
It's not much but since we are generating 500 class instances simultaneously it can add up to 2500 more pymunk objects to the dictionary which is causing the error (line 42 of I'm hesitant to attribute the size of the dictionary to the error since it can still occur when we process smaller dictionaries, albeit less frequently. The size of the dictionary can be controlled by changing the |
Ah, it became a bit easier to validate different theories around this error when I could trigger the error more often with a higher n_genes.
|
Fantastic, thank you so much for the help. I'll add your modification and see if the error happens anymore. Will keep the issue open for another day but hopefully that fixes it. |
Error still occurring unfortunately. |
Following your example I've added some code to manually set all the
Would you recommend also setting all of the constraint objects to None? |
Error hasn't occurred since manually resetting objects in the dictionary as mentioned above. Looks like the issue was caused by freeing a large number of pymunk shapes from memory simultaneously. |
Ok, great that you found a workaround! I will still keep this issue open for a while, while I research it a bit more. |
Experiencing irregular python interpreter crashes. Crash happens 20-30% of the time that error producing line is executed. Code is using a multiprocessing pool, dont know if that is relevant but thought it might be worth mentioning.
Error found by using pythons in-built faulthandler module. Full traceback below:
Line 42 of my
population.py
script is resetting a dictionary containing a 500 class instances with variables made up of pymunk objects.OS: Windows 10
PY: Python 3.10.4
The text was updated successfully, but these errors were encountered: