Skip to content

Commit d07d39b

Browse files
committed
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.
1 parent 3ebdcc5 commit d07d39b

1 file changed

Lines changed: 2 additions & 1 deletion

File tree

include/SDL_atomic.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -148,8 +148,9 @@ void _ReadWriteBarrier(void);
148148
extern __inline void SDL_CompilerBarrier(void);
149149
#pragma aux SDL_CompilerBarrier = "" parm [] modify exact [];
150150
#else
151+
/* We don't unlock here to avoid possible infinite recursion */
151152
#define SDL_CompilerBarrier() \
152-
{ SDL_SpinLock _tmp = 0; SDL_AtomicLock(&_tmp); SDL_AtomicUnlock(&_tmp); }
153+
{ SDL_SpinLock _tmp = 0; SDL_AtomicLock(&_tmp); }
153154
#endif
154155

155156
/**

0 commit comments

Comments
 (0)