Open llvmbot opened 4 years ago
I can now reproduce the error you are seeing by simply running:
$ wasm-ld RakNet.bc
However, since this is such a large wasm file its not easy to see how the malformed part of that file came to exist.
That file was linked, I believe, using wasm-ld -r -o RakNet.bc <list of object _file>
.
I believe there is a bug here in the implementation of wasm-ld -r
which combines object files into a single larger one.
I will try an make progress based on this single object file, but it would be useful to also have access to the inputs that were passed to wasm-ld to create RakNet.bc.
I have found a work around:
1) Compile all .cpp files to .o files 2) Bundle all .o files into an archive RakNet.a 3) Link the SockClient.o with RakNet.a to generate the wasm output
my wasm-ld reports the following: LLD 11.0.0 (Cswircachegitchromium.googlesource.com-external-github.com-llvm-llvm--project 613c4a87ba9bb39d1927402f4dd4c1ef1f9a02f7)
The RakNet I uploaded is: sha1sum RakNet.bc 57506f9aac3c9b76c482e606475fb62f4be4b11d *RakNet.bc (3,371 KB in size)
I stripped away all flags except the link step itself: wasm-ld.exe -o SocksClient.wasm RakNet.bc SocksClient.bc LLVM ERROR: malformed uleb128, extends past end PLEASE submit a bug report to https://bugs.llvm.org/ and include the crash backtrace. Stack dump:
Do I have the same/correct RekNet.bc files:
$ sha1sum RakNet.bc
21d36c8340b07292fba3ac829e185e198c35164f RakNet.bc
?
I'm using top of tree:
$ ../llvm-build/bin/wasm-ld -v
LLD 11.0.0 (https://github.com/llvm/llvm-project.git 8039d2c3bf14585ef37dc9343bf393ecad9aead9)
How about you? I can try with exact same version perhaps.
Can can you reduce the failing command line as much as you can? Perhaps remove all of the -L
and --export
arguments.. I believe they are not needed reproduce the crash. Perhaps the crash occurs with just wasm-ld RakNet.bc
.. can you try that?
what version of wasm-ld are you using?
I have moved the two files into their own directory to test and ran the command on them. I did it again by hand to verify. I am getting the same failure.
I'm afraid I still can't reproduce the crash using the command I posted earlier.. even after downloading the new file.
The previous RakNet.bc file was an input file for another part of the build step. I have uploaded the CORRECT RakNet.bc file on MEGA because it is > 3MB in size. Please see the new attachments.
Running wasm-ld by hand produces the same error I was getting before. You should see that now.
CORRECT RakNet.bc file This takes you to a MEGA download link for RakNet.bc since it is over 3MB in size
One this to try would be avoid combining your object files into larger ones. Those .bc
files you attached are the resulting combining smaller objects into a single object. As it happens they are not actually bitcode but wasm object files, which makes it a little confusing.
To combine object files that recommended method is to use emar cr libfoo.a <list of objects>
. The reason this might help is that using emcc to combine wasm object files is less well tested and I suspect that is where the bug lies.
Interesting. I can't seem to reproduce the problem.
I converting your failing command to run on my system and copied those two files over:
wasm-ld -o SocksClient.wasm RakNet.bc SocksClient.bc -L$EMSDK/upstream/emscripten/system/local/lib -L$EMSDK/upstream/emscripten/cache/wasm $EMSDK/upstream/emscripten/cache/wasm/libc-mt.a $EMSDK/upstream/emscripten/cache/wasm/libcompiler_rt.a $EMSDK/upstream/emscripten/cache/wasm/libc-wasm.a $EMSDK/upstream/emscripten/cache/wasm/libc++-mt-noexcept.a $EMSDK/upstream/emscripten/cache/wasm/libc++abi-mt-noexcept.a $EMSDK/upstream/emscripten/cache/wasm/libdlmalloc-mt.a $EMSDK/upstream/emscripten/cache/wasm/libpthread-mt.a $EMSDK/upstream/emscripten/cache/wasm/libc_rt_wasm.a $EMSDK/upstream/emscripten/cache/wasm/libsockets_proxy-mt.a -mllvm -combiner-global-alias-analysis=false -mllvm -enable-emscripten-sjlj -mllvm -disable-lsr --allow-undefined --import-memory --import-table --shared-memory --strip-debug --export main --export malloc --export free --export stackSave --export stackRestore --export stackAlloc --export __data_end --export __wasm_call_ctors --export fflush --export __errno_location --export emscripten_get_global_libc --export __pthread_tsd_run_dtors --export pthread_self --export __emscripten_pthread_data_constructor --export emscripten_futex_wake --export memalign --export proxy_main --export htonl --export htons --export ntohs -z stack-size=5242880 --initial-memory=16777216 --no-entry --max-memory=16777216 --global-base=1024
And it seems to work fine.
SocksClient.bc second and final input .bc file
I am generating them to .o files instead as some users on the github project said compiling them to object code solved some of their (unrelated) issues. The believed it was due to erroneous Link Time Optimizations.
I will generate .bc files instead and upload them. I have tested linking .bc files before and it still produced the same errors just fyi.
Unfortunately the -mllvm -debug stuff doesn't look like its available in the release build of wasm-ld that you have.
Can you somehow send those two bitcode files: Output/Raknet/RakNet.bc ./SocksClient.bc ?
the file is too big to upload (~29 MB). Here is a URL to a MEGA link with the dump: https://mega.nz/file/c7BxRChJ#dey9HlOrTMWtBofeo3FMsNgRBJyt5bbjexaeDIBUmo0
It has every step and output. I hope it helps.
You want me to reply with the entire build output with flags -Wl,-mllvm,-debug-only=lld
? It is long
Any chance you could provide reproduction steps?
Or at least maybe attach the bitcode inputs (Output/Raknet/RakNet.bc ./SocksClient.bc)?
If not perhaps you could run with -Wl,-mllvm,-debug-only=lld
which would tell us which object files contains the problem.
assigned to @sbc100
Extended Description
(note: I am on Windows 10 not NT)
At the final step in my build script, I cannot compile two files together which both have the same input flags. One is a custom port of RakNet and the other is a simple C++ program that uses it. Both compile by themselves but I cannot put them together to generate an HTML output.
LLVM ERROR: malformed uleb128, extends past end PLEASE submit a bug report to https://bugs.llvm.org/ and include the crash backtrace. Stack dump:
0 0x00007ff704a60fe6 (X:\Big_Code\emsdk\upstream\bin\wasm-ld.exe+0x30fe6)
1 0x00007ff9b3d8cb7d (C:\WINDOWS\System32\ucrtbase.dll+0x6cb7d)
2 0x00007ff9b3d8db81 (C:\WINDOWS\System32\ucrtbase.dll+0x6db81)
3 0x00007ff704a63972 (X:\Big_Code\emsdk\upstream\bin\wasm-ld.exe+0x33972)
4 0x00007ff704a63777 (X:\Big_Code\emsdk\upstream\bin\wasm-ld.exe+0x33777)
5 0x00007ff7064cf18c (X:\Big_Code\emsdk\upstream\bin\wasm-ld.exe+0x1a9f18c)
6 0x00007ff7064cb313 (X:\Big_Code\emsdk\upstream\bin\wasm-ld.exe+0x1a9b313)
7 0x00007ff7064cb07a (X:\Big_Code\emsdk\upstream\bin\wasm-ld.exe+0x1a9b07a)
8 0x00007ff7064caeff (X:\Big_Code\emsdk\upstream\bin\wasm-ld.exe+0x1a9aeff)
9 0x00007ff7064ca725 (X:\Big_Code\emsdk\upstream\bin\wasm-ld.exe+0x1a9a725)
10 0x00007ff7064f111a (X:\Big_Code\emsdk\upstream\bin\wasm-ld.exe+0x1ac111a)
11 0x00007ff7064f9447 (X:\Big_Code\emsdk\upstream\bin\wasm-ld.exe+0x1ac9447)
12 0x00007ff7064bb446 (X:\Big_Code\emsdk\upstream\bin\wasm-ld.exe+0x1a8b446)
13 0x00007ff704d46e89 (X:\Big_Code\emsdk\upstream\bin\wasm-ld.exe+0x316e89)
14 0x00007ff704d38f02 (X:\Big_Code\emsdk\upstream\bin\wasm-ld.exe+0x308f02)
15 0x00007ff704d36bea (X:\Big_Code\emsdk\upstream\bin\wasm-ld.exe+0x306bea)
16 0x00007ff704d33803 (X:\Big_Code\emsdk\upstream\bin\wasm-ld.exe+0x303803)
17 0x00007ff704a31746 (X:\Big_Code\emsdk\upstream\bin\wasm-ld.exe+0x1746)
18 0x00007ff706894f08 (X:\Big_Code\emsdk\upstream\bin\wasm-ld.exe+0x1e64f08)
19 0x00007ff9b58b7bd4 (C:\WINDOWS\System32\KERNEL32.DLL+0x17bd4)
20 0x00007ff9b636ce51 (C:\WINDOWS\SYSTEM32\ntdll.dll+0x6ce51)
emcc: error: 'X:/Big_Code/emsdk/upstream/bin\wasm-ld.exe -o C:\Users\Proto\AppData\Local\Temp\emscripten_temp_kzpnb07t\SocksClient.wasm Output/Raknet/RakNet.bc ./SocksClient.bc -LX:\Big_Code\emsdk\upstream\emscripten\system\local\lib -LX:\Big_Code\emsdk\upstream\emscripten\cache\wasm X:\Big_Code\emsdk\upstream\emscripten\cache\wasm\libc-mt.a X:\Big_Code\emsdk\upstream\emscripten\cache\wasm\libcompiler_rt.a X:\Big_Code\emsdk\upstream\emscripten\cache\wasm\libc-wasm.a X:\Big_Code\emsdk\upstream\emscripten\cache\wasm\libc++-mt-noexcept.a X:\Big_Code\emsdk\upstream\emscripten\cache\wasm\libc++abi-mt-noexcept.a X:\Big_Code\emsdk\upstream\emscripten\cache\wasm\libdlmalloc-mt.a X:\Big_Code\emsdk\upstream\emscripten\cache\wasm\libpthread-mt.a X:\Big_Code\emsdk\upstream\emscripten\cache\wasm\libc_rt_wasm.a X:\Big_Code\emsdk\upstream\emscripten\cache\wasm\libsockets_proxy-mt.a -mllvm -combiner-global-alias-analysis=false -mllvm -enable-emscripten-sjlj -mllvm -disable-lsr --allow-undefined --import-memory --import-table --shared-memory --strip-debug --export main --export malloc --export free --export stackSave --export stackRestore --export stackAlloc --export __data_end --export wasm_call_ctors --export fflush --export errno_location --export emscripten_get_global_libc --export pthread_tsd_run_dtors --export pthread_self --export emscripten_pthread_data_constructor --export emscripten_futex_wake --export memalign --export proxy_main --export htonl --export htons --export ntohs -z stack-size=5242880 --initial-memory=16777216 --no-entry --max-memory=16777216 --global-base=1024' failed (3221225501)