Bug#913271: segfault - broken rust compiling

Ximin Luo infinity0 at debian.org
Sun Nov 11 00:10:00 GMT 2018


The segfault is triggered by the presence of debuginfo=N where N != 0. You can avoid it by setting RUSTFLAGS or running "cargo rustc -- -C debuginfo=0" instead of "cargo build".

Together with the workaround for #913414, this means a temporary workaround for users could be to set RUSTFLAGS="-C debuginfo=0 -C relocation-model=default" in their environment. This works in some cases, unfortunately it doesn't work for packages that have a custom build.rs and use cc in it. (Perhaps the workaround can be extended to cover these cases too but I couldn't figure out how.)

Here is a backtrace of the segfault, would be good if someone else more familiar with LLVM than me could take a look:

hello_world$ gdb -q rustc
Reading symbols from rustc...Reading symbols from /usr/lib/debug/.build-id/e9/0dc62b102986d644f980ffeab6adab6f53625d.debug...done.
done.
warning: Missing auto-load script at offset 0 in section .debug_gdb_scripts
of file /usr/bin/rustc.
Use `info auto-load python-scripts [REGEXP]' to list them.
(gdb) run src/main.rs -C debuginfo=2
Starting program: /usr/bin/rustc src/main.rs -C debuginfo=2
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1".
[New Thread 0x7fffee0ed700 (LWP 10750)]
[New Thread 0x7fffedeec700 (LWP 10751)]
[New Thread 0x7fffedceb700 (LWP 10752)]
[New Thread 0x7fffedae8700 (LWP 10753)]
[Thread 0x7fffedae8700 (LWP 10753) exited]
[Thread 0x7fffedceb700 (LWP 10752) exited]

Thread 1 "rustc" received signal SIGSEGV, Segmentation fault.
0x00007ffff1e273bc in llvm::StringMapImpl::LookupBucketFor(llvm::StringRef) () from /usr/lib/x86_64-linux-gnu/libLLVM-7.so.1
(gdb) bt
#0  0x00007ffff1e273bc in llvm::StringMapImpl::LookupBucketFor(llvm::StringRef) () from /usr/lib/x86_64-linux-gnu/libLLVM-7.so.1
#1  0x00007ffff1f654c9 in ?? () from /usr/lib/x86_64-linux-gnu/libLLVM-7.so.1
#2  0x00007ffff1f65491 in llvm::MDString::get(llvm::LLVMContext&, llvm::StringRef) () from /usr/lib/x86_64-linux-gnu/libLLVM-7.so.1
#3  0x00007ffff1ee69cd in ?? () from /usr/lib/x86_64-linux-gnu/libLLVM-7.so.1
#4  0x00007ffff1ee2d12 in llvm::DIBuilder::createFile(llvm::StringRef, llvm::StringRef, llvm::Optional<llvm::DIFile::ChecksumInfo<llvm::StringRef> >, llvm::Optional<llvm::StringRef>) () from /usr/lib/x86_64-linux-gnu/libLLVM-7.so.1
#5  0x00007ffff50a01f2 in LLVMRustDIBuilderCreateFile (Builder=0x5555555d4180, Filename=0x7ffffffeedd8 "src/main.rs", Directory=0x555555b3dd10 "$HOME/hello_world")
    at /usr/lib/llvm-7/include/llvm/ADT/StringRef.h:85
#6  0x00007ffff501d39e in rustc_codegen_llvm::debuginfo::metadata::compile_unit_metadata (tcx=..., codegen_unit_name=..., debug_context=0x7ffffffeeeb0) at librustc_codegen_llvm/debuginfo/metadata.rs:859
#7  0x00007ffff4f75946 in rustc_codegen_llvm::context::CodegenCx::new (tcx=..., codegen_unit=..., llvm_module=<optimized out>) at librustc_codegen_llvm/context.rs:272
#8  0x00007ffff4ffad3e in rustc_codegen_llvm::base::compile_codegen_unit::module_codegen (tcx=..., cgu_name=...) at librustc_codegen_llvm/base.rs:1225
#9  0x00007ffff503e642 in rustc::dep_graph::graph::DepGraph::with_task_impl (self=0x7fffffff15d8, arg=..., no_tcx=false, task=0xffff8000000e8150, key=..., cx=..., create_task=<optimized out>, 
    finish_task_and_alloc_depnode=<optimized out>) at librustc/dep_graph/graph.rs:342
#10 rustc::dep_graph::graph::DepGraph::with_task (self=0x7fffffff15d8, key=..., cx=..., arg=..., task=0x7ffff4ffac40 <rustc_codegen_llvm::base::compile_codegen_unit::module_codegen>) at librustc/dep_graph/graph.rs:208
#11 0x00007ffff4ff8b8f in rustc_codegen_llvm::base::compile_codegen_unit (tcx=..., cgu_name=...) at librustc_codegen_llvm/base.rs:1199
#12 rustc_codegen_llvm::base::codegen_crate (tcx=..., rx=...) at librustc_codegen_llvm/base.rs:905
#13 0x00007ffff502df70 in <rustc_codegen_llvm::LlvmCodegenBackend as rustc_codegen_utils::codegen_backend::CodegenBackend>::codegen_crate (self=<optimized out>, tcx=..., rx=...) at librustc_codegen_llvm/lib.rs:215
#14 0x00007ffff7deb832 in rustc_driver::driver::phase_4_codegen::{{closure}} () at librustc_driver/driver.rs:1369
#15 rustc::util::common::time_ext (do_it=<optimized out>, what=..., sess=<optimized out>, f=...) at librustc/util/common.rs:163
#16 rustc::util::common::time (sess=<optimized out>, what=..., f=...) at librustc/util/common.rs:157
#17 0x00007ffff7e104ae in rustc_driver::driver::phase_4_codegen (codegen_backend=..., tcx=..., rx=...) at librustc_driver/driver.rs:1369
#18 0x00007ffff7ebd614 in rustc_driver::driver::compile_input::{{closure}} (tcx=..., analysis=..., rx=..., result=...) at librustc_driver/driver.rs:328
#19 0x00007ffff7eb7446 in rustc_driver::driver::phase_3_run_analysis_passes::{{closure}} (tcx=...) at librustc_driver/driver.rs:1352
#20 rustc::ty::context::tls::enter_global::{{closure}}::{{closure}} () at librustc/ty/context.rs:1986
#21 rustc::ty::context::tls::enter_context::{{closure}} () at librustc/ty/context.rs:1954
#22 rustc::ty::context::tls::set_tlv (value=<optimized out>, f=...) at librustc/ty/context.rs:1893
#23 rustc::ty::context::tls::enter_context (context=<optimized out>, f=...) at librustc/ty/context.rs:1953
#24 0x00007ffff7e6e1cb in rustc::ty::context::tls::enter_global::{{closure}} () at librustc/ty/context.rs:1985
#25 rustc::ty::context::tls::with_thread_locals::{{closure}}::{{closure}} (current=0x7ffff5145798) at librustc/ty/context.rs:1943
#26 <std::thread::local::LocalKey<T>>::try_with (f=..., self=<optimized out>) at libstd/thread/local.rs:294
#27 <std::thread::local::LocalKey<T>>::with (self=<optimized out>, f=...) at libstd/thread/local.rs:248
#28 rustc::ty::context::tls::with_thread_locals::{{closure}} (span_dbg=0x7ffff5145788) at librustc/ty/context.rs:1935
#29 <std::thread::local::LocalKey<T>>::try_with (self=<optimized out>, f=...) at libstd/thread/local.rs:294
#30 <std::thread::local::LocalKey<T>>::with (self=<optimized out>, f=...) at libstd/thread/local.rs:248
#31 0x00007ffff7edde1f in rustc::ty::context::tls::with_thread_locals (f=...) at librustc/ty/context.rs:1927
#32 rustc::ty::context::tls::enter_global (gcx=0x7fffffff6c58, f=...) at librustc/ty/context.rs:1965
#33 rustc::ty::context::TyCtxt::create_and_enter (s=<optimized out>, cstore=..., local_providers=..., extern_providers=..., arenas=0x7fffffff6c58, resolutions=..., hir=..., on_disk_query_result_cache=..., crate_name=..., tx=..., 
    output_filenames=0x7fffffff6ea0, f=...) at librustc/ty/context.rs:1271
#34 0x00007ffff7e09899 in rustc_driver::driver::phase_3_run_analysis_passes (codegen_backend=..., control=<optimized out>, sess=0x7fffffff8f60, arenas=0x7ffff79dd490 <rustc_traits::lowering::program_clauses_for_env>, 
    output_filenames=<optimized out>, f=..., cstore=<optimized out>, hir_map=..., analysis=..., resolutions=..., name=...) at librustc_driver/driver.rs:1260
#35 rustc_driver::driver::compile_input (codegen_backend=..., sess=<optimized out>, cstore=<optimized out>, input_path=<optimized out>, input=<optimized out>, outdir=<optimized out>, output=<optimized out>, addl_plugins=..., 
    control=<optimized out>) at librustc_driver/driver.rs:287
#36 0x00007ffff7ec22d5 in rustc_driver::run_compiler_with_pool (matches=..., sopts=..., cfg=..., callbacks=..., file_loader=..., emitter_dest=...) at librustc_driver/lib.rs:563
#37 0x00007ffff7e07665 in rustc_driver::run_compiler::{{closure}} (sopts=...) at librustc_driver/lib.rs:485
#38 rustc_driver::driver::spawn_thread_pool::{{closure}} () at librustc_driver/driver.rs:76
#39 <scoped_tls::ScopedKey<T>>::set (self=<optimized out>, f=..., t=<optimized out>) at vendor/scoped-tls/src/lib.rs:155
#40 rustc_driver::driver::spawn_thread_pool (opts=..., f=...) at librustc_driver/driver.rs:75
#41 0x00007ffff7ec12f2 in rustc_driver::run_compiler (args=..., callbacks=..., file_loader=..., emitter_dest=...) at librustc_driver/lib.rs:484
#42 0x00007ffff7df49cd in rustc_driver::main::{{closure}} () at librustc_driver/lib.rs:1745
#43 rustc_driver::run::{{closure}}::{{closure}} () at librustc_driver/lib.rs:190
#44 <scoped_tls::ScopedKey<T>>::set (self=<optimized out>, t=<optimized out>, f=...) at vendor/scoped-tls/src/lib.rs:155
#45 syntax::with_globals::{{closure}} () at libsyntax/lib.rs:108
#46 <scoped_tls::ScopedKey<T>>::set (self=<optimized out>, t=<optimized out>, f=...) at vendor/scoped-tls/src/lib.rs:155
#47 0x00007ffff7e33b52 in syntax::with_globals (f=...) at libsyntax/lib.rs:107
#48 0x00007ffff7cc7aba in __rust_maybe_catch_panic (f=0xffff8000000e8150, data=0x0, data_ptr=0x7fffffffe760, vtable_ptr=0x7fffffffe830) at libpanic_unwind/lib.rs:103
#49 0x00007ffff7ebf51d in std::panicking::try (f=...) at libstd/panicking.rs:289
---Type <return> to continue, or q <return> to quit---
#50 std::panic::catch_unwind (f=...) at libstd/panic.rs:392
#51 rustc_driver::in_named_rustc_thread (name=..., f=...) at librustc_driver/lib.rs:1574
#52 rustc_driver::in_rustc_thread (f=...) at librustc_driver/lib.rs:1585
#53 rustc_driver::monitor (f=...) at librustc_driver/lib.rs:1659
#54 rustc_driver::run (run_compiler=...) at librustc_driver/lib.rs:188
#55 0x00007ffff7ecd63b in rustc_driver::main () at librustc_driver/lib.rs:1738
#56 0x00005555555551a3 in std::rt::lang_start::{{closure}} () at libstd/rt.rs:74
#57 0x00007ffff7c89593 in std::rt::lang_start_internal::{{closure}} () at libstd/rt.rs:59
#58 std::panicking::try::do_call (data=0x7fffffffe9f0 "\020\352\377\377\377\177\000") at libstd/panicking.rs:310
#59 0x00007ffff7cc7aba in __rust_maybe_catch_panic (f=0xffff8000000e8150, data=0x0, data_ptr=0x7fffffffea08, vtable_ptr=0x7fffffffe9c8) at libpanic_unwind/lib.rs:103
#60 0x00007ffff7ca0686 in std::panicking::try (f=...) at libstd/panicking.rs:289
#61 std::panic::catch_unwind (f=...) at libstd/panic.rs:392
#62 std::rt::lang_start_internal (main=..., argc=4, argv=<optimized out>) at libstd/rt.rs:58
#63 0x000055555555519a in main ()
#64 0x00007ffff7a9db17 in __libc_start_main (main=0x555555555170 <main>, argc=4, argv=0x7fffffffeb48, init=<optimized out>, fini=<optimized out>, rtld_fini=<optimized out>, stack_end=0x7fffffffeb38) at ../csu/libc-start.c:310
#65 0x000055555555509a in _start ()


On Sat, 10 Nov 2018 21:56:59 +0100 Sylvestre Ledru <sylvestre at debian.org> wrote:
> 
> Le 10/11/2018 à 21:12, Santiago Vila a écrit :
> > On Thu, 8 Nov 2018, Sylvestre Ledru wrote:
> >
> >> Le 08/11/2018 à 21:30, jnqnfe at gmail.com a écrit :
> >>> Package: llvm-7
> >>> Version: 1:7.0.1~+rc2-1
> >>> Severity: grave
> >>>
> >>> I've just updated my Sid install and found that building Rust crates
> >>> with Cargo now fails with a seg fault.
> >>>
> >>> Initially I fired a bug report at cargo to kick things off, but I've
> >>> now discovered that it relates to the llvm-7 update, as switching llvm7
> >>> packages back to testing versions fixes the problem.
> >> Do you have more info than "it segfaults"?
> > I believe the reported problem is the same that makes all these
> > recently uploaded rust packages to FTBFS:
> >
> > https://tests.reproducible-builds.org/debian/rb-pkg/unstable/amd64/rust-arc-swap.html
> > https://tests.reproducible-builds.org/debian/rb-pkg/unstable/amd64/rust-encoding.html
> > https://tests.reproducible-builds.org/debian/rb-pkg/unstable/amd64/rust-encode-unicode.html
> > https://tests.reproducible-builds.org/debian/rb-pkg/unstable/amd64/rust-crossbeam-epoch-0.5.html
> > https://tests.reproducible-builds.org/debian/rb-pkg/unstable/amd64/rust-gobject-sys.html
> > https://tests.reproducible-builds.org/debian/rb-pkg/unstable/amd64/rust-grep-regex.html
> > https://tests.reproducible-builds.org/debian/rb-pkg/unstable/amd64/rust-heck.html
> > https://tests.reproducible-builds.org/debian/rb-pkg/unstable/amd64/rust-iso8601.html
> > https://tests.reproducible-builds.org/debian/rb-pkg/unstable/amd64/rust-mio-uds.html
> > https://tests.reproducible-builds.org/debian/rb-pkg/unstable/amd64/rust-rustc-version.html
> > https://tests.reproducible-builds.org/debian/rb-pkg/unstable/amd64/rust-term.html
> > https://tests.reproducible-builds.org/debian/rb-pkg/unstable/amd64/rust-stringprep.html
> > https://tests.reproducible-builds.org/debian/rb-pkg/unstable/amd64/rust-string-cache-codegen.html
> 
> Yeah, this is related to the move of llvm toolchain to be compiled using
> clang (stage2).
> 
> Reverting llvm to the previous version works.
> 
> If someone could help debugging the segfault, this would be great :)
> 
> Thanks
> S
> 


-- 
GPG: ed25519/56034877E1F87C35
GPG: rsa4096/1318EFAC5FBBDBCE
https://github.com/infinity0/pubkeys.git



More information about the Pkg-llvm-team mailing list