I can't use the standard library in my dynamic side module no matter what I do, MAIN_MODULE=1 freezes the game.

Abierto
#27,588 7 comentarios 0 reacciones 0 asignados Ver en GitHub

Los mantenedores suelen responder en 1 día

Nadie ha tomado este issue todavía.

Evaluación

Dificultad
5/5
Tiempo estimado
Más de una semana
Aptitud para principiantes
35/100
Tipo de issue
Error
Claridad
Necesita aclaración
Estado de actividad
Activo
Stack tecnológico
cpp, wasm

Línea de trabajo

Comienza reproduciendo el fallo del side module dinámico con el comando de enlace em++ proporcionado, MAIN_MODULE=2, SIDE_MODULE=2 y el error reportado de un símbolo de la biblioteca estándar. Compara ese resultado con MAIN_MODULE=1 y aísla un caso mínimo de enlace dinámico; se considerará terminado cuando se identifique un defecto reproducible de Emscripten o una limitación de configuración documentada.

Escrito por el modelo de indexación a partir del texto del issue.

Descripción

So in my game, I load code dynamically through shared objects. I look up symbols dynamically via function names defined in a JSON file. Then once I have a generic function pointer, I cast it to the correct function pointer.

I compile my game code using MAIN_MODULE=2 and the side modules using SIDE_MODULE=2 to reduce dead code. All my functions that are loaded by the main module dynamically through the dlopen family of functions explicitly kept alive C symbols.

Aborted(Assertion failed: undefined symbol '_ZNSt12length_errorD1Ev'. perhaps a side module was not linked in? if this global was expected to arrive from a system library, try to build the MAIN_MODULE with EMCC_FORCE_STDLIBS=1 in the environment) [Vivescence.js:2655:6](http://localhost:6931/Vivescence.js)
error loading dynamic library Data/DataPack/Module/VivescenceModule.wasm: RuntimeError: unreachable executed [Vivescence.js:8158:8](http://localhost:6931/Vivescence.js)
�[31m[Default Error] �[00m�[35mSource\Data\Module.cpp�[00m �[36mModule:16�[00m Condition �[33m!shared_object�[00m is true. �[33mFailed loading Data/DataPack/Module/VivescenceModule.wasm: could not load dynamic lib: Data/DataPack/Module/VivescenceModule.wa�[00m Executing statement �[32mreturn;�[00m [Vivescence.js:4567:12](http://localhost:6931/Vivescence.js)
�[31m[Default Error] �[00m�[35mSource\Data\Registry\ModuleRegistry.cpp�[00m �[36mregister_module:14�[00m Condition �[33m!module->is_valid()�[00m is true. Executing statement �[32mreturn;�[00m
Image

I did what it said and tried that env thing. It didn't fix anything. I tried removing std vector stuff. Then it complains about the function used for the new operator... which makes no sense because obviously I use the new operator in my main game.

Ok, so MAIN_MODULE=2 doesn't work because it can't find the symbols for standard library stuff. So I try with MAIN_MODULE=1 and it just does this forever.

Image

Freezes the entire tab and never starts the game.

Version of emscripten/emsdk:
emcc (Emscripten gcc/clang-like replacement + linker emulating GNU ld) 6.0.8 (aeb67926e7de656da38bc807d83050af93578758)
clang version 24.0.0git (https:/github.com/llvm/llvm-project 4bfd08c2d769736841ae4f5705d76fa6daa39027)

Failing command line in full:
If this is compile or link-time failure please include the full failing command
along with its entire output.

Full link command and output with -v appended:
Even for runtime issues it helps a lot if you can include the full link command.
Adding -v to the link command will show all of the sub-commands run which
can help us diagnose your issue.

C:\Users\firec\Files\vivescence>scons platform=web
scons: Reading SConscript files ...
TOOLS loaded: ['gcc', 'g++', 'gnulink', 'ar']
File created at: C:\Users\firec\Files\vivescence\Source\Generated\BuildInfo.gen.cpp
CCFLAGS: ['-s', 'USE_PTHREADS=1', '-fwasm-exceptions', '-sUSE_FREETYPE=1', '-sUSE_HARFBUZZ=1', '-fPIC']
CXXFLAGS:
LINKFLAGS: ['-s WASM=1', '-s', 'USE_PTHREADS=1', '-s', 'ALLOW_MEMORY_GROWTH=1', '-s', 'PTHREAD_POOL_SIZE=Math.min(Math.max(parseInt(navigator.hardwareConcurrency),4),32)', '-s', 'ENVIRONMENT=web', '-s', 'EXPORTED_FUNCTIONS=_main', '-s', 'EXPORTED_RUNTIME_METHODS=requestFullscreen,ccall,cwrap', '-sMIN_WEBGL_VERSION=2', '-sMAX_WEBGL_VERSION=2', '-sGL_ASSERTIONS=1', '-sFORCE_FILESYSTEM=1', '-sFETCH=1', '-sUSE_FREETYPE=1', '-sUSE_HARFBUZZ=1', '-sMAIN_MODULE=2', '-fPIC', '-lidbfs.js', '--preload-file', 'C:\\Users\\firec\\Files\\vivescence/Build/Data@Data', '-fwasm-exceptions', '-sSTACK_SIZE=262144', '--shell-file', 'C:\\Users\\firec\\Files\\vivescence\\EmscriptenShell.html', '-gsource-map', '-sASSERTIONS=2', '-lwebsocket.js']
TOOLS loaded: ['gcc', 'g++', 'gnulink', 'ar']
Platform: win32
MSVC flag: None
emcmake cmake -B C:\Users\firec\Files\vivescence\CMake\Build -G Ninja -DPLATFORM=web -DCMAKE_C_FLAGS="-s USE_PTHREADS=1 -fwasm-exceptions -sUSE_FREETYPE=1 -sUSE_HARFBUZZ=1 -fPIC" -DCMAKE_CXX_FLAGS="" -DCMAKE_BUILD_TYPE=Debug -DBUILD_SHARED_LIBS=OFF -DCMAKE_MSVC_RUNTIME_LIBRARY=MultiThreaded -G Ninja
emcmake: cmake -B 'C:\Users\firec\Files\vivescence\CMake\Build' -G Ninja -DPLATFORM=web '-DCMAKE_C_FLAGS=-s USE_PTHREADS=1 -fwasm-exceptions -sUSE_FREETYPE=1 -sUSE_HARFBUZZ=1 -fPIC' -DCMAKE_CXX_FLAGS= -DCMAKE_BUILD_TYPE=Debug -DBUILD_SHARED_LIBS=OFF -DCMAKE_MSVC_RUNTIME_LIBRARY=MultiThreaded -G Ninja '-DCMAKE_TOOLCHAIN_FILE=C:\Users\firec\Files\emsdk-main\upstream\emscripten\cmake\Modules\Platform\Emscripten.cmake' '-DCMAKE_CROSSCOMPILING_EMULATOR=C:\Users\firec\Files\emsdk-main/node/24.19.0_64bit/node.exe' in directory C:\Users\firec\Files\vivescence
-- -DPLATFORM=web;-DCMAKE_C_COMPILER=C:/Users/firec/Files/emsdk-main/upstream/emscripten/emcc.exe;-DCMAKE_CXX_COMPILER=C:/Users/firec/Files/emsdk-main/upstream/emscripten/em++.exe;-DCMAKE_C_FLAGS=-s USE_PTHREADS=1 -fwasm-exceptions -sUSE_FREETYPE=1 -sUSE_HARFBUZZ=1 -fPIC;-DCMAKE_CXX_FLAGS=;-DCMAKE_BUILD_TYPE=Debug;-DBUILD_SHARED_LIBS=OFF;-DCMAKE_MSVC_RUNTIME_LIBRARY=MultiThreaded;-DCMAKE_TOOLCHAIN_FILE=C:\Users\firec\Files\emsdk-main\upstream\emscripten\cmake\Modules\Platform\Emscripten.cmake;-DCMAKE_FIND_ROOT_PATH_MODE_PACKAGE=BOTH
-- Configuring done (0.6s)
-- Generating done (0.0s)
-- Build files have been written to: C:/Users/firec/Files/vivescence/CMake/Build
cmake --build C:\Users\firec\Files\vivescence\CMake\Build
ninja: no work to do.
scons: done reading SConscript files.
scons: Building targets ...
em++ -o Source\Generated\BuildInfo.gen.o -c -s USE_PTHREADS=1 -fwasm-exceptions -sUSE_FREETYPE=1 -sUSE_HARFBUZZ=1 -fPIC -DVIVESCENCE_DEBUG -DMBEDTLS_USER_CONFIG_FILE=\"MbedTLSConfig.hpp\" -DHALF_ENABLE_CPP11_CFENV=0 -DHALF_ENABLE_CPP11_USER_LITERALS=0 -DAS_MAX_PORTABILITY -DAS_USE_STLNAMES=1 -DSDL_STATIC -IExtern\Include -IExtern\FireCatMagic\Source -IExtern\FireCatMagic\Extern\Include -IExtern\FireCatMagic\Extern\angelscript\sdk\angelscript\include -IExtern\FireCatMagic\Extern\angelscript\sdk\add_on -IExtern\FireCatMagic\Extern\zstd\lib -ISource -IAPI -ICMake\Install\include -ICMake\Install\include\everest -ICMake\Install\include\mbedtls -ICMake\Install\include\psa -ICMake\Install\include\SDL3 -ICMake\Install\include\SDL3_mixer Source\Generated\BuildInfo.gen.cpp
em++ -o Build\Vivescence.html "-s WASM=1" -s USE_PTHREADS=1 -s ALLOW_MEMORY_GROWTH=1 -s PTHREAD_POOL_SIZE=Math.min(Math.max(parseInt(navigator.hardwareConcurrency),4),32) -s ENVIRONMENT=web -s EXPORTED_FUNCTIONS=_main -s EXPORTED_RUNTIME_METHODS=requestFullscreen,ccall,cwrap -sMIN_WEBGL_VERSION=2 -sMAX_WEBGL_VERSION=2 -sGL_ASSERTIONS=1 -sFORCE_FILESYSTEM=1 -sFETCH=1 -sUSE_FREETYPE=1 -sUSE_HARFBUZZ=1 -sMAIN_MODULE=2 -fPIC -lidbfs.js --preload-file C:\Users\firec\Files\vivescence/Build/Data@Data -fwasm-exceptions -sSTACK_SIZE=262144 --shell-file C:\Users\firec\Files\vivescence\EmscriptenShell.html -gsource-map -sASSERTIONS=2 -lwebsocket.js Source\Main.o Source\VivescenceMain.o Source\API\BlockBehavior.o Source\API\Registry.o Source\API\Variant.o Source\API\World.o Source\APIDefinitions\AudioGroup.o Source\APIDefinitions\HTTPRequest.o Source\Audio\AudioManager.o Source\Client\ClientSettings.o Source\Core\EntitySerialization.o Source\Core\Utility.o Source\Core\Input\InputManager.o Source\Core\Input\InputEvent\InputEvent.o Source\Core\Input\InputEvent\InputEventKey.o Source\Core\Input\InputEvent\InputEventMouseButton.o Source\Core\Input\InputEvent\InputEventMouseMotion.o Source\Core\Input\InputEvent\InputEventMouseWheel.o Source\Core\Input\InputMap\InputMap.o Source\Core\Input\InputReceiver\InputReceiver.o Source\Core\ProgramState\ProgramState.o Source\Core\ProgramState\ProgramStateLoading.o Source\Core\ProgramState\ProgramStateServerEditMenu.o Source\Core\ProgramState\ProgramStateTest.o Source\Core\ProgramState\ProgramStateTitleMenu.o Source\Core\ProgramState\ProgramStateWomb.o Source\Core\ProgramState\ProgramStateWorld.o Source\Core\ProgramState\ProgramStateWorldCreationMenu.o Source\Core\ProgramState\ProgramStateWorldEditMenu.o Source\Core\ProgramState\ProgramStateWorldSelectMenu.o Source\Core\Window\WindowV2.o Source\Core\World\ChunkData.o Source\Core\World\ChunkV2.o Source\Core\World\GenerateChunkData.o Source\Core\World\LightPropagationManager.o Source\Core\World\StorageGUIContext.o Source\Core\World\World.o Source\Core\World\WorldClient.o Source\Core\World\WorldGUIManager.o Source\Core\World\WorldProperties.o Source\Core\World\WorldServer.o Source\Core\World\ChunkSaveFormat\ChunkSaveFormat.o Source\Core\World\ChunkSaveFormat\ChunkSaveFormatV1.o Source\Core\World\ChunkSaveFormat\ChunkSaveFormatV2.o Source\Core\World\ECS\ApplyEntityLightSystem.o Source\Core\World\ECS\BleedSysten.o Source\Core\World\ECS\CameraSystem.o Source\Core\World\ECS\ChunkStatusSystem.o Source\Core\World\ECS\DecaySystem.o Source\Core\World\ECS\EntityChunkPartitioningSystem.o Source\Core\World\ECS\EntityControllerSystem.o Source\Core\World\ECS\EntityModelRendererManagerSystem.o Source\Core\World\ECS\FollowSystem.o Source\Core\World\ECS\GravitySystem.o Source\Core\World\ECS\HUDSystem.o Source\Core\World\ECS\InputStateSystem.o Source\Core\World\ECS\InteractionSystem.o Source\Core\World\ECS\NaturalSpawningSystem.o Source\Core\World\ECS\PhysicsSystem.o Source\Core\World\ECS\RegenerationSystem.o Source\Core\World\ECS\RenderHoveredBlockSystem.o Source\Core\World\ECS\RotationSystem.o Source\Core\World\ECS\SpeedSystem.o Source\Core\World\WorldSystem\CameraSystem.o Source\Core\World\WorldSystem\ChunkManagementSystem.o Source\Core\World\WorldSystem\EntityModelRendererManagementSystem.o Source\Core\World\WorldSystem\HUDSystem.o Source\Core\World\WorldSystem\InputStateSystem.o Source\Core\World\WorldSystem\InteractionSystem.o Source\Core\World\WorldSystem\PhysicsSystem.o Source\Core\World\WorldSystem\RenderFocusedBlockSystem.o Source\Data\Block.o Source\Data\BlockModelConfiguration.o Source\Data\BlockModelConfigurationInformation.o Source\Data\DataPackManager.o Source\Data\EntityModel.o Source\Data\EntityTemplate.o Source\Data\Font.o Source\Data\Module.o Source\Data\TextureAtlasV2.o Source\Data\TextureV2.o Source\Data\Registry\AudioGroupRegistry.o Source\Data\Registry\AudioRegistry.o Source\Data\Registry\BlockBehaviorRegistry.o Source\Data\Registry\BlockModelRegistry.o Source\Data\Registry\BlockRegistry.o Source\Data\Registry\EntityComponentRegistry.o Source\Data\Registry\EntityComponentRegistryOLD.o Source\Data\Registry\EntityTemplateRegistry.o Source\Data\Registry\GenomeRegistry.o Source\Data\Registry\ItemBehaviorRegistry.o Source\Data\Registry\ItemPropertyRegistry.o Source\Data\Registry\ItemRegistry.o Source\Data\Registry\ModuleRegistry.o Source\Data\Registry\NativeEntitySystemRegistry.o Source\Data\Registry\RecipeRegistry.o Source\Data\Registry\ServerServiceRegistry.o Source\Data\Registry\TextureRegistry.o Source\Data\Registry\TraitRegistry.o Source\Data\Registry\WorldGenerationStepRegistry.o Source\Data\Registry\WorldGeneratorRegistry.o Source\Data\Registry\WorldSystemRegistry.o Source\Debug\Debug.o Source\Generated\BuildInfo.gen.o Source\Packet\Client\AuthenticatePacket.o Source\Packet\Client\SetAimNormalPacket.o Source\Packet\Client\SetLocalPlayerEntityComponentDataPacket.o Source\Packet\Client\SetMovementInputNormalPacket.o Source\Packet\Client\SetPressedActionFlagsPacket.o Source\Packet\Client\SetSelectedHotbarIndexPacket.o Source\Packet\Client\TrySendMessagePacket.o Source\Packet\Server\AddEntityComponentPacket.o Source\Packet\Server\BlockDestroyedPacket.o Source\Packet\Server\BlockPlacedPacket.o Source\Packet\Server\CreateEntityPacket.o Source\Packet\Server\DestroyEntityPacket.o Source\Packet\Server\LoadChunkPacket.o Source\Packet\Server\RemoveEntityComponentPacket.o Source\Packet\Server\SendMessagePacket.o Source\Packet\Server\SetChunkBufferIndexPacket.o Source\Packet\Server\SetChunkBufferRegionPacket.o Source\Packet\Server\SetEntityComponentDataPacket.o Source\Packet\Server\SetRemoteEntityPacket.o Source\Packet\Server\SetWorldPropertyPacket.o Source\Packet\Server\UnloadChunkPacket.o Source\Rendering\RenderingContext.o Source\Rendering\WorldRenderingManager.o Source\Rendering\Camera\Camera.o Source\Rendering\Camera\ControlledCamera.o Source\Rendering\Image\Image.o Source\Rendering\OpenGL\GLEBO.o Source\Rendering\OpenGL\GLUBOManager.o Source\Rendering\OpenGL\GLVAO.o Source\Rendering\OpenGL\GLVBO.o Source\Rendering\OpenGL\RenderingContextOpenGL.o Source\Rendering\Renderer\Renderer.o Source\Rendering\Renderer\BlockModelRenderer\BlockModelRenderer.o Source\Rendering\Renderer\BlockModelRenderer\BlockModelRenderer2D.o Source\Rendering\Renderer\BlockModelRenderer\BlockModelRenderer3D.o Source\Rendering\Renderer\BlockModelRenderer\BlockModelRendererBase.o Source\Rendering\Renderer\BoxOutlineRenderer\BoxOutlineRenderer.o Source\Rendering\Renderer\ChunkRenderer\ChunkRenderer.o Source\Rendering\Renderer\CloudsRenderer\CloudsRenderer.o Source\Rendering\Renderer\EntityModelRenderer\EntityModelRenderer.o Source\Rendering\Renderer\ItemModelRenderer\ItemModelRenderer2D.o Source\Rendering\Renderer\ItemModelRenderer\ItemModelRenderer3D.o Source\Rendering\Renderer\RectangleRenderer\NinePatchRenderer2D.o Source\Rendering\Renderer\RectangleRenderer\RectangleRenderer2D.o Source\Rendering\Renderer\SkyRenderer\SkyRenderer.o Source\Rendering\Renderer\TextRenderer\TextRenderer2D.o Source\Rendering\Shader\Shader.o Source\Rendering\Shader\ShaderProgram.o Source\Rendering\Texture\GLTexture.o Source\Service\Ezcha\ClientServiceEzcha.o Source\Service\Ezcha\EzchaBase.o Source\Service\Ezcha\ServerServiceEzcha.o Source\Service\Generic\ClientServiceGeneric.o Source\Service\Generic\ServerServiceGeneric.o Source\Tests\Tests.o Extern\FireCatMagic\Extern\mbedtls\library\base64.o Extern\FireCatMagic\Extern\mbedtls\library\md5.o Extern\FireCatMagic\Extern\mbedtls\library\platform_util.o Extern\glad\gl.o Extern\tinyobjloader\tiny_obj_loader.o Extern\stb_image_write.o Extern\stb_rect_pack.o Build\libGUI.a -LCMake\Install\lib Extern\FireCatMagic\libfirecatmagic.a -lSDL3 -lSDL3_mixer -lopusfile -lopus -logg

I'm not sure what I am supposed to do at this point. I can't use MAIN_MODULE=1 because it just freezes the tab and I can't play my game. Can't use MAIN_MODULE=2 because it can't load the side modules because of missing symbols.

Lenguaje dominante
C++
Estrellas
27.8k
Forks
3.6k
Merge medio
1 d 3 h
PR fusionados (30 d)
179

Preparar el entorno

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Más de emscripten-core/emscripten

Todos los issues de emscripten-core/emscripten

Issues similares

Más issues de C++

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.