Skip to content
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

Crash handling bitcode #8061

Closed
llvmbot opened this issue Jul 21, 2010 · 16 comments
Closed

Crash handling bitcode #8061

llvmbot opened this issue Jul 21, 2010 · 16 comments
Labels
bugzilla Issues migrated from bugzilla llvm:core

Comments

@llvmbot
Copy link
Collaborator

llvmbot commented Jul 21, 2010

Bugzilla Link 7689
Resolution FIXED
Resolved on Aug 26, 2010 16:59
Version trunk
OS Linux
Reporter LLVM Bugzilla Contributor
CC @sunfishcode,@nlewycky

Extended Description

This shows up with the gold plugin, but I don't think it is gold specific:

$ cat test.ll
@​skel = global [1 x i8*] [i8* null]
!llvm.dbg.gv = !{#0}
!​0 = metadata !{i1 true, [1 x i8*]* @​skel}
$ llvm-as test.ll -o test.o
$ ld -plugin LLVMgold.so -o flex -shared -plugin-opt=emit-llvm test.o
Unknown constant!
UNREACHABLE executed at /usr/local/google/home/espindola/llvm/llvm/lib/Bitcode/Writer/BitcodeWriter.cpp:904!
Aborted

@sunfishcode
Copy link
Member

Could you update to r109036 and post the output on this testcase?

@llvmbot
Copy link
Collaborator Author

llvmbot commented Jul 21, 2010

Sure, the output is:

@​skel = global [1 x i8*] zeroinitializer ; <[1 x i8*]*> [#uses=0]

Unknown constant!
UNREACHABLE executed at /usr/local/google/home/espindola/llvm/llvm/lib/Bitcode/Writer/BitcodeWriter.cpp:903!

@llvmbot
Copy link
Collaborator Author

llvmbot commented Jul 22, 2010

Fixed in r109117.

@llvmbot
Copy link
Collaborator Author

llvmbot commented Jul 22, 2010

I still get the same failure:

@​skel = global [1 x i8*] zeroinitializer ; <[1 x i8*]*> [#uses=0]

Unknown constant!
UNREACHABLE executed at /usr/local/google/home/espindola/llvm/llvm/lib/Bitcode/Writer/BitcodeWriter.cpp:909!

@llvmbot
Copy link
Collaborator Author

llvmbot commented Jul 22, 2010

I program that should allow you to reproduce without gold:

#include <assert.h>
#include "llvm-c/lto.h"
int main(int argc, char *argv[]) {
lto_module_t M = lto_module_create(argv[1]);
assert (M);
unsigned sym_count = lto_module_get_num_symbols(M);

lto_code_gen_t cg = lto_codegen_create();
lto_codegen_add_module(cg, M);
lto_codegen_model output_type = LTO_CODEGEN_PIC_MODEL_STATIC;
lto_codegen_set_pic_model(cg, output_type);
lto_codegen_set_debug_model(cg, LTO_DEBUG_MODEL_DWARF);
bool err = lto_codegen_write_merged_modules(cg, "foo.bc");
return 0;
}

Just pass the test.bc file to it and lto_codegen_write_merged_modules will abort with the same error message.

@sunfishcode
Copy link
Member

This is related to llvm/llvm-bugzilla-archive#7700 .

@sunfishcode
Copy link
Member

Fixed in r111949 and related commits.

@llvmbot
Copy link
Collaborator Author

llvmbot commented Aug 25, 2010

Fixed in r111949 and related commits.

With those patches, the test case in the original description gave me these:

@​skel = global [1 x i8*] zeroinitializer ; <[1 x i8*]*> [#uses=0]

Unknown constant!
UNREACHABLE executed at /local.toadette/aliang/fixing/llvmsvn/llvm/lib/Bitcode/Writer/BitcodeWriter.cpp:909!
Aborted

Does anyone else see the same result?

@sunfishcode
Copy link
Member

@​skel = global [1 x i8*] zeroinitializer ; <[1 x i8*]*> [#uses=0]

Unknown constant!
UNREACHABLE executed at
/local.toadette/aliang/fixing/llvmsvn/llvm/lib/Bitcode/Writer/BitcodeWriter.cpp:909!

That UNREACHABLE is no longer at line 909 in BitcodeWriter.cpp on ToT; are your sources up to date?

@llvmbot
Copy link
Collaborator Author

llvmbot commented Aug 25, 2010

@​skel = global [1 x i8*] zeroinitializer ; <[1 x i8*]*> [#uses=0]

Unknown constant!
UNREACHABLE executed at
/local.toadette/aliang/fixing/llvmsvn/llvm/lib/Bitcode/Writer/BitcodeWriter.cpp:909!

That UNREACHABLE is no longer at line 909 in BitcodeWriter.cpp on ToT; are your
sources up to date?

This UNREACHABLE disappeared. Thanks. The reason is that I did not replace those old LLVMgold.so and libLTO.so.

But I got the following:
/local/llvm-gcc/lib/gcc/i686-pc-linux-gnu/4.2.1/../../../../i686-pc-linux-gnu/bin/ld: error: /local/llvm-gcc/libexec/gcc/i686-pc-linux-gnu/4.2.1/LLVMgold.so: could not load plugin library: /local/llvm-gcc/libexec/gcc/i686-pc-linux-gnu/4.2.1/LLVMgold.so: undefined symbol: lto_codegen_set_cpu

@llvmbot
Copy link
Collaborator Author

llvmbot commented Aug 25, 2010

Missing lto_codegen_set_cpu is a separate gold plugin issue. Please use new PR.

@llvmbot
Copy link
Collaborator Author

llvmbot commented Aug 25, 2010

Missing lto_codegen_set_cpu is a separate gold plugin issue. Please use new PR.

I fixed this by adding lto_codegen_set_cpu and lto_codegen_set_assembler_args to lto.exports

Then I still got the Unknown constant! by doing:
$ cat conftest.c
int
main ()
{
return 0;
}

$ llvm-gcc -use-gold-plugin -Wl,-plugin-opt=also-emit-llvm -O4 -g conftest.c
collect2: ld terminated with signal 6 [Aborted]

declare i32 @​main() nounwind readnone

Unknown constant!
UNREACHABLE executed at /local.toadette/aliang/fixing/llvmsvn/llvm/lib/Bitcode/Writer/BitcodeWriter.cpp:910!

@sunfishcode
Copy link
Member

It turns out there was another bug in bitcode linking. This is now fixed in r112091. I updated lto.exports too.

@llvmbot
Copy link
Collaborator Author

llvmbot commented Aug 26, 2010

It turns out there was another bug in bitcode linking. This is now fixed in
r112091. I updated lto.exports too.

I compiled httpd-2.2.9.tar.gz using the latest code. It compiles without problem, however, I got a lot of "BFD: Dwarf Error: Could not find abbrev number" when I do objdump.

It is configured with:
../configure --prefix=/local/install CFLAGS="-O4 -g" CC="llvm-gcc -use-gold-plugin -Wl,-plugin-opt=also-emit-llvm" CXX="llvm-g++ -use-gold-plugin -Wl,-plugin-opt=also-emit-llvm" RANLIB="/bin/true" --with-mpm=worker

then I make

then go to .libs and do
objdump -l -S httpd > httpd.S
and got:
"
BFD: Dwarf Error: Could not find abbrev number 116.
BFD: Dwarf Error: Could not find abbrev number 5864.
BFD: Dwarf Error: Could not find abbrev number 117.
BFD: Dwarf Error: Could not find abbrev number 110.
BFD: Dwarf Error: Could not find abbrev number 116.
BFD: Dwarf Error: Could not find abbrev number 116.
BFD: Dwarf Error: Could not find abbrev number 120.
BFD: Dwarf Error: Could not find abbrev number 116.
BFD: Dwarf Error: Could not find abbrev number 127.
BFD: Dwarf Error: Could not find abbrev number 127.
BFD: Dwarf Error: Could not find abbrev number 116.
BFD: Dwarf Error: Could not find abbrev number 116.
BFD: Dwarf Error: Could not find abbrev number 111.
BFD: Dwarf Error: Could not find abbrev number 267.
BFD: Dwarf Error: Could not find abbrev number 267.
BFD: Dwarf Error: Could not find abbrev number 5495.
BFD: Dwarf Error: Could not find abbrev number 12928.
...
...
"

I did get one httpd.S though.

@nlewycky
Copy link
Contributor

Please file a new bug with an example of a bitcode file that produces a .o with broken debug info. Thanks!

@llvmbot
Copy link
Collaborator Author

llvmbot commented Aug 26, 2010

Please file a new bug with an example of a bitcode file that produces a .o with
broken debug info. Thanks!

http://llvm.org/bugs/show_bug.cgi?id=8003

I haven't reduce it to a single bytecode file. Instead I uploaded a tarball of bytecode files that can be linked to get the final binary.

@llvmbot llvmbot transferred this issue from llvm/llvm-bugzilla-archive Dec 3, 2021
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bugzilla Issues migrated from bugzilla llvm:core
Projects
None yet
Development

No branches or pull requests

3 participants