Bug 23574 - Rust 1.28.0-1.mga6 segfaults when compiling encoding_c (and thus firefox)
Summary: Rust 1.28.0-1.mga6 segfaults when compiling encoding_c (and thus firefox)
Status: RESOLVED FIXED
Alias: None
Product: Mageia
Classification: Unclassified
Component: RPM Packages (show other bugs)
Version: 6
Hardware: All Linux
Priority: Normal critical
Target Milestone: ---
Assignee: QA Team
QA Contact:
URL:
Whiteboard: MGA6-64-OK
Keywords: advisory, has_procedure, validated_update
Depends on:
Blocks:
 
Reported: 2018-09-15 00:59 CEST by Rémi Verschelde
Modified: 2018-09-21 01:18 CEST (History)
1 user (show)

See Also:
Source RPM: rust-1.28.0-1.mga6
CVE:
Status comment:


Attachments

Description Rémi Verschelde 2018-09-15 00:59:08 CEST
When compiling the Rust crate `encoding_c` (version 0.8.0), rustc segfaults:


-----

$ git clone https://github.com/hsivonen/encoding_c
$ cd encoding_c
$ git checkout v0.8.0
$ cargo build --verbose
       Fresh cfg-if v0.1.5
       Fresh encoding_rs v0.7.2
   Compiling encoding_c v0.8.0 (file:///home/akien/tmp/encoding_c)
     Running `rustc --crate-name encoding_c src/lib.rs --crate-type lib --emit=dep-info,link -C debuginfo=2 -C metadata=a4b0f5c8585ef9ae -C extra-filename=-a4b0f5c8585ef9ae --out-dir /home/akien/tmp/encoding_c/target/debug/deps -C incremental=/home/akien/tmp/encoding_c/target/debug/incremental -L dependency=/home/akien/tmp/encoding_c/target/debug/deps --extern encoding_rs=/home/akien/tmp/encoding_c/target/debug/deps/libencoding_rs-48383778ec87c0b3.rlib`
error: Could not compile `encoding_c`.

Caused by:
  process didn't exit successfully: `rustc --crate-name encoding_c src/lib.rs --crate-type lib --emit=dep-info,link -C debuginfo=2 -C metadata=a4b0f5c8585ef9ae -C extra-filename=-a4b0f5c8585ef9ae --out-dir /home/akien/tmp/encoding_c/target/debug/deps -C incremental=/home/akien/tmp/encoding_c/target/debug/incremental -L dependency=/home/akien/tmp/encoding_c/target/debug/deps --extern encoding_rs=/home/akien/tmp/encoding_c/target/debug/deps/libencoding_rs-48383778ec87c0b3.rlib` (signal: 11, SIGSEGV: invalid memory reference)

-----

Backtrace:

Thread 1 "rustc" received signal SIGSEGV, Segmentation fault.
0x00007ffff72c5c6a in strlen () from /lib64/libc.so.6
(gdb) bt
#0  0x00007ffff72c5c6a in strlen () from /lib64/libc.so.6
#1  0x00007fffeff6e3d0 in LLVMRustDIBuilderCreateStaticVariable () from /usr/lib/rustlib/x86_64-unknown-linux-gnu/codegen-backends/librustc_codegen_llvm-llvm.so
#2  0x00007fffefeed736 in rustc_codegen_llvm::debuginfo::metadata::create_global_var_metadata::h385cd2ccd9ae36cb ()
   from /usr/lib/rustlib/x86_64-unknown-linux-gnu/codegen-backends/librustc_codegen_llvm-llvm.so
#3  0x00007fffeff2cecd in rustc_codegen_llvm::consts::codegen_static::h2e38e5e9654d82d7 () from /usr/lib/rustlib/x86_64-unknown-linux-gnu/codegen-backends/librustc_codegen_llvm-llvm.so
#4  0x00007fffefe5a66a in rustc_codegen_llvm::mono_item::MonoItemExt::define::h3f4d4603cfb619d4 ()
   from /usr/lib/rustlib/x86_64-unknown-linux-gnu/codegen-backends/librustc_codegen_llvm-llvm.so
#5  0x00007fffefee5103 in rustc_codegen_llvm::base::compile_codegen_unit::h74eac8adde3255ca () from /usr/lib/rustlib/x86_64-unknown-linux-gnu/codegen-backends/librustc_codegen_llvm-llvm.so
#6  0x00007ffff396a747 in rustc::ty::query::__query_compute::compile_codegen_unit::h55f41a1670671037 () from /lib64/librustc-e1eeeaf74b9fb842.so
#7  0x00007ffff3686fd0 in rustc::ty::query::_$LT$impl$u20$rustc..ty..query..config..QueryAccessors$LT$$u27$tcx$GT$$u20$for$u20$rustc..ty..query..queries..compile_codegen_unit$LT$$u27$tcx$GT$$GT$::compute::h4dab223a1afa271a () from /lib64/librustc-e1eeeaf74b9fb842.so
#8  0x00007ffff35e9a84 in rustc::ty::context::tls::with_context::h0b4d469939316e38 () from /lib64/librustc-e1eeeaf74b9fb842.so
#9  0x00007ffff3510d95 in rustc::dep_graph::graph::DepGraph::with_task_impl::h7c45266264c1f51d () from /lib64/librustc-e1eeeaf74b9fb842.so
#10 0x00007ffff34ee6d7 in rustc::dep_graph::graph::DepGraph::with_task::h4036999ab06bde92 () from /lib64/librustc-e1eeeaf74b9fb842.so
#11 0x00007ffff3639eb7 in rustc::ty::context::tls::with_related_context::h40d58168569011f6 () from /lib64/librustc-e1eeeaf74b9fb842.so
#12 0x00007ffff371c615 in _$LT$rustc..ty..query..plumbing..JobOwner$LT$$u27$a$C$$u20$$u27$tcx$C$$u20$Q$GT$$GT$::start::h7a142c939b1e281c () from /lib64/librustc-e1eeeaf74b9fb842.so
#13 0x00007ffff3767f9f in rustc::ty::query::plumbing::_$LT$impl$u20$rustc..ty..context..TyCtxt$LT$$u27$a$C$$u20$$u27$gcx$C$$u20$$u27$tcx$GT$$GT$::force_query_with_job::h3fbcf0b1a012dcc8 ()
   from /lib64/librustc-e1eeeaf74b9fb842.so
#14 0x00007ffff38836f7 in rustc::ty::query::plumbing::_$LT$impl$u20$rustc..ty..context..TyCtxt$LT$$u27$a$C$$u20$$u27$gcx$C$$u20$$u27$tcx$GT$$GT$::get_query::hee6f493be843e6b0 ()
   from /lib64/librustc-e1eeeaf74b9fb842.so
#15 0x00007ffff3ac8ed9 in rustc::ty::query::TyCtxtAt::compile_codegen_unit::h5c393d5c40988ec2 () from /lib64/librustc-e1eeeaf74b9fb842.so
#16 0x00007ffff38a0d56 in rustc::ty::query::_$LT$impl$u20$rustc..ty..context..TyCtxt$LT$$u27$a$C$$u20$$u27$tcx$C$$u20$$u27$lcx$GT$$GT$::compile_codegen_unit::h7b61799abb630ae8 ()
   from /lib64/librustc-e1eeeaf74b9fb842.so
#17 0x00007fffefee227e in rustc_codegen_llvm::base::codegen_crate::h896d6da39d339e78 () from /usr/lib/rustlib/x86_64-unknown-linux-gnu/codegen-backends/librustc_codegen_llvm-llvm.so
#18 0x00007fffefed0fb0 in _$LT$rustc_codegen_llvm..LlvmCodegenBackend$u20$as$u20$rustc_codegen_utils..codegen_backend..CodegenBackend$GT$::codegen_crate::h2a2959de2fd1a074 ()
   from /usr/lib/rustlib/x86_64-unknown-linux-gnu/codegen-backends/librustc_codegen_llvm-llvm.so
#19 0x00007ffff7a043bd in rustc::util::common::time::hf4b2f2c60b9eadb1 () from /lib64/librustc_driver-883e4a4dfa7f2b09.so
#20 0x00007ffff79f8632 in rustc_driver::driver::phase_4_codegen::hbb4992f0a7361e0a () from /lib64/librustc_driver-883e4a4dfa7f2b09.so
#21 0x00007ffff7ac6550 in rustc_driver::driver::compile_input::_$u7b$$u7b$closure$u7d$$u7d$::h5146919408b53f3a () from /lib64/librustc_driver-883e4a4dfa7f2b09.so
#22 0x00007ffff7abce7d in rustc::ty::context::tls::enter_context::h726a082d98371925 () from /lib64/librustc_driver-883e4a4dfa7f2b09.so
---Type <return> to continue, or q <return> to quit---
#23 0x00007ffff7a5b632 in _$LT$std..thread..local..LocalKey$LT$T$GT$$GT$::with::h327208f7823076d2 () from /lib64/librustc_driver-883e4a4dfa7f2b09.so
#24 0x00007ffff7ab8b93 in rustc::ty::context::tls::enter_global::h1a0f9f62e6ec6c7e () from /lib64/librustc_driver-883e4a4dfa7f2b09.so
#25 0x00007ffff79b65af in rustc::ty::context::TyCtxt::create_and_enter::hfed0eeb5a8f5b916 () from /lib64/librustc_driver-883e4a4dfa7f2b09.so
#26 0x00007ffff79f20df in rustc_driver::driver::compile_input::hac0d6ddf92c130fd () from /lib64/librustc_driver-883e4a4dfa7f2b09.so
#27 0x00007ffff7a9bd49 in rustc_driver::run_compiler_with_pool::h4f37bf2af00e71ec () from /lib64/librustc_driver-883e4a4dfa7f2b09.so
#28 0x00007ffff79e25fe in _$LT$scoped_tls..ScopedKey$LT$T$GT$$GT$::set::h75c23511385c6381 () from /lib64/librustc_driver-883e4a4dfa7f2b09.so
#29 0x00007ffff79b9eee in syntax::with_globals::h65f3fbd1cd8182a2 () from /lib64/librustc_driver-883e4a4dfa7f2b09.so
#30 0x00007ffff7a9af76 in rustc_driver::run_compiler::hf793905258323bd5 () from /lib64/librustc_driver-883e4a4dfa7f2b09.so
#31 0x00007ffff799bf9b in _$LT$std..panic..AssertUnwindSafe$LT$F$GT$$u20$as$u20$core..ops..function..FnOnce$LT$$LP$$RP$$GT$$GT$::call_once::h0a7be9576eb1b85a ()
   from /lib64/librustc_driver-883e4a4dfa7f2b09.so
#32 0x00007ffff7690231 in __rust_maybe_catch_panic () from /lib64/libstd-0c1f6d84da50b2aa.so
#33 0x00007ffff7ab02a0 in std::panicking::try::ha710f4cef0c3e130 () from /lib64/librustc_driver-883e4a4dfa7f2b09.so
#34 0x00007ffff7aa85e6 in rustc_driver::main::h83c700c820f7f819 () from /lib64/librustc_driver-883e4a4dfa7f2b09.so
#35 0x0000555555554bc3 in std::rt::lang_start::_$u7b$$u7b$closure$u7d$$u7d$::h49fc9c3ed92a5b46 ()
#36 0x00007ffff76523c3 in std::panicking::try::do_call::h58dbfaf2bf70135a () from /lib64/libstd-0c1f6d84da50b2aa.so
#37 0x00007ffff7690231 in __rust_maybe_catch_panic () from /lib64/libstd-0c1f6d84da50b2aa.so
#38 0x00007ffff7652358 in std::panicking::try::h36c4cc8fa5ecdcf2 () from /lib64/libstd-0c1f6d84da50b2aa.so
#39 0x00007ffff764d4f9 in std::panic::catch_unwind::h510a81003a1968a1 () from /lib64/libstd-0c1f6d84da50b2aa.so
#40 0x00007ffff7646597 in std::rt::lang_start_internal::h504bea112f2cb456 () from /lib64/libstd-0c1f6d84da50b2aa.so
#41 0x0000555555554bb1 in std::rt::lang_start::h085c25b42ad865b3 ()
#42 0x00007ffff7260600 in __libc_start_main () from /lib64/libc.so.6
#43 0x0000555555554a89 in _start ()

-----

Fedora's Rust maintainer Josh Stone helped diagnose this as related to our use of LLVM 3.9, which doesn't support a feature used (by mistake) in Rust 1.28.0:
- In rustc: https://github.com/rust-lang/rust/blob/85da24527adc45adc6b503d92fca2a29331ddab5/src/librustc_codegen_llvm/debuginfo/metadata.rs#L1730-L1733
- LLVM 4+ feature: https://reviews.llvm.org/D24904

I already have a fixed package with a patch provided by Josh, but I'm documenting this bug first for consistency.
Comment 1 Rémi Verschelde 2018-09-15 01:09:51 CEST
rust-1.28.0-1.1.mga6 fixes this issue thanks to this patch by Josh Stone: http://svnweb.mageia.org/packages/updates/6/rust/current/SOURCES/rust-1.28.0-debuginfo-llvm3.9-compat.patch?view=markup

Cauldron is unaffected (recent enough LLVM).

I'm also pushing updates to rust-packaging and rust-srpm-macros for convenience, they're not related to this bugfix, but it keeps us in sync with Cauldron and upstream in case we would decide to package some rust crates and applications in Mageia 6.


Advisory:
=========

Updated rust packages fix crash creating debuginfo metadata

  Mageia 6's rustc compiler is built against the system-wide LLVM 3.9.1, but
  rustc 1.28.0 has an incompatibility with this LLVM version, which leads to a
  segmentation fault when compiling certain crates (e.g. encoding_c).

  This update fixes it by using an alternative call compatible with LLVM 3.9.1.

  Updates are also provided to rust-packaging and rust-srpm-macros for Mageia
  packagers' convenience.

References:

 - https://bugs.mageia.org/show_bug.cgi?id=23574


RPMs in core/updates_testing:
=============================

cargo-1.28.0-1.1.mga6
cargo-doc-1.28.0-1.1.mga6

rust-1.28.0-1.1.mga6
rust-analysis-1.28.0-1.1.mga6
rust-debugger-common-1.28.0-1.1.mga6
rust-doc-1.28.0-1.1.mga6
rust-gdb-1.28.0-1.1.mga6
rust-lldb-1.28.0-1.1.mga6
rust-src-1.28.0-1.1.mga6
rust-std-static-1.28.0-1.1.mga6

rls-preview-0.128.0-1.1.mga6

rustfmt-preview-0.8.2-1.1.mga6

python3-rustcfg-0.0.2-1.mga6
python3-rustcfg-tests-0.0.2-1.mga6

rust-packaging-6-1.mga6
python3-rust2rpm-6-1.mga6

rust-srpm-macros-6-1.mga6


SRPMs in core/updates_testing:
==============================

- rust-1.28.0-1.1.mga6

- python-rustcfg-0.0.2-1.mga6
- rust-packaging-6-1.mga6
- rust-srpm-macros-6-1.mga6


Testing procedure:
==================

Bug 22882 comment 1

Keywords: (none) => has_procedure
Assignee: rverschelde => qa-bugs

Comment 2 Rémi Verschelde 2018-09-15 01:26:09 CEST
Tested successfully on Mageia 6 x86_64, building ripgrep 0.10.0 as well as encoding_c (which used to trigger the crash).

Will attempt to build firefox 60.2.0 tomorrow, if it works/doesn't fail on rust code, this should be good to validate.

Whiteboard: (none) => MGA6-64-OK

Comment 3 Rémi Verschelde 2018-09-18 09:38:25 CEST
Firefox built properly against this fixed rust (failed further down the road but due to a too old hunspell library, unrelated to rust).

Validating, advisory uploaded.

Keywords: (none) => advisory, validated_update
CC: (none) => sysadmin-bugs

Comment 4 Mageia Robot 2018-09-21 01:18:56 CEST
An update for this issue has been pushed to the Mageia Updates repository.

https://advisories.mageia.org/MGAA-2018-0151.html

Resolution: (none) => FIXED
Status: NEW => RESOLVED


Note You need to log in before you can comment on or make changes to this bug.