From 9e347006d534fa8d280cb7759937a8e0685e63d6 Mon Sep 17 00:00:00 2001 From: Cameron Gutman Date: Mon, 27 Apr 2026 19:53:10 -0500 Subject: [PATCH] atomic: Fix infinite recursion in SDL_CompilerBarrier() fallback On some platforms, SDL_MemoryBarrierRelease() is defined to SDL_CompilerBarrier(). If SDL_CompilerBarrier() is also defined to the fallback spinlock acquire/release, then we will infinitely recurse in SDL_UnlockSpinlock(). Avoid this by not unlocking the temporary spinlock we create. (cherry picked from commit d07d39b0da9d2ef5568eff4749422259c54b7901) --- include/SDL_atomic.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/include/SDL_atomic.h b/include/SDL_atomic.h index b6def304a2..bc2644f4d6 100644 --- a/include/SDL_atomic.h +++ b/include/SDL_atomic.h @@ -148,8 +148,9 @@ void _ReadWriteBarrier(void); extern __inline void SDL_CompilerBarrier(void); #pragma aux SDL_CompilerBarrier = "" parm [] modify exact []; #else +/* We don't unlock here to avoid possible infinite recursion */ #define SDL_CompilerBarrier() \ -{ SDL_SpinLock _tmp = 0; SDL_AtomicLock(&_tmp); SDL_AtomicUnlock(&_tmp); } +{ SDL_SpinLock _tmp = 0; SDL_AtomicLock(&_tmp); } #endif /**