Skip to content

Calling pygame.quit() and then Surface.get_bitsize() overflowing and segfaulting #3601

@ImNotMeAnymore

Description

@ImNotMeAnymore

Environment:

pygame-ce 2.5.5 (SDL 2.32.6, Python 3.13.1)
Platform:		Linux-6.1.0-38-amd64-x86_64-with-glibc2.36
System:			Linux
System Version:		#1 SMP PREEMPT_DYNAMIC Debian 6.1.147-1 (2025-08-02)
Processor:			SSE2: Yes	AVX2: Yes	NEON: No
Architecture:		Bits: 64bit	Linkage: ELF

Python:			CPython 3.13.1 (main, Mar 19 2025, 22:50:29) [GCC 12.2.0]
GIL Enabled:		True
pygame version:		2.5.5
SDL versions:		Linked: 2.32.6	Compiled: 2.32.6
SDL Mixer versions:	Linked: 2.8.1	Compiled: 2.8.1
SDL Font versions:	Linked: 2.24.0	Compiled: 2.24.0
SDL Image versions:	Linked: 2.8.8	Compiled: 2.8.8
Freetype versions:	Linked: 2.13.3	Compiled: 2.13.3

Display Driver:		x11 ( xwayland == False )
Mixer Driver:		Mixer Not Initialized

Current behavior:

If you create a window with the Window class, save it's surface, then close pygame, and after print the surface you'll see overflow garbage instead of it's real size or, if you're lucky, a friendly Fatal Python error: pygame_parachute: (pygame parachute) Segmentation Fault

Expected behavior:

Surf should become a <Surface(Dead Display)> or similar after pygame.close() has been called. At the very least it should not segfault.

Steps to reproduce:

  1. create a window, then get it's surface with window.get_surface()
  2. call pygame.quit()
  3. try to print the surface

Test code

import pygame

window = pygame.Window()

surf = window.get_surface()
pygame.quit()

print(surf.size) # sometimes size overflows too, but this never seems to segfault
print(surf.get_bitsize()) # overflow or segfault which means print(surf) also segfaults

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugNot working as intendedwindowpygame.Window

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions