Skip to content

ResumeInst needs to be in a function with a personality #18

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

Closed
shepmaster opened this issue Sep 26, 2016 · 35 comments
Closed

ResumeInst needs to be in a function with a personality #18

shepmaster opened this issue Sep 26, 2016 · 35 comments

Comments

@shepmaster
Copy link
Member

Trying to update to avr-llvm/llvm@3c0d2ad, I've made some good progress and some nasty hacks, but now I'm stuck at this intriguing LLVM error

ResumeInst needs to be in a function with a personality.
  resume { i8*, i32 } %3
LLVM ERROR: Broken function found, compilation aborted!

Unfortunately, I have not been able to generate an LLVM IR dump of the invalid input before the failure occurs, and I can't get useful debugging symbols in LLVM or add debugging prints to the LLVM codebase. Frustrating!

@dylanmckay
Copy link
Member

Interesting, I'm not getting that.

I've been working off the branch you pushed before

https://github.com/avr-rust/rust/commits/avr-support-4.0

I am getting this error though:

Assertion failed: (isa<X>(Val) && "cast<Ty>() argument of incompatible type!"), function cast, file //Users//dylanmckay//projects//avr-rust//rust//src//llvm//include/llvm/Support/Casting.h, line 237.

@dylanmckay
Copy link
Member

Pretty sure we duplicated a bunch of stuff

@shepmaster
Copy link
Member Author

Pretty sure we duplicated a bunch of stuff

That wouldn't be too surprising, but I definitely hacked-and-slashed some stuff to get it working. There's a few places where I lost functionality. Do you have a branch of your in-progress changes? Maybe something will jump out at us if we compare the two.

@dylanmckay
Copy link
Member

The branch I linked before has my WIP stuff

@shepmaster
Copy link
Member Author

Oh, I didn't even notice it was in this repo ;-)

I do notice that you are building LLVM inside of the Rust directory; are you letting the Rust build process drive that? I've got LLVM built in a separate directory and am linking to it.

@dylanmckay
Copy link
Member

are you letting the Rust build process drive that?

Yeah I am

Other differences I can see:

  • You're using the beta bootstrap stuff instead of the configure script like myself
  • You've got a bunch more inlining-related stuff on your branch, whereas I've got your initial inlining stuff in my branch

@shepmaster
Copy link
Member Author

You're using the beta bootstrap stuff instead of the configure script like myself

Yeah, for a long time the configure script couldn't handle the CMake-based LLVM. That was addressed when they wanted to upgrade to 3.9 for Emscripten, but I'm still used to the way that I got working ;-)

a bunch more inlining-related stuff

I don't know that there's a bunch more, but I think I changed it from the initial commit because I got missing symbol errors, which might be fixed from your inclusion of the Objective-C library...

@dylanmckay
Copy link
Member

I'm merging our two branches, and will prune stuff and see if I can get a build working

@shepmaster
Copy link
Member Author

I'm merging our two branches

👍 I'll be off to bed shortly. I'll expect a magically working compiler in the morning 😈

@shepmaster
Copy link
Member Author

shepmaster commented Sep 26, 2016

Woo, my last hail-Mary effort worked. I guess something doesn't quite get rebuilt properly all the time, so my make clean helped:

; Function Attrs: inlinehint uwtable
define internal void @_ZN4core3mem6forget17h6a12bc5fd51e1250E(i64) unnamed_addr #2 !dbg !633 {
entry-block:
  %arg0 = alloca i64
  %t = alloca i64
  %personalityslot = alloca { i8*, i32 }
  store i64 %0, i64* %arg0
  call void @llvm.dbg.declare(metadata i64* %arg0, metadata !641, metadata !642), !dbg !643
  call void @llvm.dbg.declare(metadata i64* %t, metadata !644, metadata !642), !dbg !646
  br label %start

start:                                            ; preds = %entry-block
  %1 = load i64, i64* %arg0, !dbg !647
  store i64 %1, i64* %t, !dbg !647
  %2 = load i64, i64* %t, !dbg !648
  br label %bb2, !dbg !648

bb1:                                              ; No predecessors!
  %3 = load { i8*, i32 }, { i8*, i32 }* %personalityslot, !dbg !647
  resume { i8*, i32 } %3

bb2:                                              ; preds = %start
  ret void, !dbg !646
}

@dylanmckay
Copy link
Member

I've also gotten the ResumeInst error after merging the two branches. I'll try cleaning and rebuilding

@dylanmckay
Copy link
Member

I've rebuilt twice and am still getting that error, weird.

@dylanmckay
Copy link
Member

dylanmckay commented Sep 26, 2016

Looks like others have had this bug before too

https://botbot.me/mozilla/rust-internals/2016-08-11/?msg=71118645&page=1

That must mean that it's unrelated to our changes, and is an incompatibility between LLVM 4.0 and 3.9

nagisa suggests that it's likely to be an ABI incompatibility that's causing it.

@shepmaster
Copy link
Member Author

I've got a very hacky reproduction:

#![feature(lang_items)]
#![feature(start)]
#![feature(intrinsics)]
#![feature(no_core)]
#![feature(on_unimplemented)]
#![feature(fundamental)]

#![no_std]
#![no_core]

#[start]
fn start(_argc: isize, _argv: *const *const u8) -> isize {
    forget(42);
    0
}

#[lang = "eh_personality"]
extern fn eh_personality() {}

#[lang = "panic_fmt"]
extern fn panic_fmt() -> ! { loop {} }

mod intrinsics {
    extern "rust-intrinsic" {
        pub fn forget<T>(_: T) -> ();
    }
}

#[inline]
pub fn forget<T>(t: T) {
    unsafe { intrinsics::forget(t) }
}

#[lang = "sized"]
#[rustc_on_unimplemented = "`{Self}` does not have a constant size known at compile-time"]
#[fundamental]
pub trait Sized {}

#[lang = "copy"]
pub trait Copy {}

And this is how I reproduce

RUSTC="/Users/shep/Projects/avr-rust/debug/build/bootstrap/debug/rustc" \
RUSTC_BOOTSTRAP_KEY="836a4172" \
RUSTC_LIBDIR="/Users/shep/Projects/avr-rust/debug/build/x86_64-apple-darwin/stage1/lib" \
RUSTC_REAL="/Users/shep/Projects/avr-rust/debug/build/x86_64-apple-darwin/stage1/bin/rustc" \
RUSTC_SNAPSHOT="/Users/shep/Projects/avr-rust/debug/build/x86_64-apple-darwin/stage0/bin/rustc" \
RUSTC_SNAPSHOT_LIBDIR="/Users/shep/Projects/avr-rust/debug/build/x86_64-apple-darwin/stage0/lib" \
RUSTC_STAGE="1" \
RUSTC_SYSROOT="/Users/shep/Projects/avr-rust/debug/build/x86_64-apple-darwin/stage1" \
/Users/shep/Projects/avr-rust/debug/build/bootstrap/debug/rustc \
/tmp/repro.rs \
--crate-type lib \
--emit=link \
--target x86_64-apple-darwin

Really, I'm running that process in LLDB, but it forks the real compiler, so I need to do something like:

# LLDB #1
(lldb) env ...env...
(lldb) b fork
(lldb) r ...args...
# LLDB #2
(lldb) attach -w -n rustc
# LLDB #1
(lldb) c
# LLDB #2
(lldb) br set -r '.*personality.*'
(lldb) br set -r '.*Personality.*'
(lldb) c

Doing this, I break at the following frames:

rustc::middle::lang_items::{{impl}}::eh_personality at lang_items.rs:136
rustc_trans::mir::block::{{impl}}::get_personality_slot at block.rs:758
rustc_trans::mir::block::{{impl}}::get_personality_slot::{{closure}} at block.rs:764
llvm::Function::hasPersonalityFn() const
llvm::Function::hasPersonalityFn() const
llvm::Function::hasPersonalityFn() const
llvm::Function::hasPersonalityFn() const
llvm::Function::hasPersonalityFn() const
llvm::Function::hasPersonalityFn() const
llvm::Function::hasPersonalityFn() const
llvm::Function::hasPersonalityFn() const

So it currently looks like we are indeed not setting the personality on the function.

@dylanmckay
Copy link
Member

Sounds like an upstream Rust bug, perhaps we should raise it there?

@shepmaster
Copy link
Member Author

Perhaps. I'm never quite sure how upstream wants to treat LLVM upgrades that they don't need directly. I suppose I could open an issue there later today with the appropriate information. In the worst case, they can close it.

@dylanmckay
Copy link
Member

@shepmaster: Does this occur when disabling MIR and using the old backend?

@shepmaster
Copy link
Member Author

I'm... not sure how to disable MIR anymore... I'm looking, but maybe you recall?

@shepmaster
Copy link
Member Author

Maybe it was permanently enabled? cb9b0ed

@dylanmckay
Copy link
Member

Looks like you're right, that's tricky. I do think it's weird that the only things being done in the IR you posted before:

  • Loading
  • Storing
  • Branching within the function
  • Calling llvm.dbg.declare to declare debug information

I don't think any of this would trigger exceptions, it does literally nothing (as per the definition of drop). The bug could be that we shouldn't even have resume

  call void @llvm.dbg.declare(metadata i64* %arg0, metadata !641, metadata !642), !dbg !643
  call void @llvm.dbg.declare(metadata i64* %t, metadata !644, metadata !642), !dbg !646

@dylanmckay
Copy link
Member

The IR validator for 'ResumeInst must be in a function with a personality' was introduced in LLVM commit r277360.

We could always quick-fix this by reverting the commit on our fork of LLVM.

@dylanmckay
Copy link
Member

I think I may have fixed the bug, will keep this updated.

@dylanmckay
Copy link
Member

I've opened #20, although it currently causes a segfault.

@dylanmckay
Copy link
Member

I'm pretty happy to revert out the verifier addition in LLVM that caused this breakage and not think about it until upstream Rust fixes this when they next update LLVM tbh

@dylanmckay
Copy link
Member

dylanmckay commented Oct 1, 2016

I've fixed the segfault and am upstreaming it in rust-lang#36896

Found another segfault

@shepmaster
Copy link
Member Author

I think this is the most recent segfault:

* thread #2: tid = 0x2c556b, 0x00000001083fca78 librustc_llvm-d85452a8c927d1f5.dylib`llvm::MemoryBufferRef::getBuffer() const + 8, name = 'rustc', stop reason = EXC_BAD_ACCESS (code=1, address=0x10)
  * frame #0: 0x00000001083fca78 librustc_llvm-d85452a8c927d1f5.dylib`llvm::MemoryBufferRef::getBuffer() const + 8
    frame #1: 0x0000000108447285 librustc_llvm-d85452a8c927d1f5.dylib`llvm::object::Binary::getData() const + 21
    frame #2: 0x00000001084337b3 librustc_llvm-d85452a8c927d1f5.dylib`llvm::object::Archive::Child::Child(llvm::object::Archive const*, char const*, llvm::Error*) + 131
    frame #3: 0x000000010843528d librustc_llvm-d85452a8c927d1f5.dylib`llvm::object::Archive::Child::Child(llvm::object::Archive const*, char const*, llvm::Error*) + 45
    frame #4: 0x0000000107ca4e73 librustc_llvm-d85452a8c927d1f5.dylib`llvm::object::Archive::child_iterator::child_iterator(this=0x000000010da13bc0) + 35 at Archive.h:135
    frame #5: 0x0000000107ca4e45 librustc_llvm-d85452a8c927d1f5.dylib`llvm::object::Archive::child_iterator::child_iterator(this=0x000000010da13bc0) + 21 at Archive.h:135
    frame #6: 0x0000000107ca4e09 librustc_llvm-d85452a8c927d1f5.dylib`RustArchiveIterator::RustArchiveIterator(this=0x000000010da13bc0) + 25 at ArchiveWrapper.cpp:29
    frame #7: 0x0000000107c9a905 librustc_llvm-d85452a8c927d1f5.dylib`RustArchiveIterator::RustArchiveIterator(this=0x000000010da13bc0) + 21 at ArchiveWrapper.cpp:29
    frame #8: 0x0000000107c9a6b5 librustc_llvm-d85452a8c927d1f5.dylib`::LLVMRustArchiveIteratorNew(ra=0x000000010da128a0) + 85 at ArchiveWrapper.cpp:108
    frame #9: 0x0000000107c7c90b librustc_llvm-d85452a8c927d1f5.dylib`rustc_llvm::archive_ro::{{impl}}::iter(self=0x000070001049e8f0) + 43 at archive_ro.rs:73
    frame #10: 0x0000000102675095 librustc_metadata-15876f14be6b409b.dylib`rustc_metadata::loader::{{impl}}::new(ar=(ptr = 0x000000010da128a0)) + 117 at loader.rs:735
    frame #11: 0x00000001026760a9 librustc_metadata-15876f14be6b409b.dylib`rustc_metadata::loader::get_metadata_section_imp(target=0x00007000104bb8a0, flavor=Rlib, filename=0x000000010da128b0) + 1545 at loader.rs:794
    frame #12: 0x000000010267578e librustc_metadata-15876f14be6b409b.dylib`rustc_metadata::loader::get_metadata_section(target=0x00007000104bb8a0, flavor=Rlib, filename=0x000000010da128b0) + 142 at loader.rs:771
    frame #13: 0x0000000102671d90 librustc_metadata-15876f14be6b409b.dylib`rustc_metadata::loader::{{impl}}::extract_one(self=0x00007000104a2ec0, m=HashMap<std::path::PathBuf, rustc::session::search_paths::PathKind, core::hash::BuildHasherDefault<rustc_data_structures::fnv::FnvHasher>> @ 0x00007000104a0640, flavor=Rlib, slot=0x00007000104a0b00) + 1616 at loader.rs:549
    frame #14: 0x00000001026747df librustc_metadata-15876f14be6b409b.dylib`rustc_metadata::loader::{{impl}}::find_commandline_library<collections::btree::set::Iter<collections::string::String>>(self=0x00007000104a2ec0, locs=Iter<collections::string::String> @ 0x00007000104a0cd0) + 1295 at loader.rs:713
    frame #15: 0x000000010266ff51 librustc_metadata-15876f14be6b409b.dylib`rustc_metadata::loader::{{impl}}::find_library_crate(self=0x00007000104a2ec0) + 385 at loader.rs:404
    frame #16: 0x000000010266d97c librustc_metadata-15876f14be6b409b.dylib`rustc_metadata::loader::{{impl}}::maybe_load_library_crate(self=0x00007000104a2ec0) + 44 at loader.rs:314
    frame #17: 0x00000001026618c8 librustc_metadata-15876f14be6b409b.dylib`rustc_metadata::creader::{{impl}}::load(self=0x00007000104b0608, loader=0x00007000104a2ec0) + 88 at creader.rs:394
    frame #18: 0x0000000102662f56 librustc_metadata-15876f14be6b409b.dylib`rustc_metadata::creader::{{impl}}::read_extension_crate(self=0x00007000104b0608, span=Span @ 0x00007000104a3050, info=0x00007000104a4098) + 2166 at creader.rs:513
    frame #19: 0x000000010266402b librustc_metadata-15876f14be6b409b.dylib`rustc_metadata::creader::{{impl}}::read_macros(self=0x00007000104b0608, item=0x000000010da131f0) + 299 at creader.rs:559
    frame #20: 0x0000000102678e68 librustc_metadata-15876f14be6b409b.dylib`rustc_metadata::macro_import::{{impl}}::load_macros(self=0x00007000104b0600, vi=0x000000010da131f0, allows_macros=true, import=Option<std::collections::hash::map::HashMap<syntax::parse::token::InternedString, syntax_pos::Span, core::hash::BuildHasherDefault<rustc_data_structures::fnv::FnvHasher>>> @ 0x00007000104a4980, reexport=HashMap<syntax::parse::token::InternedString, syntax_pos::Span, core::hash::BuildHasherDefault<rustc_data_structures::fnv::FnvHasher>> @ 0x00007000104a4968) + 616 at macro_import.rs:115
    frame #21: 0x0000000102678276 librustc_metadata-15876f14be6b409b.dylib`rustc_metadata::macro_import::{{impl}}::load_crate(self=0x00007000104b0600, extern_crate=0x000000010da131f0, allows_macros=true) + 454 at macro_import.rs:94
    frame #22: 0x00000001026780a5 librustc_metadata-15876f14be6b409b.dylib`rustc_metadata::macro_import::load_macros(loader=0x00007000104b0600, extern_crate=0x000000010da131f0, allows_macros=true) + 85 at macro_import.rs:40
    frame #23: 0x0000000102669a75 librustc_metadata-15876f14be6b409b.dylib`rustc_metadata::creader::{{impl}}::load_macros(self=0x00007000104b0600, extern_crate=0x000000010da131f0, allows_macros=true) + 85 at creader.rs:1048
    frame #24: 0x0000000103531301 librustc_resolve-0bffade7bd96682b.dylib`rustc_resolve::macros::{{impl}}::load_crate(self=0x00007000104b0170, extern_crate=0x000000010da131f0, allows_macros=true) + 97 at macros.rs:41
    frame #25: 0x000000010c30b2d2 libsyntax-3a79160b29ac600e.dylib`syntax::ext::expand::{{impl}}::fold_item(self=0x00007000104ab2f8, item=P<syntax::ast::Item> @ 0x00007000104a58c0) + 3618 at expand.rs:679
    frame #26: 0x000000010c379ae9 libsyntax-3a79160b29ac600e.dylib`syntax::fold::noop_fold_mod::{{closure}}<syntax::ext::expand::InvocationCollector>(x=P<syntax::ast::Item> @ 0x00007000104a5970) + 73 at fold.rs:960
    frame #27: 0x000000010c0445ce libsyntax-3a79160b29ac600e.dylib`syntax::util::move_map::{{impl}}::move_flat_map<syntax::ptr::P<syntax::ast::Item>,closure,syntax::util::small_vector::SmallVector<syntax::ptr::P<syntax::ast::Item>>>(self=Vec<syntax::ptr::P<syntax::ast::Item>> @ 0x00007000104a5b80, f=closure @ 0x00007000104a5b78) + 574 at move_map.rs:38
    frame #28: 0x000000010c129f4a libsyntax-3a79160b29ac600e.dylib`syntax::fold::noop_fold_mod<syntax::ext::expand::InvocationCollector>((null)=Mod @ 0x00007000104a5cc8, folder=0x00007000104ab2f8) + 282 at fold.rs:960
    frame #29: 0x000000010c0d898c libsyntax-3a79160b29ac600e.dylib`syntax::fold::Folder::fold_mod<syntax::ext::expand::InvocationCollector>(self=0x00007000104ab2f8, m=Mod @ 0x00007000104a5d80) + 172 at fold.rs:131
    frame #30: 0x000000010c11c21a libsyntax-3a79160b29ac600e.dylib`syntax::fold::noop_fold_item_kind<syntax::ext::expand::InvocationCollector>(i=ItemKind @ 0x00007000104a7050, folder=0x00007000104ab2f8) + 1514 at fold.rs:868
    frame #31: 0x000000010c30dede libsyntax-3a79160b29ac600e.dylib`syntax::ext::expand::{{impl}}::fold_item_kind(self=0x00007000104ab2f8, item=ItemKind @ 0x00007000104a7388) + 270 at expand.rs:748
    frame #32: 0x000000010c12e5ea libsyntax-3a79160b29ac600e.dylib`syntax::fold::noop_fold_item_simple<syntax::ext::expand::InvocationCollector>((null)=Item @ 0x00007000104a77f0, folder=0x00007000104ab2f8) + 826 at fold.rs:1020
    frame #33: 0x000000010c0d4ed5 libsyntax-3a79160b29ac600e.dylib`syntax::fold::Folder::fold_item_simple<syntax::ext::expand::InvocationCollector>(self=0x00007000104ab2f8, i=Item @ 0x00007000104a7b58) + 197 at fold.rs:71
    frame #34: 0x000000010c3958d8 libsyntax-3a79160b29ac600e.dylib`syntax::fold::noop_fold_item::{{closure}}<syntax::ext::expand::InvocationCollector>(i=Item @ 0x00007000104a7ec8) + 216 at fold.rs:1009
    frame #35: 0x000000010c23de56 libsyntax-3a79160b29ac600e.dylib`syntax::ptr::{{impl}}::map<syntax::ast::Item,closure>(self=P<syntax::ast::Item> @ 0x00007000104a83b8, f=closure @ 0x00007000104a83a8) + 614 at ptr.rs:86
    frame #36: 0x000000010c12c091 libsyntax-3a79160b29ac600e.dylib`syntax::fold::noop_fold_item<syntax::ext::expand::InvocationCollector>(i=P<syntax::ast::Item> @ 0x00007000104a8688, folder=0x00007000104ab2f8) + 97 at fold.rs:1009
    frame #37: 0x000000010c30ad37 libsyntax-3a79160b29ac600e.dylib`syntax::ext::expand::{{impl}}::fold_item(self=0x00007000104ab2f8, item=P<syntax::ast::Item> @ 0x00007000104a9000) + 2183 at expand.rs:647
    frame #38: 0x000000010c353d39 libsyntax-3a79160b29ac600e.dylib`syntax::ext::expand::{{impl}}::fold_with::{{closure}}<syntax::ext::expand::InvocationCollector>(ast=P<syntax::ast::Item> @ 0x00007000104a90b0) + 73 at expand.rs:81
    frame #39: 0x000000010bec3cdb libsyntax-3a79160b29ac600e.dylib`{{inlined-root}}::call_once<(syntax::ptr::P<syntax::ast::Item>),closure>(self=0x00007000104a95a0, (null)=P<syntax::ast::Item> @ 0x000000010da13740) + 75 at ops.rs:2644
    frame #40: 0x000000010be19a78 libsyntax-3a79160b29ac600e.dylib`{{inlined-root}}::map<syntax::ptr::P<syntax::ast::Item>,syntax::util::small_vector::SmallVector<syntax::ptr::P<syntax::ast::Item>>,&mut closure>(self=Option<syntax::ptr::P<syntax::ast::Item>> @ 0x00007000104a91d8, f=0x00007000104a95a0) + 248 at option.rs:383
    frame #41: 0x000000010bfb926d libsyntax-3a79160b29ac600e.dylib`{{inlined-root}}::next<syntax::util::small_vector::IntoIter<syntax::ptr::P<syntax::ast::Item>>,syntax::util::small_vector::SmallVector<syntax::ptr::P<syntax::ast::Item>>,closure>(self=0x00007000104a9570) + 397 at mod.rs:1629
    frame #42: 0x000000010bfccce2 libsyntax-3a79160b29ac600e.dylib`syntax::util::small_vector::{{impl}}::extend<syntax::ptr::P<syntax::ast::Item>,core::iter::FlatMap<syntax::util::small_vector::IntoIter<syntax::ptr::P<syntax::ast::Item>>, syntax::util::small_vector::SmallVector<syntax::ptr::P<syntax::ast::Item>>, closure>>(self=0x00007000104a98a0, iter=FlatMap<syntax::util::small_vector::IntoIter<syntax::ptr::P<syntax::ast::Item>>, syntax::util::small_vector::SmallVector<syntax::ptr::P<syntax::ast::Item>>, closure> @ 0x00007000104a96d0) + 242 at small_vector.rs:58
    frame #43: 0x000000010bfc7518 libsyntax-3a79160b29ac600e.dylib`syntax::util::small_vector::{{impl}}::from_iter<syntax::ptr::P<syntax::ast::Item>,core::iter::FlatMap<syntax::util::small_vector::IntoIter<syntax::ptr::P<syntax::ast::Item>>, syntax::util::small_vector::SmallVector<syntax::ptr::P<syntax::ast::Item>>, closure>>(iter=FlatMap<syntax::util::small_vector::IntoIter<syntax::ptr::P<syntax::ast::Item>>, syntax::util::small_vector::SmallVector<syntax::ptr::P<syntax::ast::Item>>, closure> @ 0x00007000104a9968) + 248 at small_vector.rs:51
    frame #44: 0x000000010bee5855 libsyntax-3a79160b29ac600e.dylib`{{inlined-root}}::collect<core::iter::FlatMap<syntax::util::small_vector::IntoIter<syntax::ptr::P<syntax::ast::Item>>, syntax::util::small_vector::SmallVector<syntax::ptr::P<syntax::ast::Item>>, closure>,syntax::util::small_vector::SmallVector<syntax::ptr::P<syntax::ast::Item>>>(self=FlatMap<syntax::util::small_vector::IntoIter<syntax::ptr::P<syntax::ast::Item>>, syntax::util::small_vector::SmallVector<syntax::ptr::P<syntax::ast::Item>>, closure> @ 0x00007000104a9bc8) + 165 at iterator.rs:1200
    frame #45: 0x000000010c2fe023 libsyntax-3a79160b29ac600e.dylib`syntax::ext::expand::{{impl}}::fold_with<syntax::ext::expand::InvocationCollector>(self=Expansion @ 0x00007000104aadf0, folder=0x00007000104ab2f8) + 1683 at expand.rs:81
    frame #46: 0x000000010c3034f1 libsyntax-3a79160b29ac600e.dylib`syntax::ext::expand::{{impl}}::collect_invocations(self=0x00007000104ad9c8, expansion=Expansion @ 0x00007000104ab558) + 609 at expand.rs:274
    frame #47: 0x000000010c30201f libsyntax-3a79160b29ac600e.dylib`syntax::ext::expand::{{impl}}::expand(self=0x00007000104ad9c8, expansion=Expansion @ 0x00007000104ace08) + 447 at expand.rs:220
    frame #48: 0x000000010c30173b libsyntax-3a79160b29ac600e.dylib`syntax::ext::expand::{{impl}}::expand_crate(self=0x00007000104ad9c8, krate=Crate @ 0x00007000104ad878) + 1035 at expand.rs:195
    frame #49: 0x000000010c30e66b libsyntax-3a79160b29ac600e.dylib`syntax::ext::expand::expand_crate(cx=0x00007000104adf30, user_exts=Vec<(syntax::ast::Name, syntax::ext::base::SyntaxExtension)> @ 0x00007000104adb10, c=Crate @ 0x00007000104ada90) + 347 at expand.rs:814
    frame #50: 0x000000010042c859 librustc_driver-6e670f88c682b7bb.dylib`rustc_driver::driver::phase_2_configure_and_expand::{{closure}}<closure> + 841 at driver.rs:682
    frame #51: 0x00000001001fb4a6 librustc_driver-6e670f88c682b7bb.dylib`{{inlined-root}}::time<syntax::ast::Crate,closure>(do_it=false, what=(data_ptr = "expansion", length = 9), f=closure @ 0x00007000104ae7e8) + 294 at common.rs:38
    frame #52: 0x00000001003f305d librustc_driver-6e670f88c682b7bb.dylib`rustc_driver::driver::phase_2_configure_and_expand<closure>(sess=0x00007000104bb598, cstore=0x000000010da025f0, krate=Crate @ 0x00007000104b0ca8, registry=Option<rustc_plugin::registry::Registry> @ 0x00007000104b0bc0, crate_name=(data_ptr = "compiler_builtins", length = 17), addl_plugins=Option<collections::vec::Vec<collections::string::String>> @ 0x00007000104b0b98, make_glob_map=No, after_expand=closure @ 0x00007000104b0b58) + 4557 at driver.rs:647
    frame #53: 0x00000001003edf39 librustc_driver-6e670f88c682b7bb.dylib`rustc_driver::driver::compile_input(sess=0x00007000104bb598, cstore=0x000000010da025f0, cfg=Vec<syntax::ptr::P<syntax::codemap::Spanned<syntax::ast::MetaItemKind>>> @ 0x00007000104b4400, input=0x00007000104bc458, outdir=0x00007000104bc4a8, output=0x00007000104bc490, addl_plugins=Option<collections::vec::Vec<collections::string::String>> @ 0x00007000104b43d0, control=0x00007000104bb4d0) + 2729 at driver.rs:120
    frame #54: 0x00000001004081e4 librustc_driver-6e670f88c682b7bb.dylib`rustc_driver::run_compiler_with_file_loader<syntax::codemap::RealFileLoader>(args=&[collections::string::String] @ 0x00007000104bc990, callbacks=&mut CompilerCalls @ 0x00007000104bc980, loader=0x0000000000000001) + 4500 at lib.rs:226
    frame #55: 0x0000000100407021 librustc_driver-6e670f88c682b7bb.dylib`rustc_driver::run_compiler(args=&[collections::string::String] @ 0x00007000104bca50, callbacks=&mut CompilerCalls @ 0x00007000104bca40) + 145 at lib.rs:161
    frame #56: 0x000000010045fee9 librustc_driver-6e670f88c682b7bb.dylib`rustc_driver::run::{{closure}} + 217 at lib.rs:136
    frame #57: 0x000000010045acdd librustc_driver-6e670f88c682b7bb.dylib`rustc_driver::monitor::{{closure}}<closure> + 173 at lib.rs:1083
    frame #58: 0x00000001003c25b3 librustc_driver-6e670f88c682b7bb.dylib`{{inlined-root}}::call_once<(),closure>(self=AssertUnwindSafe<closure> @ 0x00007000104bf7f0) + 115 at panic.rs:255
    frame #59: 0x0000000100119105 librustc_driver-6e670f88c682b7bb.dylib`{{inlined-root}}::do_call<std::panic::AssertUnwindSafe<closure>,()>(data="�{�\r\x01") + 341 at panicking.rs:356
    frame #60: 0x000000010d268928 libstd-dec491587576f8e3.dylib`__rust_try + 24
    frame #61: 0x000000010d268708 libstd-dec491587576f8e3.dylib`panic_unwind::__rust_maybe_catch_panic(f=(librustc_driver-6e670f88c682b7bb.dylib`{{inlined-root}}::do_call<std::panic::AssertUnwindSafe<closure>,()> at panicking.rs:352), data="�{�\r\x01", data_ptr=0x00007000104bfb48, vtable_ptr=0x00007000104bfb40) + 88 at lib.rs:91
    frame #62: 0x0000000100118d0b librustc_driver-6e670f88c682b7bb.dylib`{{inlined-root}}::try<(),std::panic::AssertUnwindSafe<closure>>(f=AssertUnwindSafe<closure> @ 0x00007000104bfb70) + 331 at panicking.rs:332
    frame #63: 0x0000000100117f62 librustc_driver-6e670f88c682b7bb.dylib`{{inlined-root}}::catch_unwind<std::panic::AssertUnwindSafe<closure>,()>(f=AssertUnwindSafe<closure> @ 0x00007000104bfc10) + 130 at panic.rs:311
    frame #64: 0x000000010041e4df librustc_driver-6e670f88c682b7bb.dylib`std::thread::Builder::spawn::_$u7b$$u7b$closure$u7d$$u7d$::h7fed6055eb8097e3 + 351
    frame #65: 0x00000001001ac0bc librustc_driver-6e670f88c682b7bb.dylib`{{inlined-root}}::call_box<(),closure>(self=0x000000010dc07d30, args=<unavailable>) + 76 at boxed.rs:591
    frame #66: 0x000000010d18506a libstd-dec491587576f8e3.dylib`{{inlined-root}}::call_once<(),()>(self=Box<FnBox<()>> @ 0x00007000104bfe30) + 42 at boxed.rs:601
    frame #67: 0x000000010d22b9c1 libstd-dec491587576f8e3.dylib`std::sys_common::thread::start_thread(main=0x000000010dc07c30) + 97 at thread.rs:21
    frame #68: 0x000000010d255b6d libstd-dec491587576f8e3.dylib`std::sys::thread::{{impl}}::new::thread_start(main=0x000000010dc07c30) + 29 at thread.rs:71
    frame #69: 0x00007fffad46dabb libsystem_pthread.dylib`_pthread_body + 180
    frame #70: 0x00007fffad46da07 libsystem_pthread.dylib`_pthread_start + 286
    frame #71: 0x00007fffad46d231 libsystem_pthread.dylib`thread_start + 13

@shepmaster
Copy link
Member Author

shepmaster commented Oct 2, 2016

I got my debugging info setup correctly:

frame #3: 0x00000001084335bd librustc_llvm-d85452a8c927d1f5.dylib`llvm::object::Archive::Child::Child(this=0x000000010f40b1c0, Parent=0x0000000000000000, Start=0x0000000000000000, Err=0x0000000000000000) + 45 at Archive.cpp:310
   307
   308  Archive::Child::Child(const Archive *Parent, const char *Start, Error *Err)
   309      : Parent(Parent), Header(Parent, Start, Parent->getData().size() -
-> 310                               (Start - Parent->getData().data()), Err) {
   311    if (!Start)
   312      return;
   313
(lldb) up
frame #4: 0x0000000107ca4d03 librustc_llvm-d85452a8c927d1f5.dylib`llvm::object::Archive::child_iterator::child_iterator(this=0x000000010f40b1c0) + 35 at Archive.h:135
   132      Error *E;
   133
   134    public:
-> 135      child_iterator() : C(Child(nullptr, nullptr, nullptr)), E(nullptr) {}

so Parent and Start are null. I did cherry-pick your change c9ec72ab8f1ee61644d41db8ebe19757336bcffb.

I don't understand how this code could ever work if nullptr is hardcoded...

@dylanmckay
Copy link
Member

dylanmckay commented Oct 3, 2016

I'm looking at that too. I believe this was broken in r276686. There is still a default constructor for Archive::Child but it gives nullptr as the Parent which will always segfault. Nobody must've noticed this in code review.

Upstream LLVM regression :(

@shepmaster
Copy link
Member Author

Upstream LLVM regression :(

So what's the right process here?

@dylanmckay
Copy link
Member

We can email llvm-commits and CC in the original author, or we could fix it ourselves and I could upstream it.

The fix will basically be to change this in Archive.cpp

Archive::Child::Child(const Archive *Parent, const char *Start, Error *Err)
    : Parent(Parent), Header(Parent, Start, Parent->getData().size() -
                              (Start - Parent->getData().data()), Err) {

So that it handles Parent being null. One issue is that Header itself doesn't have a default constructor, and it is a non-nullable field on Archive::Child so it's not as easy as calling a different constructor.

@dylanmckay
Copy link
Member

I've just sent an email to llvm-commits CCing @shepmaster and the original author.

@dylanmckay
Copy link
Member

Lang Hames is currently working on a fix, we should be able to update LLVM again after that and we should be good.

@dylanmckay
Copy link
Member

This has been fixed as of r283387. I'm merging master in again now.

@dylanmckay
Copy link
Member

I needed to rebase on top of master again because Rust stopped building with Apple Clang 8, more merge conflicts, JS backend added, etc.

I think I'm on top of it now, we'll see how this build goes.

@dylanmckay
Copy link
Member

The ResumeInst thing has been fixed, I'm now raising #22 to look at the current error I'm getting.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants