Skip to content

Linker crash in Writer::run() #19774

Closed
Closed
@sergeyext

Description

@sergeyext

Initially I faced this problem with
libc.a(scalbnf.o): attempt to add bitcode file after LTO and added -Wl,-u,scalbnf to the linker command line as advised in that issue discussion. After that I got the linker crash. Probably the issue should go to llvm upstream because the crash handler says 'PLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/'.

Version of emscripten/emsdk:

emcc (Emscripten gcc/clang-like replacement + linker emulating GNU ld) 3.1.42 (6ede0b8fc1c979bb206148804bfb48b472ccc3da)
clang version 17.0.0 (https://github.com/llvm/llvm-project f3b64887de61020c09404bfee97b2fadd30df10a)
Target: wasm32-unknown-emscripten
Thread model: posix

Failing command line in full:

cd /path/to/project/client/cmake/cmake-build-web-new/PlayClient && /usr/local/bin/cmake -E cmake_link_script CMakeFiles/engine.dir/link.txt --verbose=1
/home/sergey/code/emsdk-new/upstream/emscripten/em++ -fwasm-exceptions -flto -fno-rtti -s USE_OGG=1 -s USE_VORBIS=1 -s USE_ZLIB=1 -Wno-invalid-utf8 -O2 -g -DNDEBUG -DuseAssertLevel1  -fwasm-exceptions -flto -s DEMANGLE_SUPPORT=1 -s USE_OGG=1 -s USE_VORBIS=1 -s USE_ZLIB=1 -s ABORTING_MALLOC=0 --js-library /path/to/project/client/cmake/../jsLibs/../../render/Drawer/Platform/Gl/WebglOesDrawBuffersIndexed.js -Wl,-u,scalbnf -s TOTAL_MEMORY=480MB -s NO_EXIT_RUNTIME=1 -s EXPORTED_FUNCTIONS="['_main', '_platformWork', '_mouseLeave', '_mouseReturn']" -s NO_FILESYSTEM=1 -s USE_GLFW=3 -s WASM=1 -s EXPORTED_RUNTIME_METHODS='["ccall", "cwrap"]' -s USE_FREETYPE=1 -s USE_ZLIB=1 -s USE_OGG=1 -s USE_VORBIS=1 -s MAX_WEBGL_VERSION=2 --js-library /path/to/project/client/cmake/../jsLibs/Render3D.js --js-library /path/to/project/client/cmake/../jsLibs/Helper.js --js-library /path/to/project/client/cmake/../../render/Content/Image/Parsing/WebHelper.js --js-library /path/to/project/client/cmake/../jsLibs/InputManager.js --js-library /path/to/project/client/cmake/../jsLibs/../../render/Drawer/Platform/Gl/WebglVersionSupport.js --pre-js /path/to/project/client/cmake/../jsLibs/pre.js @CMakeFiles/engine.dir/objects1.rsp -o engine.js @CMakeFiles/engine.dir/linklibs.rsp

It's output:

PLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace.
Stack dump:
0.      Program arguments: /home/sergey/code/emsdk-new/upstream/bin/wasm-ld @/tmp/emscripten__vfbaa6u.rsp.utf-8
 #0 0x0000560d038f0228 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/home/sergey/code/emsdk-new/upstream/bin/wasm-ld+0xef0228)
 #1 0x0000560d038edb4e llvm::sys::RunSignalHandlers() (/home/sergey/code/emsdk-new/upstream/bin/wasm-ld+0xeedb4e)
 #2 0x0000560d038f0e35 SignalHandler(int) Signals.cpp:0:0
 #3 0x00007f32471c88e0 __restore_rt (/lib64/libc.so.6+0x3d8e0)
 #4 0x0000560d03ce7e1e lld::wasm::(anonymous namespace)::Writer::run() Writer.cpp:0:0
 #5 0x0000560d03cdbf18 lld::wasm::writeResult() (/home/sergey/code/emsdk-new/upstream/bin/wasm-ld+0x12dbf18)
 #6 0x0000560d03cb49b2 lld::wasm::(anonymous namespace)::LinkerDriver::linkerMain(llvm::ArrayRef<char const*>) Driver.cpp:0:0
 #7 0x0000560d03cb0a20 lld::wasm::link(llvm::ArrayRef<char const*>, llvm::raw_ostream&, llvm::raw_ostream&, bool, bool) (/home/sergey/code/emsdk-new/upstream/bin/wasm-ld+0x12b0a20)
 #8 0x0000560d038f2c9f lld::unsafeLldMain(llvm::ArrayRef<char const*>, llvm::raw_ostream&, llvm::raw_ostream&, llvm::ArrayRef<lld::DriverDef>, bool) (/home/sergey/code/emsdk-new/upstream/bin/wasm-ld+0xef2c9f)
 #9 0x0000560d0383c472 lld_main(int, char**, llvm::ToolContext const&) (/home/sergey/code/emsdk-new/upstream/bin/wasm-ld+0xe3c472)
#10 0x0000560d0383cb2c main (/home/sergey/code/emsdk-new/upstream/bin/wasm-ld+0xe3cb2c)
#11 0x00007f32471b25b0 __libc_start_call_main (/lib64/libc.so.6+0x275b0)
#12 0x00007f32471b2679 __libc_start_main@GLIBC_2.2.5 (/lib64/libc.so.6+0x27679)
#13 0x0000560d037b69aa _start (/home/sergey/code/emsdk-new/upstream/bin/wasm-ld+0xdb69aa)
em++: error: '/home/sergey/code/emsdk-new/upstream/bin/wasm-ld @/tmp/emscripten__vfbaa6u.rsp.utf-8' failed (received SIGSEGV (-11))
make[2]: *** [PlayClient/CMakeFiles/engine.dir/build.make:10773: PlayClient/engine.js] Error 1
make[2]: leaving directory «/path/to/project/client/cmake/cmake-build-web-new»
make[1]: *** [CMakeFiles/Makefile2:369: PlayClient/CMakeFiles/engine.dir/all] Error 2
make[1]: leaving directory «/path/to/project/client/cmake/cmake-build-web-new»
make: *** [Makefile:103: all] Error 2

Full link command and output with -v appended:

cd /path/to/project/client/cmake/cmake-build-web-new/PlayClient && /usr/local/bin/cmake -E cmake_link_script CMakeFiles/engine.dir/link.txt --verbose=1
/home/sergey/code/emsdk-new/upstream/emscripten/em++ -fwasm-exceptions -flto -fno-rtti -s USE_OGG=1 -s USE_VORBIS=1 -s USE_ZLIB=1 -Wno-invalid-utf8 -O2 -g -DNDEBUG -DuseAssertLevel1  -fwasm-exceptions -flto -s DEMANGLE_SUPPORT=1 -s USE_OGG=1 -s USE_VORBIS=1 -s USE_ZLIB=1 -s ABORTING_MALLOC=0 --js-library /path/to/project/client/cmake/../jsLibs/../../render/Drawer/Platform/Gl/WebglOesDrawBuffersIndexed.js -Wl,-u,scalbnf -s TOTAL_MEMORY=480MB -s NO_EXIT_RUNTIME=1 -s EXPORTED_FUNCTIONS="['_main', '_platformWork', '_mouseLeave', '_mouseReturn']" -s NO_FILESYSTEM=1 -s USE_GLFW=3 -s WASM=1 -s EXPORTED_RUNTIME_METHODS='["ccall", "cwrap"]' -s USE_FREETYPE=1 -s USE_ZLIB=1 -s USE_OGG=1 -s USE_VORBIS=1 -s MAX_WEBGL_VERSION=2 --js-library /path/to/project/client/cmake/../jsLibs/Render3D.js --js-library /path/to/project/client/cmake/../jsLibs/Helper.js --js-library /path/to/project/client/cmake/../../render/Content/Image/Parsing/WebHelper.js --js-library /path/to/project/client/cmake/../jsLibs/InputManager.js --js-library /path/to/project/client/cmake/../jsLibs/../../render/Drawer/Platform/Gl/WebglVersionSupport.js --pre-js /path/to/project/client/cmake/../jsLibs/pre.js @CMakeFiles/engine.dir/objects1.rsp -o engine.js @CMakeFiles/engine.dir/linklibs.rsp -v

Output:

 "/home/sergey/code/emsdk-new/upstream/bin/clang" --version
 "/home/sergey/code/emsdk-new/upstream/bin/wasm-ld" @/tmp/emscripten_00aiz_j1.rsp.utf-8

the rest lines are as above starting with 'PLEASE submit a bug report....'

Contents of /tmp/emscripten_00aiz_j1.rsp.utf-8:

.... list of projects's object file paths ...
-L/home/sergey/code/emsdk-new/upstream/emscripten/cache/sysroot/lib/wasm32-emscripten/lto
/home/sergey/code/emsdk-new/upstream/emscripten/cache/sysroot/lib/wasm32-emscripten/lto/libfreetype-wasm-sjlj.a
/home/sergey/code/emsdk-new/upstream/emscripten/cache/sysroot/lib/wasm32-emscripten/lto/libvorbis.a
/home/sergey/code/emsdk-new/upstream/emscripten/cache/sysroot/lib/wasm32-emscripten/lto/libogg.a
/home/sergey/code/emsdk-new/upstream/emscripten/cache/sysroot/lib/wasm32-emscripten/lto/libz.a
--whole-archive
-lGL-webgl2
--no-whole-archive
-lal
-lhtml5
-lstubs
-lnoexit
-lc
-ldlmalloc
-lcompiler_rt-wasm-sjlj
-lc++-except
-lc++abi-except
-lunwind-except
-lsockets
-mllvm
-combiner-global-alias-analysis=false
-mllvm
-wasm-enable-sjlj
-mllvm
-disable-lsr
-mllvm
-wasm-enable-eh
-mllvm
-exception-model=wasm
/tmp/tmp7uaemuillibemscripten_js_symbols.so
--export-if-defined=main
--export-if-defined=platformWork
--export-if-defined=mouseLeave
--export-if-defined=mouseReturn
--export-if-defined=__start_em_asm
--export-if-defined=__stop_em_asm
--export-if-defined=__start_em_lib_deps
--export-if-defined=__stop_em_lib_deps
--export-if-defined=__start_em_js
--export-if-defined=__stop_em_js
--export-if-defined=__main_argc_argv
--export=__cxa_demangle
--export=free
--export=stackSave
--export=stackRestore
--export=stackAlloc
--export=__errno_location
--export=__get_temp_ret
--export=__set_temp_ret
--export=__trap
--export=__wasm_call_ctors
--export-table
-z
stack-size=65536
--initial-memory=503316480
--no-entry
--max-memory=503316480
--global-base=1024

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