Assertion breaks in llvm when -g is used. #13681

Closed
farcaller opened this Issue Apr 22, 2014 · 12 comments

Projects

None yet

6 participants

@farcaller
Contributor

On recent rust, compiling the code with -g fails with

Assertion failed: (Ty == resolve(Ty.getRef()) && "type was not uniqued, possible ODR violation."), function getOrCreateTypeDIE, file /Users/farcaller/temp/rust/src/llvm/lib/CodeGen/AsmPrinter/DwarfUnit.cpp, line 984.

Here's the backtrace:

* thread #2: tid = 0x3cc39f, 0x00007fff8bcba866 libsystem_kernel.dylib`__pthread_kill + 10, stop reason = signal SIGABRT
  * frame #0: 0x00007fff8bcba866 libsystem_kernel.dylib`__pthread_kill + 10
    frame #1: 0x00007fff8a9bd35c libsystem_pthread.dylib`pthread_kill + 92
    frame #2: 0x00000001026ff13b librustc-4283bb68-0.11-pre.dylib`raise(sig=6) + 27 at Signals.inc:368
    frame #3: 0x00000001026ff1f2 librustc-4283bb68-0.11-pre.dylib`abort + 18 at Signals.inc:385
    frame #4: 0x00000001026ff1d1 librustc-4283bb68-0.11-pre.dylib`__assert_rtn(func=0x0000000102a4c377, file=0x0000000102a4c1d9, line=984, expr=0x0000000102a4c3b8) + 129 at Signals.inc:381
    frame #5: 0x0000000101ad7dbf librustc-4283bb68-0.11-pre.dylib`llvm::DwarfUnit::getOrCreateTypeDIE(this=0x00000001087b7c20, TyNode=0x000000010650a120) + 303 at DwarfUnit.cpp:983
    frame #6: 0x0000000101adb0b9 librustc-4283bb68-0.11-pre.dylib`llvm::DwarfUnit::addType(this=0x00000001087b7c20, Entity=0x000000010a09a5e0, Ty=DIType at 0x0000000108308618, Attribute=DW_AT_type) + 233 at DwarfUnit.cpp:1053
    frame #7: 0x0000000101ad925d librustc-4283bb68-0.11-pre.dylib`llvm::DwarfUnit::constructTypeDIE(this=0x00000001087b7c20, Buffer=0x000000010a09a5e0, CTy=DICompositeType at 0x0000000108308898) + 461 at DwarfUnit.cpp:1229
    frame #8: 0x0000000101ad806b librustc-4283bb68-0.11-pre.dylib`llvm::DwarfUnit::getOrCreateTypeDIE(this=0x00000001087b7c20, TyNode=0x000000010653fbe0) + 987 at DwarfUnit.cpp:1011
    frame #9: 0x0000000101adb0b9 librustc-4283bb68-0.11-pre.dylib`llvm::DwarfUnit::addType(this=0x00000001087b7c20, Entity=0x000000010a09a4e0, Ty=DIType at 0x00000001083089f8, Attribute=DW_AT_type) + 233 at DwarfUnit.cpp:1053
    frame #10: 0x0000000101ad890e librustc-4283bb68-0.11-pre.dylib`llvm::DwarfUnit::getOrCreateSubprogramDIE(this=0x00000001087b7c20, SP=DISubprogram at 0x0000000108308c40) + 1502 at DwarfUnit.cpp:1507
    frame #11: 0x0000000101a8d258 librustc-4283bb68-0.11-pre.dylib`llvm::DwarfDebug::constructSubprogramDIE(this=0x0000000109804200, TheCU=0x00000001087b7c20, N=0x0000000106459a40) + 152 at DwarfDebug.cpp:767
    frame #12: 0x0000000101a89b48 librustc-4283bb68-0.11-pre.dylib`llvm::DwarfDebug::beginModule(this=0x0000000109804200) + 1400 at DwarfDebug.cpp:852
    frame #13: 0x0000000101a89510 librustc-4283bb68-0.11-pre.dylib`DwarfDebug(this=0x0000000109804200, A=0x00000001087d8c20, M=0x0000000108704a10) + 1776 at DwarfDebug.cpp:218
    frame #14: 0x0000000101a88e15 librustc-4283bb68-0.11-pre.dylib`DwarfDebug(this=0x0000000109804200, A=0x00000001087d8c20, M=0x0000000108704a10) + 37 at DwarfDebug.cpp:220
    frame #15: 0x0000000101a506f3 librustc-4283bb68-0.11-pre.dylib`llvm::AsmPrinter::doInitialization(this=0x00000001087d8c20, M=0x0000000108704a10) + 1811 at AsmPrinter.cpp:231
    frame #16: 0x000000010262a3c3 librustc-4283bb68-0.11-pre.dylib`llvm::FPPassManager::doInitialization(this=0x000000010a020170, M=0x0000000108704a10) + 99 at LegacyPassManager.cpp:1564
    frame #17: 0x000000010262ab78 librustc-4283bb68-0.11-pre.dylib`(anonymous namespace)::MPPassManager::runOnModule(this=0x000000010645f630, M=0x0000000108704a10) + 1000 at LegacyPassManager.cpp:1598
    frame #18: 0x000000010262a5ce librustc-4283bb68-0.11-pre.dylib`llvm::legacy::PassManagerImpl::run(this=0x00000001064949d0, M=0x0000000108704a10) + 302 at LegacyPassManager.cpp:1720
    frame #19: 0x000000010262b491 librustc-4283bb68-0.11-pre.dylib`llvm::legacy::PassManager::run(this=0x000000010a0925a0, M=0x0000000108704a10) + 33 at LegacyPassManager.cpp:1755
    frame #20: 0x00000001010aef80 librustc-4283bb68-0.11-pre.dylib`LLVMRustWriteOutputFile(Target=0x0000000109827600, PMR=0x000000010a0925a0, M=0x0000000108704a10, path=0x000000010a00c5b0, FileType=CGFT_ObjectFile) + 832 at PassWrapper.cpp:187
    frame #21: 0x0000000100e86d6f librustc-4283bb68-0.11-pre.dylib`back::link::WriteOutputFile::closure.83915 + 127
    frame #22: 0x000000010025f5b8 librustc-4283bb68-0.11-pre.dylib`c_str::CString::with_ref::h67bfc77600f111fdg0v::v0.11.pre + 152
    frame #23: 0x0000000100e86cb0 librustc-4283bb68-0.11-pre.dylib`c_str::ToCStr::with_c_str::h649f3d0125be42b1V9P::v0.11.pre + 112
    frame #24: 0x0000000100e86c25 librustc-4283bb68-0.11-pre.dylib`back::link::WriteOutputFile::h613b65c16e8d30bcUv1::v0.11.pre + 165
    frame #25: 0x0000000100e8cdd7 librustc-4283bb68-0.11-pre.dylib`back::link::write::run_passes::closure.83984 + 103
    frame #26: 0x0000000100e8c8fc librustc-4283bb68-0.11-pre.dylib`back::link::write::run_passes::with_codegen::hf1bba93ca8ea702anI1::v0.11.pre + 156
    frame #27: 0x0000000100e8ccd5 librustc-4283bb68-0.11-pre.dylib`back::link::write::run_passes::closure.83982 + 229
    frame #28: 0x00000001008e2715 librustc-4283bb68-0.11-pre.dylib`util::common::time::hd17fee6f98ebc873VZh::v0.11.pre + 101
    frame #29: 0x0000000100e88206 librustc-4283bb68-0.11-pre.dylib`back::link::write::run_passes::h7c53c9fff7a4a3569x1::v0.11.pre + 4918
    frame #30: 0x00000001010235e3 librustc-4283bb68-0.11-pre.dylib`driver::driver::phase_5_run_llvm_passes::closure.90380 + 147
    frame #31: 0x00000001008e2715 librustc-4283bb68-0.11-pre.dylib`util::common::time::hd17fee6f98ebc873VZh::v0.11.pre + 101
    frame #32: 0x00000001010234b8 librustc-4283bb68-0.11-pre.dylib`driver::driver::phase_5_run_llvm_passes::h992d8bb755f4d822yVf::v0.11.pre + 520
    frame #33: 0x0000000101028b93 librustc-4283bb68-0.11-pre.dylib`driver::driver::compile_input::h9c6393b1dbe53bc1xag::v0.11.pre + 3875
    frame #34: 0x0000000101077ea4 librustc-4283bb68-0.11-pre.dylib`run_compiler::hadccb7a29096a1ab4Gn::v0.11.pre + 8020
    frame #35: 0x00000001010a90d6 librustc-4283bb68-0.11-pre.dylib`main_args::closure.92321 + 86
    frame #36: 0x00000001010a466a librustc-4283bb68-0.11-pre.dylib`monitor::closure.92199 + 234
    frame #37: 0x00000001010967a4 librustc-4283bb68-0.11-pre.dylib`task::TaskBuilder::try::closure.91965 + 68
    frame #38: 0x000000010007e394 libnative-83574243-0.11-pre.dylib`task::spawn_opts::closure.7781 + 68
    frame #39: 0x0000000105d29a6c libstd-aad93cea-0.11-pre.dylib`unstable::finally::_$x7c$x7c.$x20$x27a$x20.$GT$$x20T.Finally$LT$T$GT$::finally::closure.40007 + 76
    frame #40: 0x0000000105d29949 libstd-aad93cea-0.11-pre.dylib`unstable::finally::try_finally::h7b5dce0c97463d98wMT::v0.11.pre + 89
    frame #41: 0x0000000105d298e2 libstd-aad93cea-0.11-pre.dylib`unstable::finally::_$x7c$x7c.$x20$x27a$x20.$GT$$x20T.Finally$LT$T$GT$::finally::he3252c2706ad38fecLT::v0.11.pre + 130
    frame #42: 0x0000000105d2984d libstd-aad93cea-0.11-pre.dylib`rt::task::Task::run::closure.40002 + 77
    frame #43: 0x0000000105d33b72 libstd-aad93cea-0.11-pre.dylib`rt::unwind::Unwinder::try::try_fn::__rust_abi + 98
    frame #44: 0x0000000105d33a32 libstd-aad93cea-0.11-pre.dylib`rt::unwind::Unwinder::try::try_fn::h1832ab126c831274z09::v0.11.pre + 66
    frame #45: 0x0000000105d419fc libstd-aad93cea-0.11-pre.dylib`rust_try + 12
    frame #46: 0x0000000105d2a378 libstd-aad93cea-0.11-pre.dylib`rt::unwind::Unwinder::try::h476c3fb682ff096aHY9::v0.11.pre + 120
    frame #47: 0x0000000105d296dc libstd-aad93cea-0.11-pre.dylib`rt::task::Task::run::h8de48cc50f018c3cS37::v0.11.pre + 220
    frame #48: 0x000000010007e155 libnative-83574243-0.11-pre.dylib`task::spawn_opts::closure.7753 + 485
    frame #49: 0x0000000105d308e3 libstd-aad93cea-0.11-pre.dylib`rt::thread::thread_start::__rust_abi + 99
    frame #50: 0x0000000105d30875 libstd-aad93cea-0.11-pre.dylib`rt::thread::thread_start::hc37897b3c1d0bcbfDI8::v0.11.pre + 21
    frame #51: 0x00007fff8a9bc899 libsystem_pthread.dylib`_pthread_body + 138
    frame #52: 0x00007fff8a9bc72a libsystem_pthread.dylib`_pthread_start + 137

Unfortunately, I cannot provide a small demo code to reproduce this (can reproduce only on the big project).

@jdm
Contributor
jdm commented Apr 22, 2014

A link to the bigger project would help. There's not much to go on here.

@jdm jdm added the A-debuginfo label Apr 22, 2014
@farcaller
Contributor

I just got the project approved so you can reproduce the bug now.

The code is at https://github.com/hackndev/zinc, uncomment -g line at support/rake.rb line 54 and build with

rake PLATFORM=lpc17xx APP=app_mbed_lcd
@farcaller
Contributor

A bit more context, it fails here:

DIE *DwarfUnit::getOrCreateTypeDIE(const MDNode *TyNode) {
  if (!TyNode)
    return NULL;

  DIType Ty(TyNode);
  assert(Ty.isType());
  assert(Ty == resolve(Ty.getRef()) &&
         "type was not uniqued, possible ODR violation.");

where Ty.getName() == (u8,&hal::lpc17xx::pin::reg::PINSEL), that is supposedly defined here.

@huonw
Member
huonw commented Apr 30, 2014
@sruggier

I just hit this today. Here's a minimal set of files that will trigger the issue. I used delta and a bit of massaging to strip all the flavor out of them:
https://gist.github.com/sruggier/79ea3c87ea843a52d716

@farcaller I found that both -g and -Z lto were required to repro this. If you need to debug your code, you can temporarily disable lto and hopefully your project will build.

@michaelwoerister
Contributor

Thanks for providing a small test case, @sruggier, that's very helpful!
I'll set aside some time to take a look at this tomorrow.

@michaelwoerister
Contributor

So, this is a problem with unique type ids not being so unique when bitcode from different crates gets mixed together, as is the case with link-time-optimization. I'll work on a fix over the next days.

@michaelwoerister michaelwoerister added a commit to michaelwoerister/rust that referenced this issue Jun 11, 2014
@michaelwoerister michaelwoerister debuginfo: Generate cross-crate unique type identifiers for debuginfo…
… types.

With this change, rustc creates a unique type identifier for types in debuginfo. These type identifiers are used by LLVM to correctly handle link-time-optimization scenarios but also help rustc with dealing with inlining from other crates. For more information, see the documentation block at the top of librustc/middle/trans/debuginfo.rs.

Fixes #13681.
94a63e6
@michaelwoerister michaelwoerister added a commit to michaelwoerister/rust that referenced this issue Jun 11, 2014
@michaelwoerister michaelwoerister debuginfo: Generate cross-crate unique type identifiers for debuginfo…
… types.

With this change, rustc creates a unique type identifier for types in debuginfo. These type identifiers are used by LLVM to correctly handle link-time-optimization scenarios but also help rustc with dealing with inlining from other crates. For more information, see the documentation block at the top of librustc/middle/trans/debuginfo.rs.

Fixes #13681.
26952dc
@michaelwoerister michaelwoerister added a commit to michaelwoerister/rust that referenced this issue Jun 11, 2014
@michaelwoerister michaelwoerister debuginfo: Generate cross-crate unique type identifiers for debuginfo…
… types.

With this change, rustc creates a unique type identifier for types in debuginfo. These type identifiers are used by LLVM to correctly handle link-time-optimization scenarios but also help rustc with dealing with inlining from other crates. For more information, see the documentation block at the top of librustc/middle/trans/debuginfo.rs.

Fixes #13681.
36828ca
@michaelwoerister michaelwoerister added a commit to michaelwoerister/rust that referenced this issue Jun 12, 2014
@michaelwoerister michaelwoerister debuginfo: Generate cross-crate unique type identifiers for debuginfo…
… types.

With this change, rustc creates a unique type identifier for types in debuginfo. These type identifiers are used by LLVM to correctly handle link-time-optimization scenarios but also help rustc with dealing with inlining from other crates. For more information, see the documentation block at the top of librustc/middle/trans/debuginfo.rs.

Fixes #13681.
3d6b406
@michaelwoerister michaelwoerister added a commit that closed this issue Jun 13, 2014
@michaelwoerister michaelwoerister debuginfo: Generate cross-crate unique type identifiers for debuginfo…
… types.

With this change, rustc creates a unique type identifier for types in debuginfo. These type identifiers are used by LLVM to correctly handle link-time-optimization scenarios but also help rustc with dealing with inlining from other crates. For more information, see the documentation block at the top of librustc/middle/trans/debuginfo.rs.

Fixes #13681.
0a98a4e
@farcaller
Contributor

And it's broken again:

Assertion failed: (ScopeDIE), function constructAbstractSubprogramScopeDIE, file /Users/rustbuild/src/rust-buildbot/slave/nightly-mac/build/src/llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp, line 534.
@farcaller farcaller added a commit to farcaller/zinc that referenced this issue Jun 16, 2014
@farcaller farcaller Reverting '-g' addition, it's kroken again (rust-lang/rust#13681).
This reverts commit 6f135b0.
37e7516
@farcaller farcaller added a commit to farcaller/zinc that referenced this issue Jun 16, 2014
@farcaller farcaller Reverting '-g' addition, it's broken again (rust-lang/rust#13681).
This reverts commit 6f135b0.
3114101
@michaelwoerister
Contributor

And it's broken again

This seems to be a different issue. Feel free to open a new bug, preferable with a title specific to the assertion happening :)

@farcaller
Contributor

Sure, opened #14930

@iopq
iopq commented Nov 8, 2015

I get Assertion failed: Ty == resolve(Ty->getRef()) && "type was not uniqued, possible ODR violation.", file C:\bot\slave\nightly-dist-rustc-win-msvc-64\build\src\llvm\lib\CodeGen\AsmPrinter\DwarfUnit.cpp, line 713 when trying to compile with debug and LTO at the same time

is this the same issue?

@jdm
Contributor
jdm commented Nov 8, 2015

@iopq It's been long enough that it's worth filing separately, I think.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment