Skip to content

"LLVM ERROR: LEB is outside Varint32 range" when dealing with large complex<double> array #24142

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
gtrrebel opened this issue Apr 17, 2025 · 0 comments

Comments

@gtrrebel
Copy link

I was working with https://ahti.space/git/shikhin/tjsm and run into an issue with big complex arrays. The steps I did to run into the issue:

cloned https://ahti.space/git/shikhin/tjsm
replaced main.cpp under src by the following simple c++ file: https://p.ahti.space/f8d37e.html
ran "emcmake cmake .." in a build directory (after sourcing emscripten)
ran "make" in a build directory.

It seems that something goes wrong when main.cpp contains a large complex array, of size between 2^27 and 2^28. For size 200000000 and some other sizes close to lower bound one obtains error:

"LLVM ERROR: LEB is outside Varint32 range"

while sizes close to upper bound one obtains similar error message but with

"LLVM ERROR: section size does not fit in a uint32_t" instead

For some values (size 2^28 - 1000 array for instance) instead:

"wasm-ld: error: lto.tmp: Function extends beyond buffer"

If the array size is smaller than 2^27, compilation seems to work fine, and for bigger than 2^28, the compiler notices that the array is too large.

Version of emscripten/emsdk:
emcc (Emscripten gcc/clang-like replacement + linker emulating GNU ld) 4.0.7 (8dc91db)
clang version 21.0.0git (https:/github.com/llvm/llvm-project 57025b42c43b2f14f7e58692bc19cd53d1b8a45e)
Target: wasm32-unknown-emscripten
Thread model: posix
InstalledDir: /Users/otteheinavaara/Desktop/emscripten/emsdk/upstream/bin

Failing command line in full: (This is the output from make)
[ 50%] Linking CXX executable ../public/wasm-main.js
LLVM ERROR: LEB is outside Varint32 range
PLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace.
Stack dump:
0. Program arguments: /Users/otteheinavaara/Desktop/emscripten/emsdk/upstream/bin/wasm-ld -o ../public/wasm-main.wasm -lembind-rtti CMakeFiles/wasm-main.dir/src/main.cpp.o -L/Users/otteheinavaara/Desktop/emscripten/emsdk/upstream/emscripten/cache/sysroot/lib/wasm32-emscripten/lto -L/Users/otteheinavaara/Desktop/emscripten/emsdk/upstream/emscripten/src/lib /Users/otteheinavaara/Desktop/emscripten/emsdk/upstream/emscripten/cache/sysroot/lib/wasm32-emscripten/lto/crtbegin.o -lGL-mt-getprocaddr -lal -lhtml5 -lstubs -lnoexit -lc-mt -ldlmalloc-mt -lcompiler_rt-mt -lc++-mt-noexcept -lc++abi-mt-noexcept -lsockets-mt -mllvm -combiner-global-alias-analysis=false -mllvm -enable-emscripten-sjlj -mllvm -disable-lsr /var/folders/l8/wr002pq55q9b2nmwzc51vtgm0000gn/T/tmpkkl81nnelibemscripten_js_symbols.so --import-memory --shared-memory --strip-debug -u__cxa_atexit --export=malloc --export=free --export=_emscripten_stack_alloc --export=__getTypeName --export=_emscripten_thread_free_data --export=_emscripten_thread_crashed --export=_embind_initialize_bindings --export=__wasm_call_ctors --export=_emscripten_tls_init --export=_emscripten_thread_init --export=emscripten_stack_get_current --export=_emscripten_stack_restore --export=emscripten_stack_set_limits --export=_emscripten_thread_exit --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 --export-if-defined=__main_argc_argv --export-table -z stack-size=65536 --no-growable-memory --initial-memory=52428800 --no-entry --table-base=1 --global-base=1024
#0 0x000000010f531678 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/Users/otteheinavaara/Desktop/emscripten/emsdk/upstream/bin/lld+0x10015b678)
#1 0x000000010f52edf5 llvm::sys::RunSignalHandlers() (/Users/otteheinavaara/Desktop/emscripten/emsdk/upstream/bin/lld+0x100158df5)
#2 0x000000010f532272 SignalHandler(int, __siginfo*, void*) (/Users/otteheinavaara/Desktop/emscripten/emsdk/upstream/bin/lld+0x10015c272)
#3 0x00007ff803587e1d (/usr/lib/system/libsystem_platform.dylib+0x7ff800482e1d)
#4 0x00007faf9770c270
#5 0x00007ff803471b19 (/usr/lib/system/libsystem_c.dylib+0x7ff80036cb19)
#6 0x000000010f49c364 llvm::report_fatal_error(llvm::Twine const&, bool) (/Users/otteheinavaara/Desktop/emscripten/emsdk/upstream/bin/lld+0x1000c6364)
#7 0x000000010f49c199 llvm::report_fatal_error(char const*, bool) (/Users/otteheinavaara/Desktop/emscripten/emsdk/upstream/bin/lld+0x1000c6199)
#8 0x0000000111dd0cb1 readVarint32(llvm::object::WasmObjectFile::ReadContext&) (/Users/otteheinavaara/Desktop/emscripten/emsdk/upstream/bin/lld+0x1029facb1)
#9 0x0000000111dd17bc readInitExpr(llvm::wasm::WasmInitExpr&, llvm::object::WasmObjectFile::ReadContext&) (/Users/otteheinavaara/Desktop/emscripten/emsdk/upstream/bin/lld+0x1029fb7bc)
#10 0x0000000111dc8ae6 llvm::object::WasmObjectFile::parseDataSection(llvm::object::WasmObjectFile::ReadContext&) (/Users/otteheinavaara/Desktop/emscripten/emsdk/upstream/bin/lld+0x1029f2ae6)
#11 0x0000000111dc3383 llvm::object::WasmObjectFile::parseSection(llvm::object::WasmSection&) (/Users/otteheinavaara/Desktop/emscripten/emsdk/upstream/bin/lld+0x1029ed383)
#12 0x0000000111dc2e78 llvm::object::WasmObjectFile::WasmObjectFile(llvm::MemoryBufferRef, llvm::Error&) (/Users/otteheinavaara/Desktop/emscripten/emsdk/upstream/bin/lld+0x1029ece78)
#13 0x0000000111dbacd5 llvm::object::ObjectFile::createObjectFile(llvm::MemoryBufferRef, llvm::file_magic, bool) (/Users/otteheinavaara/Desktop/emscripten/emsdk/upstream/bin/lld+0x1029e4cd5)
#14 0x0000000111dc08c5 llvm::object::SymbolicFile::createSymbolicFile(llvm::MemoryBufferRef, llvm::file_magic, llvm::LLVMContext*, bool) (/Users/otteheinavaara/Desktop/emscripten/emsdk/upstream/bin/lld+0x1029ea8c5)
#15 0x0000000111d2f2a5 llvm::object::createBinary(llvm::MemoryBufferRef, llvm::LLVMContext*, bool) (/Users/otteheinavaara/Desktop/emscripten/emsdk/upstream/bin/lld+0x1029592a5)
#16 0x000000010fa05d4a lld::wasm::WasmFileBase::WasmFileBase(lld::wasm::InputFile::Kind, llvm::MemoryBufferRef) (/Users/otteheinavaara/Desktop/emscripten/emsdk/upstream/bin/lld+0x10062fd4a)
#17 0x000000010fa13c55 lld::wasm::SymbolTable::compileBitcodeFiles() (/Users/otteheinavaara/Desktop/emscripten/emsdk/upstream/bin/lld+0x10063dc55)
#18 0x000000010f9fabbe lld::wasm::(anonymous namespace)::LinkerDriver::linkerMain(llvm::ArrayRef<char const*>) (/Users/otteheinavaara/Desktop/emscripten/emsdk/upstream/bin/lld+0x100624bbe)
#19 0x000000010f9f5049 lld::wasm::link(llvm::ArrayRef<char const*>, llvm::raw_ostream&, llvm::raw_ostream&, bool, bool) (/Users/otteheinavaara/Desktop/emscripten/emsdk/upstream/bin/lld+0x10061f049)
#20 0x000000010f5471bc lld::unsafeLldMain(llvm::ArrayRef<char const*>, llvm::raw_ostream&, llvm::raw_ostream&, llvm::ArrayReflld::DriverDef, bool) (/Users/otteheinavaara/Desktop/emscripten/emsdk/upstream/bin/lld+0x1001711bc)
#21 0x000000010f475582 lld_main(int, char**, llvm::ToolContext const&) (/Users/otteheinavaara/Desktop/emscripten/emsdk/upstream/bin/lld+0x10009f582)
#22 0x000000010f475f90 main (/Users/otteheinavaara/Desktop/emscripten/emsdk/upstream/bin/lld+0x10009ff90)
#23 0x00007ff8031c22cd
em++: error: '/Users/otteheinavaara/Desktop/emscripten/emsdk/upstream/bin/wasm-ld -o ../public/wasm-main.wasm -lembind-rtti CMakeFiles/wasm-main.dir/src/main.cpp.o -L/Users/otteheinavaara/Desktop/emscripten/emsdk/upstream/emscripten/cache/sysroot/lib/wasm32-emscripten/lto -L/Users/otteheinavaara/Desktop/emscripten/emsdk/upstream/emscripten/src/lib /Users/otteheinavaara/Desktop/emscripten/emsdk/upstream/emscripten/cache/sysroot/lib/wasm32-emscripten/lto/crtbegin.o -lGL-mt-getprocaddr -lal -lhtml5 -lstubs -lnoexit -lc-mt -ldlmalloc-mt -lcompiler_rt-mt -lc++-mt-noexcept -lc++abi-mt-noexcept -lsockets-mt -mllvm -combiner-global-alias-analysis=false -mllvm -enable-emscripten-sjlj -mllvm -disable-lsr /var/folders/l8/wr002pq55q9b2nmwzc51vtgm0000gn/T/tmpkkl81nnelibemscripten_js_symbols.so --import-memory --shared-memory --strip-debug -u__cxa_atexit --export=malloc --export=free --export=_emscripten_stack_alloc --export=__getTypeName --export=_emscripten_thread_free_data --export=_emscripten_thread_crashed --export=_embind_initialize_bindings --export=__wasm_call_ctors --export=_emscripten_tls_init --export=_emscripten_thread_init --export=emscripten_stack_get_current --export=_emscripten_stack_restore --export=emscripten_stack_set_limits --export=_emscripten_thread_exit --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 --export-if-defined=__main_argc_argv --export-table -z stack-size=65536 --no-growable-memory --initial-memory=52428800 --no-entry --table-base=1 --global-base=1024' failed (received SIGABRT (-6))
make[2]: *** [../public/wasm-main.js] Error 1
make[1]: *** [CMakeFiles/wasm-main.dir/all] Error 2
make: *** [all] Error 2

Note: Where possible, please avoid attaching screen shots of code or console
logs. Instead, please include them as text so that they may be copied /
searched. To make code blocks more readable and syntax highlighted, please
escape them with three backticks before and after, like this:

int x = 20;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant