Quuxplusone / LLVMBugzillaTest

0 stars 0 forks source link

wasm-ld: crash when creating map file with Free Pascal generated object files #47941

Open Quuxplusone opened 3 years ago

Quuxplusone commented 3 years ago
Bugzilla Link PR48972
Status NEW
Importance P enhancement
Reported by Nikolay Nikolov (nickysn@gmail.com)
Reported on 2021-01-30 16:48:07 -0800
Last modified on 2021-02-11 01:18:16 -0800
Version unspecified
Hardware PC Linux
CC dschuff@google.com, llvm-bugs@lists.llvm.org, sbc@chromium.org
Fixed by commit(s)
Attachments linkmap-crash.tar.gz (201561 bytes, application/gzip)
Blocks
Blocked by
See also
Created attachment 24469
Object modules and linker script to reproduce the crash

Linker crashes, when asked to create a map file. It produces a working
WebAssembly binary when not creating a map file. The WebAssembly binary targets
the WASI platform and can be run using wasmtime.

Object modules being linked are produced by the llvm-mc assembler. Assembly
output that was previously fed to llvm-mc was generated by the Free Pascal
Compiler.

I have attached all the object modules and two linker scripts - one that
invokes the linker without map file (this one produces a working WebAssembly
binary), and one that tries to create a map file, which causes a crash. The
linker scripts are exactly as produced by the Free Pascal Compiler and use
absolute paths to the linker binary, which needs to be adjusted for your system.

I have included the source code for the Pascal program that was compiled
(hello.pas). This gives information of how a successful hello.wasm should
behave. It demonstrates that standard input and output are working and needs no
file access.

I have not included the assembler files, produced by the Free Pascal compiler,
but I can provide them as well, if that would help resolve the bug. They are
quite big. The assembly source for producing system.o alone is enough to reach
the 1 MB bugzilla attachment limit after gzipping.

The llvm-mc and wasm-ld linkers are compiled from the git main branch, commit
689de5841c1c4c9b0fe711b61d26f7425cf99423.

The crash looks like this:

Linking hello.wasm
PLEASE submit a bug report to https://bugs.llvm.org/ and include the crash
backtrace.
./link-linkmap.sh: line 10: 30785 Segmentation fault      (core dumped)
/home/nickysn/tralala/llvm/llvm-project/build-lld/bin/wasm-ld system.o hello.o
si_prc.o --gc-sections -Map hello.map -o hello.wasm --no-entry --strip-all
An error occurred while linking hello.wasm
Quuxplusone commented 3 years ago

Attached linkmap-crash.tar.gz (201561 bytes, application/gzip): Object modules and linker script to reproduce the crash

Quuxplusone commented 3 years ago

I wonder if this will be fixed by this change when it lands: https://reviews.llvm.org/D88369

Quuxplusone commented 3 years ago

Can this now be closed?

Quuxplusone commented 3 years ago

I rebuilt with git main, commit df1a17c219c073427f9d00eb042057bb3a4a3c64 and retested with the same files (attached to this bug report) and it is still crashing. :(