Skip to content

Emscripten port SDL 2.24.0 SDL_THREADS_DISABLED stack error #6344

Closed
@ericoporto

Description

@ericoporto

Hey, I am trying to upgrade AGS to use Emscripten 3.1.23, and it also uses SDL 2.24.0. It doesn't even start for me, I am getting the following error stack, and it's all in SDL 2. It looks like a recursive error? I curiously don't use SDL_CreateSemaphore and revealing the missing frames it's all a loop started by it.

ags.js:36 Uncaught RangeError: Maximum call stack size exceeded
    at __memcpy (emscripten_memcpy.c:29:1)
    at __fwritex (fwrite.c:23:2)
    at out (vfprintf.c:179:27)
    at printf_core (vfprintf.c:513:10)
    at __vfprintf_internal (vfprintf.c:739:13)
    at vfprintf (vfprintf.c:756:9)
    at vsnprintf (vsnprintf.c:54:9)
    at SDL_vsnprintf (SDL_string.c:1407:12)
    at SDL_SetError (SDL_error.c:40:18)
    at SDL_CreateSemaphore (SDL_syssem.c:35:5)
$__memcpy	@	emscripten_memcpy.c:29
$__fwritex	@	fwrite.c:23
$out	@	vfprintf.c:179
$printf_core	@	vfprintf.c:513
$__vfprintf_internal	@	vfprintf.c:739
$vfprintf	@	vfprintf.c:756
$vsnprintf	@	vsnprintf.c:54
$SDL_vsnprintf	@	SDL_string.c:1407
$SDL_SetError	@	SDL_error.c:40
$SDL_CreateSemaphore	@	SDL_syssem.c:35
$SDL_CreateMutex	@	SDL_sysmutex.c:44
$SDL_LogMessageV	@	SDL_log.c:319
$SDL_LogDebug	@	SDL_log.c:227
$SDL_SetError	@	SDL_error.c:58
$SDL_CreateSemaphore	@	SDL_syssem.c:35
$SDL_CreateMutex	@	SDL_sysmutex.c:44
$SDL_LogMessageV	@	SDL_log.c:319
$SDL_LogDebug	@	SDL_log.c:227
$SDL_SetError	@	SDL_error.c:58
$SDL_CreateSemaphore	@	SDL_syssem.c:35
$SDL_CreateMutex	@	SDL_sysmutex.c:44
$SDL_LogMessageV	@	SDL_log.c:319
$SDL_LogDebug	@	SDL_log.c:227
$SDL_SetError	@	SDL_error.c:58
$SDL_CreateSemaphore	@	SDL_syssem.c:35
$SDL_CreateMutex	@	SDL_sysmutex.c:44
$SDL_LogMessageV	@	SDL_log.c:319
$SDL_LogDebug	@	SDL_log.c:227
$SDL_SetError	@	SDL_error.c:58
$SDL_CreateSemaphore	@	SDL_syssem.c:35
load (async)		
agsAttachFileInput	@	ags.html:295
onchange	@	ags.html:183
Show 170 more frames

I added a breakpoint there and this revealed that the cause was just the SDL_Init call we use.

image

My Emsdk flags used through CMake

CMAKE_CXX_FLAGS:   -sUSE_SDL=2  -sUSE_FREETYPE=1  -sUSE_VORBIS=1  -sUSE_OGG=1           -O2         -s DISABLE_EXCEPTION_CATCHING=0          -gsource-map -fsanitize=null -fsanitize-minimal-runtime
CMAKE_C_FLAGS:   -sUSE_SDL=2  -sUSE_FREETYPE=1  -sUSE_VORBIS=1  -sUSE_OGG=1           -O2         -s DISABLE_EXCEPTION_CATCHING=0          -gsource-map -fsanitize=null -fsanitize-minimal-runtime
CMAKE_EXE_LINKER_FLAGS:   -sUSE_SDL=2  -sUSE_FREETYPE=1  -sUSE_VORBIS=1  -sUSE_OGG=1          -s ALLOW_MEMORY_GROWTH=1          -s ASYNCIFY         -s ALLOW_TABLE_GROWTH=1         -s WASM=1         -s INVOKE_RUN=0              -s EXIT_RUNTIME=1               -s EMULATE_FUNCTION_POINTER_CASTS=1          -s FULL_ES2=1         -s FORCE_FILESYSTEM=1 -lidbfs.js          -s EXPORTED_FUNCTIONS=['_main']         -s EXTRA_EXPORTED_RUNTIME_METHODS=['ccall','callMain'] --emit-symbol-map --source-map-base http://127.0.0.1:8000/../  --shell-file C:/Users/user/launcher_index.html

The SDL2 I am using is built by emscripten own ports feature, built without threads.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions