Open ImNotMeAnymore opened 1 day ago
This will either segfault immediately at
ren = "huh?"
or it will (very rarely) continue but vomit a nasty Fatal Python error at the end of the script and then segfault
Seems like the crash happens when renderer object is collected by garbage, which might happen at different moments
import gc
from pygame import Window
from pygame._sdl2.video import Renderer
win = Window(size=(100,100))
ren = Renderer(win)
ren.logical_size = 10,10
ren.to_surface()
del win, ren
gc.collect() # Force garbage collection
print("Shouldn't be reached.")
Environment:
Current behavior: If you make a
pygame._sdl2.video.Renderer
object and change it's logical_size attribute, then make a surface out of it withRenderer.to_surface()
, on some occasions the program will either segfault immediately, or it will run as normal but once it reaches the end it exits with segfaultIt's somewhat inconsistent, not every logical_size value will cause the segfault, and some of those who do don't cause it every time, but there are values that appear to segfault every time
Expected behavior:
The program should continue as normal and not segfault under any of these circumstances
Test code All of these return something different every time they're run, so it's better to try them many times, saving or not the Surface in a variable doesn't seem to change the result
Not using it:
This will run as normal but once the script is done it segfaults,
logical_size
needs to be smaller than the window size but not every value causes it to act up, if it's bigger it will always work as intended apparentlyUsing a different value:
Notice how this is exactly the same as the first one but changing one of the 10's to 80 will make it segfault immediately on
ren.to_surface()
, having a 80 seems to segfault every time except when the other value is 1, in which case this happens: #3244There are other specific logical_size values that raise specific errors like (10,1) on a (90,2) sized window
Assigning other value to the Renderer object:
This will either segfault immediately at
ren = "huh?"
or it will (very rarely) continue but vomit a nasty Fatal Python error at the end of the script and then segfault (same error happens every time if you take the first example and set the window size to 90,2 and logical_size to 10,1)