LLVM Bugzilla is read-only and represents the historical archive of all LLVM issues filled before November 26, 2021. Use github to submit LLVM bugs

Bug 7689 - Crash handling bitcode
Summary: Crash handling bitcode
Status: RESOLVED FIXED
Alias: None
Product: libraries
Classification: Unclassified
Component: Core LLVM classes (show other bugs)
Version: trunk
Hardware: PC Linux
: P normal
Assignee: Unassigned LLVM Bugs
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2010-07-21 16:07 PDT by Rafael Ávila de Espíndola
Modified: 2010-08-26 16:59 PDT (History)
5 users (show)

See Also:
Fixed By Commit(s):


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Rafael Ávila de Espíndola 2010-07-21 16:07:40 PDT
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
Comment 1 Dan Gohman 2010-07-21 16:18:59 PDT
Could you update to r109036 and post the output on this testcase?
Comment 2 Rafael Ávila de Espíndola 2010-07-21 16:24:09 PDT
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!
Comment 3 Devang Patel 2010-07-22 11:36:17 PDT
Fixed in r109117.
Comment 4 Rafael Ávila de Espíndola 2010-07-22 12:48:43 PDT
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!
Comment 5 Rafael Ávila de Espíndola 2010-07-22 13:34:35 PDT
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.
Comment 6 Dan Gohman 2010-07-27 13:30:07 PDT
This is related to PR7700.
Comment 7 Dan Gohman 2010-08-24 15:27:07 PDT
Fixed in r111949 and related commits.
Comment 8 Guoliang Jin 2010-08-24 21:23:21 PDT
(In reply to comment #7)
> 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?
Comment 9 Dan Gohman 2010-08-25 10:19:44 PDT
(In reply to comment #8)
> @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?
Comment 10 Guoliang Jin 2010-08-25 11:50:46 PDT
(In reply to comment #9)
> (In reply to comment #8)
> > @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
Comment 11 Devang Patel 2010-08-25 12:16:11 PDT
Missing lto_codegen_set_cpu is a separate gold plugin issue. Please use new PR.
Comment 12 Guoliang Jin 2010-08-25 12:30:06 PDT
(In reply to comment #11)
> 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!
Comment 13 Dan Gohman 2010-08-25 16:52:25 PDT
It turns out there was another bug in bitcode linking. This is now fixed in r112091.  I updated lto.exports too.
Comment 14 Guoliang Jin 2010-08-25 18:06:51 PDT
(In reply to comment #13)
> 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.
Comment 15 Nick Lewycky 2010-08-26 00:38:40 PDT
Please file a new bug with an example of a bitcode file that produces a .o with broken debug info. Thanks!
Comment 16 Guoliang Jin 2010-08-26 16:59:03 PDT
(In reply to comment #15)
> 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.