llvm / llvm-project

The LLVM Project is a collection of modular and reusable compiler and toolchain technologies.
http://llvm.org
Other
29.44k stars 12.17k forks source link

LLVM ERROR: malformed uleb128, extends past end #46002

Open llvmbot opened 4 years ago

llvmbot commented 4 years ago
Bugzilla Link 46657
Version unspecified
OS Windows NT
Reporter LLVM Bugzilla Contributor
CC @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:

  1. Program arguments: 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

    ​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)

sbc100 commented 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.

llvmbot commented 4 years ago

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

llvmbot commented 4 years ago

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:

  1. Program arguments: X:\Big_Code\emsdk\upstream\bin\wasm-ld.exe -o SocksClient.wasm RakNet.bc SocksClient.bc

    ​0 0x00007ff6f3950fe6 (X:\Big_Code\emsdk\upstream\bin\wasm-ld.exe+0x30fe6)

    ​1 0x00007ffb5e11cb7d (C:\WINDOWS\System32\ucrtbase.dll+0x6cb7d)

    ​2 0x00007ffb5e11db81 (C:\WINDOWS\System32\ucrtbase.dll+0x6db81)

    ​3 0x00007ff6f3953972 (X:\Big_Code\emsdk\upstream\bin\wasm-ld.exe+0x33972)

    ​4 0x00007ff6f3953777 (X:\Big_Code\emsdk\upstream\bin\wasm-ld.exe+0x33777)

    ​5 0x00007ff6f53bf18c (X:\Big_Code\emsdk\upstream\bin\wasm-ld.exe+0x1a9f18c)

    ​6 0x00007ff6f53bb313 (X:\Big_Code\emsdk\upstream\bin\wasm-ld.exe+0x1a9b313)

    ​7 0x00007ff6f53bb07a (X:\Big_Code\emsdk\upstream\bin\wasm-ld.exe+0x1a9b07a)

    ​8 0x00007ff6f53baeff (X:\Big_Code\emsdk\upstream\bin\wasm-ld.exe+0x1a9aeff)

    ​9 0x00007ff6f53ba725 (X:\Big_Code\emsdk\upstream\bin\wasm-ld.exe+0x1a9a725)

    ​10 0x00007ff6f53e111a (X:\Big_Code\emsdk\upstream\bin\wasm-ld.exe+0x1ac111a)

    ​11 0x00007ff6f53e9447 (X:\Big_Code\emsdk\upstream\bin\wasm-ld.exe+0x1ac9447)

    ​12 0x00007ff6f53ab446 (X:\Big_Code\emsdk\upstream\bin\wasm-ld.exe+0x1a8b446)

    ​13 0x00007ff6f3c36e89 (X:\Big_Code\emsdk\upstream\bin\wasm-ld.exe+0x316e89)

    ​14 0x00007ff6f3c28f02 (X:\Big_Code\emsdk\upstream\bin\wasm-ld.exe+0x308f02)

    ​15 0x00007ff6f3c26bea (X:\Big_Code\emsdk\upstream\bin\wasm-ld.exe+0x306bea)

    ​16 0x00007ff6f3c23803 (X:\Big_Code\emsdk\upstream\bin\wasm-ld.exe+0x303803)

    ​17 0x00007ff6f3921746 (X:\Big_Code\emsdk\upstream\bin\wasm-ld.exe+0x1746)

    ​18 0x00007ff6f5784f08 (X:\Big_Code\emsdk\upstream\bin\wasm-ld.exe+0x1e64f08)

    ​19 0x00007ffb5f917bd4 (C:\WINDOWS\System32\KERNEL32.DLL+0x17bd4)

    ​20 0x00007ffb6106ce51 (C:\WINDOWS\SYSTEM32\ntdll.dll+0x6ce51)

sbc100 commented 4 years ago

Do I have the same/correct RekNet.bc files:

$ sha1sum RakNet.bc 
21d36c8340b07292fba3ac829e185e198c35164f  RakNet.bc

?

sbc100 commented 4 years ago

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?

llvmbot commented 4 years ago

what version of wasm-ld are you using?

llvmbot commented 4 years ago

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.

sbc100 commented 4 years ago

I'm afraid I still can't reproduce the crash using the command I posted earlier.. even after downloading the new file.

llvmbot commented 4 years ago

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.

llvmbot commented 4 years ago

CORRECT RakNet.bc file This takes you to a MEGA download link for RakNet.bc since it is over 3MB in size

sbc100 commented 4 years ago

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.

sbc100 commented 4 years ago

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.

llvmbot commented 4 years ago

SocksClient.bc second and final input .bc file

llvmbot commented 4 years ago

RakNet.bc First .bc files

llvmbot commented 4 years ago

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.

sbc100 commented 4 years ago

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 ?

llvmbot commented 4 years ago

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.

llvmbot commented 4 years ago

You want me to reply with the entire build output with flags -Wl,-mllvm,-debug-only=lld? It is long

sbc100 commented 4 years ago

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.

llvmbot commented 4 years ago

assigned to @sbc100