libsdl-org / SDL

Simple Directmedia Layer
https://libsdl.org
zlib License
9.42k stars 1.75k forks source link

ios: infinite hang on SDL_malloc #10590

Open hsdk123 opened 3 weeks ago

hsdk123 commented 3 weeks ago

Hi, I'm trying to run a SDL2 application on ios, but I notice an infinite loop at https://github.com/libsdl-org/SDL/blob/SDL2/src/SDL_hints.c#L214

I've explicitly had to set

set(SDL_GCC_ATOMICS OFF CACHE BOOL "" FORCE)
set(SDL_ATOMIC_ENABLED_BY_DEFAULT OFF CACHE BOOL "" FORCE)

in my cmakelists due to sdl2 trying to pick up <atomic> and XCode complaining that it doesn't exist.

The infinite loop seems to explicitly occur here: https://github.com/libsdl-org/SDL/blob/SDL2/src/atomic/SDL_atomic.c#L241-L243

hsdk123 commented 3 weeks ago

I notice it eventually reaching https://github.com/libsdl-org/SDL/blob/SDL2/src/atomic/SDL_spinlock.c#L70

and notice the comment:

/* Terrible terrible damage */
hsdk123 commented 3 weeks ago

If I remove set(SDL_ATOMIC_ENABLED_BY_DEFAULT OFF CACHE BOOL "" FORCE), I get:

/Users/.../Desktop/SoulEngineProject/Light.vn-core/_deps/sdl/12d1a62d5935f195948fa324c17af1667ae86e59/src/atomic/SDL_spinlock.c:142:12: error:
      call to undeclared function 'OSAtomicCompareAndSwap32Barrier'; ISO C99 and
      later do not support implicit function declarations
      [-Wimplicit-function-declaration]
    return OSAtomicCompareAndSwap32Barrier(0, 1, lock);
           ^
1 error generated.