You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
pygame-ce version: 2.4.0 (just installed from pip)
Relevant hardware: -
Current behavior:
This issue has appeared in both original pygame and in pygame-ce.
I have a game in which some cars navigate the environment with obstacles using sensor data and they collide quite frequently with each other and with obstacles. The problem is that sometimes during collisions the program crashes. It throws Fatal Python error: Segmentation fault but I'm 99% sure, that it's pygame. I use mask.overlap() function to detect collisions and when I remove parts that use this function, the program works perfectly fine. What's interesting but very confusing is that the trace points to the blit() function. Maybe I should also mention that I rotate the sprites using rotozoom() and create masks from rotated images.
Expected behavior:
Pixel-perfect sprite collisions using mask.overlap() without getting segmentation faults.
Steps to reproduce:
Create a number of moving sprites and check collisions between them using the mask.overlap() function.
Unfortunately, I cannot easily provide an adequate path to reproduce the issue as I am not sure what really causes it (except that it's part of pygame). If you are really interested, I can provide the repo with the code of my program, but it also uses ROS2 and some of its additional packages so you will be required to download them. Then the steps to reproduce are:
Launch the program
Use arrows to move and collide with objects
Try to collid with objects until it crashes
Stack trace/error output/other error logs
Fatal Python error: Segmentation fault
Current thread 0x00007f504d0a7740 (most recent call first):
File "/home/leev/workspaces/gr-kinematic-sim/install/gr_kinematic_sim/lib/python3.8/site-packages/gr_kinematic_sim/custom_utils/object_tools.py", line 71 in draw
File "/home/leev/workspaces/gr-kinematic-sim/install/gr_kinematic_sim/lib/python3.8/site-packages/gr_kinematic_sim/custom_utils/robots.py", line 103 in call_sensors
File "/home/leev/workspaces/gr-kinematic-sim/install/gr_kinematic_sim/lib/python3.8/site-packages/gr_kinematic_sim/custom_utils/robots.py", line 108 in draw
File "/home/leev/workspaces/gr-kinematic-sim/install/gr_kinematic_sim/lib/python3.8/site-packages/gr_kinematic_sim/custom_utils/gametools.py", line 141 in draw_every_sprite_in_list
File "/home/leev/workspaces/gr-kinematic-sim/install/gr_kinematic_sim/lib/python3.8/site-packages/gr_kinematic_sim/main.py", line 94 in main
File "/home/leev/workspaces/gr-kinematic-sim/install/gr_kinematic_sim/lib/gr_kinematic_sim/sim", line 11 in <module>
Fatal Python error: (pygame parachute) Segmentation Fault
Python runtime state: initialized
Current thread 0x00007f504d0a7740 (most recent call first):
File "/home/leev/workspaces/gr-kinematic-sim/install/gr_kinematic_sim/lib/python3.8/site-packages/gr_kinematic_sim/custom_utils/object_tools.py", line 71 in draw
File "/home/leev/workspaces/gr-kinematic-sim/install/gr_kinematic_sim/lib/python3.8/site-packages/gr_kinematic_sim/custom_utils/robots.py", line 103 in call_sensors
File "/home/leev/workspaces/gr-kinematic-sim/install/gr_kinematic_sim/lib/python3.8/site-packages/gr_kinematic_sim/custom_utils/robots.py", line 108 in draw
File "/home/leev/workspaces/gr-kinematic-sim/install/gr_kinematic_sim/lib/python3.8/site-packages/gr_kinematic_sim/custom_utils/gametools.py", line 141 in draw_every_sprite_in_list
File "/home/leev/workspaces/gr-kinematic-sim/install/gr_kinematic_sim/lib/python3.8/site-packages/gr_kinematic_sim/main.py", line 94 in main
File "/home/leev/workspaces/gr-kinematic-sim/install/gr_kinematic_sim/lib/gr_kinematic_sim/sim", line 11 in <module>
free(): invalid pointer
Without a reproducible script it's very hard to make any progress against a segfault. You mentioned a repo?
Your traceback has thread identifiers in it? Are you calling into pygame-ce from multiple threads? That's a dicey prospect, and could explain a segfault.
I will try to provide something but as for now I cannot give access to the repo. But I found out, that the segfault is caused by the linear_velocity variable I use that for some reason became nan. After adding nan to rect coordinates and trying to draw a sprite in that position it resulted in segfault. I don't know, why it happend, but checking it with math.isnan() solved the issue for me. So most probably it is my fault and not pygame's
I’m going to reopen this for now. Regardless of the cause, if it’s actually a segfault happening in pygame-ce, it should be fixed on our end. No input should be so broken that we segfault
Environment:
Current behavior:
This issue has appeared in both original pygame and in pygame-ce.
I have a game in which some cars navigate the environment with obstacles using sensor data and they collide quite frequently with each other and with obstacles. The problem is that sometimes during collisions the program crashes. It throws
Fatal Python error: Segmentation fault
but I'm 99% sure, that it's pygame. I usemask.overlap()
function to detect collisions and when I remove parts that use this function, the program works perfectly fine. What's interesting but very confusing is that the trace points to theblit()
function. Maybe I should also mention that I rotate the sprites usingrotozoom()
and create masks from rotated images.Expected behavior:
Pixel-perfect sprite collisions using
mask.overlap()
without getting segmentation faults.Steps to reproduce:
Create a number of moving sprites and check collisions between them using the
mask.overlap()
function.Unfortunately, I cannot easily provide an adequate path to reproduce the issue as I am not sure what really causes it (except that it's part of pygame). If you are really interested, I can provide the repo with the code of my program, but it also uses ROS2 and some of its additional packages so you will be required to download them. Then the steps to reproduce are:
Stack trace/error output/other error logs
The mentioned
draw()
function:The text was updated successfully, but these errors were encountered: