Bug 496736

Summary: KWin X11 memory leak after exiting a program written with SDL
Product: [Plasma] kwin Reporter: emberqualia
Component: performanceAssignee: KWin default assignee <kwin-bugs-null>
Status: REPORTED ---    
Severity: crash CC: kdedev
Priority: NOR Keywords: X11-only
Version First Reported In: 6.2.4   
Target Milestone: ---   
Platform: Arch Linux   
OS: Linux   
Latest Commit: Version Fixed/Implemented In:
Sentry Crash Report:
Attachments: Minimal SDL2 example code

Description emberqualia 2024-11-27 03:47:54 UTC
Created attachment 176159 [details]
Minimal SDL2 example code

SUMMARY

Every time I close my program written in C++ with SDL, KWin (the KDE window manager) leaks memory, anywhere from 1 to 10 MB at a time. After about 1 GB has leaked, KWin starts to get unstable, and it crashes soon thereafter.

STEPS TO REPRODUCE

1. Run "g++ -lSDL2 sdl2.cpp" to compile the attached C++ code, which is a minimal SDL3 app
2. Run the compiled program and then close it

OBSERVED RESULT

KWin leaks memory, eventually to the point of a crash.

EXPECTED RESULT

It shouldn't leak memory.

SOFTWARE/OS VERSIONS

Operating System: Arch Linux 
KDE Plasma Version: 6.2.3
KDE Frameworks Version: 6.8.0
Qt Version: 6.8.0
Kernel Version: 6.12.1-zen1-1-zen (64-bit)
Graphics Platform: X11
Processors: 20 × 13th Gen Intel® Core™ i9-13900H
Memory: 31.0 GiB of RAM
Graphics Processor: Mesa Intel® Graphics

ADDITIONAL INFORMATION

This issue happens with both SDL2 and SDL3.

I often see the following error in the console after closing the program:

X Error of failed request:  BadWindow (invalid Window parameter)
  Major opcode of failed request:  40 (X_TranslateCoords)
  Resource id in failed request:  0x7e171fc
  Serial number of failed request:  560
  Current serial number in output stream:  560
Comment 1 TraceyC 2025-02-24 17:59:09 UTC
Adding the x11-only keyword