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

Seg fault in pygame._sdl2.Renderer.to_surface() when pygame._sdl2.Renderer.logical_size has been set #3028

Open
rethanon opened this issue Aug 2, 2024 · 0 comments
Labels
bug Not working as intended _sdl2 pygame._sdl2 segfault For PRs that fix segfaults or issues containing segfaults which have an higher priority

Comments

@rethanon
Copy link
Contributor

rethanon commented Aug 2, 2024

Environment:

Platform: Windows-11 OS build 22631.3958
System: Windows
System Version: 10.0.22631
Processor: AMD Ryzen9 5900X

Python: Python 3.12.2
pygame-ce version: 2.5.0
SDL versions: 2.30.3

Display Driver: windows

Current behaviour:

When using pygame._sdl2.Renderer.to_surface(), if the application window is fullscreen(desktop=True) and pygame._sdl2.Renderer.logical_size has been set., this results in a segmentation fault. If the application is windowed then the segmentation fault does not occur.

Expected behaviour:

Segmentation fault is not experienced and program continues normally.

Screenshots

image

Steps to reproduce:

  1. Create a window using pygame.Window()
  2. Create a renderer using pygame._sdl2.Renderer()
  3. Set a logical size for the renderer using pygame._sdl2.Renderer.logical_size()
  4. Set the window to fullscreen using desktop resolution using pygame.Window.set_fullscreen(desktop=True)
  5. Try to take a copy of the renderer and output to a surface using pygame._sdl2.Renderer.to_surface()

Test code

Use the 'Space' key to toggle between windowed and fullscreen. Use the 'R' key to perform the renderer copy to a surface.

import pygame
import pygame._sdl2 as sdl2

pygame.init()

WINDOW = pygame.Window("Test Window", (800, 600))
RENDERER = sdl2.Renderer(WINDOW)
RENDERER.draw_color = "blue"
RENDERER.logical_size = (800, 600)

fullscreen = False

running = True
while running:
    for event in pygame.event.get():
        if event.type == pygame.WINDOWCLOSE:
            running = False
        elif event.type == pygame.KEYDOWN:
            if event.key == pygame.K_ESCAPE:
                running = False
            elif event.key == pygame.K_r:
                new_surface = RENDERER.to_surface()
            elif event.key == pygame.K_SPACE:
                if fullscreen:
                    WINDOW.set_windowed()
                else:
                    WINDOW.set_fullscreen(desktop=True)
                fullscreen = not fullscreen

    RENDERER.clear()
    RENDERER.present()

Stack trace/error output/other error logs

Fatal Python error: pygame_parachute: (pygame parachute) Segmentation Fault
Python runtime state: initialized

Current thread 0x00007f20 (most recent call first):
  File "c:\Users\retha\Desktop\sdl2_seg_fault.py", line 22 in <module>

Extension modules: _wmi, pygame.base, pygame.constants, pygame.rect, pygame.rwobject, pygame.surflock, pygame.bufferproxy, pygame.math, pygame.surface, pygame.window, pygame.display, pygame.draw, pygame.joystick, pygame.event, pygame.imageext, pygame.image, pygame.key, pygame.mouse, pygame.time, pygame.mask, pygame.pixelcopy, pygame.transform, pygame.font, pygame.mixer_music, pygame.mixer, pygame.scrap, numpy.core._multiarray_umath, numpy.core._multiarray_tests, numpy.linalg._umath_linalg, numpy.fft._pocketfft_internal, numpy.random._common, numpy.random.bit_generator, numpy.random._bounded_integers, numpy.random._mt19937, numpy.random.mtrand, numpy.random._philox, numpy.random._pcg64, numpy.random._sfc64, numpy.random._generator, pygame.system, pygame._sdl2.sdl2, pygame._sdl2.audio, pygame._sdl2.video, pygame._freetype (total: 44)
@rethanon rethanon added the bug Not working as intended label Aug 2, 2024
@rethanon rethanon changed the title Seg fault in pygame._sdl2.Renderer.to_surface() Seg fault in pygame._sdl2.Renderer.to_surface() when pygame._sdl2.Renderer.logical_size has been set Aug 2, 2024
@damusss damusss added segfault For PRs that fix segfaults or issues containing segfaults which have an higher priority _sdl2 pygame._sdl2 labels Aug 3, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Not working as intended _sdl2 pygame._sdl2 segfault For PRs that fix segfaults or issues containing segfaults which have an higher priority
Projects
None yet
Development

No branches or pull requests

2 participants