Skip to content

"".split('.') in build.rs with -Cremark=all causes compiler segfault on ARM #116729

Description

@aldanor
cargo new --bin foo
cd foo
echo "fn main() { _ = \"\".split('.'); }" >build.rs
RUSTFLAGS="-Cremark=all -Cdebuginfo=1" cargo +nightly build --release
  • on M1 macOS (ARM) results in
note: /rustc/.../library/core/src/str/pattern.rs:546:9 gisel-legalize (missed): unable to legalize instruction: G_STORE %26:_(<4 x s8>), %25:_(p0) :: (store (<4 x s8>) into %ir.18, align 8)

error: could not compile `foo` (build script)

Caused by:
  process didn't exit successfully: `rustc --crate-name build_script_build --edition=2021 build.rs --error-format=json --json=diagnostic-rendered-ansi,artifacts,future-incompat --diagnostic-width=323 --crate-type bin --emit=dep-info,link -C embed-bitcode=no -C metadata=01a3112ac4ce4489 -C extra-filename=-01a3112ac4ce4489 --out-dir target/debug/build/foo-01a3112ac4ce4489 -C incremental=foo/target/debug/incremental -L dependency=target/debug/deps -Cremark=all -Cdebuginfo=1`

(signal: 11, SIGSEGV: invalid memory reference)
  • on c7g AWS instance (ARM) results in
note: /rustc/.../library/core/src/str/pattern.rs:543:0 size-info (analysis): AArch64O0PreLegalizerCombiner: Function: _ZN52_$LT$char$u20$as$u20$core..str..pattern..Pattern$GT$13into_searcher17h670b9d7d5e22c8caE: MI Instruction count changed from 43 to 40; Delta: -3

note: /rustc/.../library/core/src/str/pattern.rs:546:9 gisel-legalize (missed): unable to legalize instruction: G_STORE %26:_(<4 x s8>), %25:_(p0) :: (store (<4 x s8>) into %ir.18, align 8)

error: rustc interrupted by SIGSEGV, printing backtrace
  • on c6i AWS instance (x64) compiles fine

(was randomly discovered while trying out cargo-remark which makes use of LLVM remarks)

A few notes of interest:

  • This crashes on both M1 (ARM, macOS) and c7g (ARM, Linux); works on x64 Linux
  • Seems to happen for both debug and release builds
  • Interestingly enough, if you replace '.' with ".", it won't crash

Activity

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

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.E-needs-testCall for participation: An issue has been fixed and does not reproduce, but no test has been added.I-crashIssue: The compiler crashes (SIGSEGV, SIGABRT, etc). Use I-ICE instead when the compiler panics.O-ArmTarget: 32-bit Arm processors (armv6, armv7, thumb...), including 64-bit Arm in AArch32 stateT-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