Skip to content

Compiler crashes when trying to compile core with static relocation model #58563

@Serentty

Description

@Serentty

I'm trying to compile Rust code for MS-DOS, and have written a custom target. In this target I have the relocation model set to static, since including that kind of information is impossible in a COM executable (which I'm using because it's trivial to generate them with linker scripts, unlike MZ executables). However, when compiling core, the compiler simply crashes with a segmentation fault. It seems to get most of the way through compiling core, as it actually crashes during or after LTO (I can't really tell). Here is the last part of the output of running the build with RUST_LOG=debug.

 INFO 2019-02-18T19:19:11Z: rustc_codegen_ssa::base: codegen_instance(<alloc::AllocErr as fmt::Debug>::fmt)
 INFO 2019-02-18T19:19:11Z: rustc_codegen_ssa::base: codegen_instance(<alloc::CannotReallocInPlace as fmt::Debug>::fmt)
 INFO 2019-02-18T19:19:11Z: rustc_codegen_ssa::base: codegen_instance(mem::size_of::<u8>)
 INFO 2019-02-18T19:19:11Z: rustc_codegen_ssa::base: codegen_instance(mem::size_of::<fmt::ArgumentV1>)
 INFO 2019-02-18T19:19:11Z: rustc_codegen_ssa::base: codegen_instance(mem::size_of::<fmt::rt::v1::Argument>)
 INFO 2019-02-18T19:19:11Z: rustc_codegen_ssa::base: codegen_instance(mem::size_of::<&str>)
 INFO 2019-02-18T19:19:11Z: rustc_codegen_ssa::base: codegen_instance(mem::size_of::<u32>)
Post-codegen
Ty interner             total           ty region  both
    Adt               :   7819  8.6%,  0.2%   0.0%  0.0%
    Array             :   1969  2.2%,  0.0%   0.0%  0.0%
    Slice             :    222  0.2%,  0.0%   0.0%  0.0%
    RawPtr            :    222  0.2%,  0.0%   0.0%  0.0%
    Ref               :  42210 46.3%,  0.1%   0.0%  0.0%
    FnDef             :  21176 23.2%,  0.0%   0.0%  0.0%
    FnPtr             :   8613  9.4%,  0.0%   0.0%  0.0%
    Placeholder       :      0  0.0%,  0.0%   0.0%  0.0%
    Generator         :      0  0.0%,  0.0%   0.0%  0.0%
    GeneratorWitness  :      0  0.0%,  0.0%   0.0%  0.0%
    Dynamic           :    253  0.3%,  0.0%   0.0%  0.0%
    Closure           :   1799  2.0%,  0.2%   0.0%  0.0%
    Tuple             :   2164  2.4%,  0.2%   0.0%  0.0%
    Bound             :     17  0.0%,  0.0%   0.0%  0.0%
    Param             :    240  0.3%,  0.0%   0.0%  0.0%
    Infer             :     16  0.0%,  0.0%   0.0%  0.0%
    UnnormalizedProjection:      0  0.0%,  0.0%   0.0%  0.0%
    Projection        :   4429  4.9%,  0.0%   0.0%  0.0%
    Opaque            :      0  0.0%,  0.0%   0.0%  0.0%
    Foreign           :      1  0.0%,  0.0%   0.0%  0.0%
                  total  91150         0.8%   0.0%  0.0%
Substs interner: #65877
Region interner: #30211
Stability interner: #322
Allocation interner: #1060
Layout interner: #411
 INFO 2019-02-18T19:19:11Z: rustc_codegen_llvm::back::lto: 641 symbols to preserve in this crate
 INFO 2019-02-18T19:19:11Z: rustc_codegen_llvm::back::lto: going for that thin, thin LTO
 INFO 2019-02-18T19:19:11Z: rustc_codegen_llvm::back::lto: local module: 0 - core.1v8m1ai7-cgu.15
 INFO 2019-02-18T19:19:11Z: rustc_codegen_llvm::back::lto: local module: 1 - core.1v8m1ai7-cgu.0
 INFO 2019-02-18T19:19:11Z: rustc_codegen_llvm::back::lto: local module: 2 - core.1v8m1ai7-cgu.2
 INFO 2019-02-18T19:19:11Z: rustc_codegen_llvm::back::lto: local module: 3 - core.1v8m1ai7-cgu.5
 INFO 2019-02-18T19:19:11Z: rustc_codegen_llvm::back::lto: local module: 4 - core.1v8m1ai7-cgu.1
 INFO 2019-02-18T19:19:11Z: rustc_codegen_llvm::back::lto: local module: 5 - core.1v8m1ai7-cgu.6
 INFO 2019-02-18T19:19:11Z: rustc_codegen_llvm::back::lto: local module: 6 - core.1v8m1ai7-cgu.7
 INFO 2019-02-18T19:19:11Z: rustc_codegen_llvm::back::lto: local module: 7 - core.1v8m1ai7-cgu.14
 INFO 2019-02-18T19:19:11Z: rustc_codegen_llvm::back::lto: local module: 8 - core.1v8m1ai7-cgu.3
 INFO 2019-02-18T19:19:11Z: rustc_codegen_llvm::back::lto: local module: 9 - core.1v8m1ai7-cgu.9
 INFO 2019-02-18T19:19:11Z: rustc_codegen_llvm::back::lto: local module: 10 - core.1v8m1ai7-cgu.8
 INFO 2019-02-18T19:19:11Z: rustc_codegen_llvm::back::lto: local module: 11 - core.1v8m1ai7-cgu.11
 INFO 2019-02-18T19:19:11Z: rustc_codegen_llvm::back::lto: local module: 12 - core.1v8m1ai7-cgu.12
 INFO 2019-02-18T19:19:11Z: rustc_codegen_llvm::back::lto: local module: 13 - core.1v8m1ai7-cgu.4
 INFO 2019-02-18T19:19:11Z: rustc_codegen_llvm::back::lto: local module: 14 - core.1v8m1ai7-cgu.13
 INFO 2019-02-18T19:19:11Z: rustc_codegen_llvm::back::lto: local module: 15 - core.1v8m1ai7-cgu.10
 INFO 2019-02-18T19:19:11Z: rustc_codegen_llvm::back::lto: thin LTO data created
 INFO 2019-02-18T19:19:11Z: rustc_codegen_llvm::back::lto: thin LTO import map loaded
 INFO 2019-02-18T19:19:11Z: rustc_codegen_llvm::back::lto: checking which modules can be-reused and which have to be re-optimized.
 INFO 2019-02-18T19:19:11Z: rustc_codegen_llvm::back::lto:  - core.1v8m1ai7-cgu.15: re-compiled
 INFO 2019-02-18T19:19:11Z: rustc_codegen_llvm::back::lto:  - core.1v8m1ai7-cgu.0: re-compiled
 INFO 2019-02-18T19:19:11Z: rustc_codegen_llvm::back::lto:  - core.1v8m1ai7-cgu.2: re-compiled
 INFO 2019-02-18T19:19:11Z: rustc_codegen_llvm::back::lto:  - core.1v8m1ai7-cgu.5: re-compiled
 INFO 2019-02-18T19:19:11Z: rustc_codegen_llvm::back::lto:  - core.1v8m1ai7-cgu.1: re-compiled
 INFO 2019-02-18T19:19:11Z: rustc_codegen_llvm::back::lto:  - core.1v8m1ai7-cgu.6: re-compiled
 INFO 2019-02-18T19:19:11Z: rustc_codegen_llvm::back::lto:  - core.1v8m1ai7-cgu.7: re-compiled
 INFO 2019-02-18T19:19:11Z: rustc_codegen_llvm::back::lto:  - core.1v8m1ai7-cgu.14: re-compiled
 INFO 2019-02-18T19:19:11Z: rustc_codegen_llvm::back::lto:  - core.1v8m1ai7-cgu.3: re-compiled
 INFO 2019-02-18T19:19:11Z: rustc_codegen_llvm::back::lto:  - core.1v8m1ai7-cgu.9: re-compiled
 INFO 2019-02-18T19:19:11Z: rustc_codegen_llvm::back::lto:  - core.1v8m1ai7-cgu.8: re-compiled
 INFO 2019-02-18T19:19:11Z: rustc_codegen_llvm::back::lto:  - core.1v8m1ai7-cgu.11: re-compiled
 INFO 2019-02-18T19:19:11Z: rustc_codegen_llvm::back::lto:  - core.1v8m1ai7-cgu.12: re-compiled
 INFO 2019-02-18T19:19:11Z: rustc_codegen_llvm::back::lto:  - core.1v8m1ai7-cgu.4: re-compiled
 INFO 2019-02-18T19:19:11Z: rustc_codegen_llvm::back::lto:  - core.1v8m1ai7-cgu.13: re-compiled
 INFO 2019-02-18T19:19:11Z: rustc_codegen_llvm::back::lto:  - core.1v8m1ai7-cgu.10: re-compiled
 INFO 2019-02-18T19:19:11Z: rustc_codegen_llvm::back::lto: running thin lto passes over core.1v8m1ai7-cgu.11
 INFO 2019-02-18T19:19:11Z: rustc_codegen_llvm::back::lto: running thin lto passes over core.1v8m1ai7-cgu.15
[2019-02-18T19:19:20Z INFO  cargo::core::compiler::job_queue] end: core v0.0.0 (/home/seren/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/src/libcore) => Target(lib)/Profile(release) => Target
[2019-02-18T19:19:20Z INFO  cargo::util::rustc] updated rustc info cache
[2019-02-18T19:19:20Z DEBUG cargo] exit_with_error; err=CliError { error: Some(ProcessError { desc: "process didn\'t exit successfully: `rustc --crate-name core /home/seren/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/src/libcore/lib.rs --color always --crate-type lib --emit=dep-info,link -C opt-level=3 -C panic=abort -C metadata=83dd25ed9bb01753 -C extra-filename=-83dd25ed9bb01753 --out-dir /tmp/xargo.Ts6CcVcYOJgB/target/dos/release/deps --target /home/seren/Code/Rust/dos/dos.json -L dependency=/tmp/xargo.Ts6CcVcYOJgB/target/dos/release/deps -L dependency=/tmp/xargo.Ts6CcVcYOJgB/target/release/deps` (signal: 11, SIGSEGV: invalid memory reference)", exit: Some(ExitStatus(ExitStatus(139))), output: None }

Could not compile `core`.), unknown: false, exit_code: 101 }
error: Could not compile `core`.

Caused by:
  process didn't exit successfully: `rustc --crate-name core /home/seren/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/src/libcore/lib.rs --color always --crate-type lib --emit=dep-info,link -C opt-level=3 -C panic=abort -C metadata=83dd25ed9bb01753 -C extra-filename=-83dd25ed9bb01753 --out-dir /tmp/xargo.Ts6CcVcYOJgB/target/dos/release/deps --target /home/seren/Code/Rust/dos/dos.json -L dependency=/tmp/xargo.Ts6CcVcYOJgB/target/dos/release/deps -L dependency=/tmp/xargo.Ts6CcVcYOJgB/target/release/deps` (signal: 11, SIGSEGV: invalid memory reference)
error: `"cargo" "rustc" "-p" "alloc" "--release" "--manifest-path" "/tmp/xargo.Ts6CcVcYOJgB/Cargo.toml" "--target" "dos.json" "--" "-Z" "force-unstable-if-unmarked"` failed with exit code: Some(101)
note: run with `RUST_BACKTRACE=1` for a backtrace

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-LLVMArea: Code generation parts specific to LLVM. Both correctness bugs and optimization-related issues.C-bugCategory: This is a bug.I-crashIssue: The compiler crashes (SIGSEGV, SIGABRT, etc). Use I-ICE instead when the compiler panics.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions