Skip to content

wasm-ld crash on dynamic linking + debugging symbols #26044

@gl84

Description

@gl84

While trying to debug an error I encountered the following wasm-ld crash (stacktrace from 4.0.21-asserts):

wasm-ld: /b/s/w/ir/cache/builder/emscripten-releases/llvm-project/llvm/include/llvm/Support/Casting.h:572: decltype(auto) llvm::cast(From *) [To = lld::wasm::DefinedFunction, From = const lld::wasm::Symbol]: Assertion `isa<To>(Val) && "cast<Ty>() argument of incompatible type!"' failed.
wasm-ld: /b/s/w/ir/cache/builder/emscripten-releases/llvm-project/llvm/include/llvm/Support/Casting.h:572: decltype(auto) llvm::cast(From *) [To = lld::wasm::DefinedFunction, From = const lld::wasm::Symbol]: Assertion `isa<To>(Val) && "cast<Ty>() argument of incompatible type!"' failed.
PLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace and instructions to reproduce the bug.

It can be reproduced easily:

echo >main.cpp 'int main() {   return 0; }' && echo >side.cpp '#include <string>
#include <emscripten.h>
EMSCRIPTEN_KEEPALIVE void test_string_assignment(char* argv[]){
    std::string s;
    s = argv[0];
}
' && em++  -o side.so -sFAKE_DYLIBS=0  -shared  -sSIDE_MODULE=1 side.cpp && em++ -g  -O0 -sMAIN_MODULE=1  main.cpp  -o main.js       side.so

Compiling the main module without debugging symbols works as expected.

The crash happens in 4.0.21, 4.0.22 and tot.

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