`poky`-patched cargo segfaults on `cargo build --bin helloworld`
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 119k
- Forks
- 16.1k
- PR merge metrics
- PR metrics pending
Description
cargo build for a simple hello world program gives seg fault when built in sdk environment using poky sources.
This was first observed in rustc v1.78 and continued in v1.79 and v1.80 also.
(Note: There's no change in the process of sdk build env when tested between the versions).
rustc --version --verbose:
rustc 1.79.0 (129f3b996 2024-06-10) (built from a source tarball)
binary: rustc
commit-hash: 129f3b9964af4d4a709d1383930ade12dfe7c081
commit-date: 2024-06-10
host: x86_64-pokysdk-linux-gnu
release: 1.79.0
LLVM version: 18.1.7
Error output
error: the compiler unexpectedly panicked. this is a bug.
note: we would appreciate a bug report: https://github.com/rust-lang/rust/issues/new?labels=C-bug%2C+I-ICE%2C+T-compiler&template=ice.md
note: rustc 1.79.0 (129f3b996 2024-06-10) (built from a source tarball) running on x86_64-pokysdk-linux-gnu
note: compiler flags: --crate-type bin -C embed-bitcode=no -C debuginfo=2 -C incremental=[REDACTED]
note: some of the compiler flags provided by cargo are hidden
query stack during panic:
end of query stack
error: rustc interrupted by SIGSEGV, printing backtrace
The backtrace generated is same for with "RUST_BACKTRACE=1" and "RUST_BACKTRACE=full".
I suspect the following out of bounds index access is the main reason for seg fault here.
at compiler/rustc_metadata/src/creader.rs:193:31:
index out of bounds: the len is 20 but the index is 60747757
https://github.com/rust-lang/rust/commit/fbc9b94064c611f341d613ce14d321b267b3c298 and https://github.com/rust-lang/rust/commit/0025c9cc5001c194ac1f8ce4824d93a0efbe5c18 are the recent commits related to this.
Maybe @oli-obk can help to understand the error better?
Backtrace
{"$message_type":"artifact","artifact":"/home/poky/build/tmp/work/qemux86_64-poky-linux/core-image-sato/1.0/testimage-sdk/hello/target/debug/build/hello-69a92b98b70371ba/build_script_build-69a92b98b70371ba.d","emit":"dep-info"}
thread 'rustc' panicked at compiler/rustc_metadata/src/creader.rs:193:31:
index out of bounds: the len is 20 but the index is 60747757
stack backtrace:
0: 0x7fa9a2bcf31f - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::hdd8826f6b9d3bb6e
1: 0x7fa9a2c0246b - core::fmt::write::hce77028645369722
2: 0x7fa9a2bca2ce - <unknown>
3: 0x7fa9a2bcf0ee - <unknown>
4: 0x7fa9a2bb889a - <unknown>
5: 0x7fa9a2bb8594 - std::panicking::default_hook::h49af0c7febe67f8d
6: 0x7fa9a37e7187 - <unknown>
7: 0x7fa9a2bb90e9 - std::panicking::rust_panic_with_hook::h14a0ca211eb21fbf
8: 0x7fa9a2bcf6e2 - <unknown>
9: 0x7fa9a2bcf529 - <unknown>
10: 0x7fa9a2bb8cc6 - rust_begin_unwind
11: 0x7fa9a2b71422 - core::panicking::panic_fmt::hb4b7de66d883fcc4
12: 0x7fa9a2b715f6 - core::panicking::panic_bounds_check::h4eecb12f9bb341c4
13: 0x7fa9a83c8ffd - <rustc_metadata[acbd193db608c71e]::creader::CStore as rustc_session[2c1f89e6504c4cfe]::cstore::CrateStore>::stable_crate_id
14: 0x7fa9a89931e9 - <unknown>
15: 0x7fa9a89978ed - <rustc_middle[fd6644fcde453e4f]::query::on_disk_cache::OnDiskCache>::serialize
16: 0x7fa9a8891541 - <rustc_middle[fd6644fcde453e4f]::ty::context::TyCtxt>::serialize_query_result_cache
17: 0x7fa9a826b2ea - <unknown>
18: 0x7fa9a82640cc - <unknown>
19: 0x7fa9a826b5c0 - <unknown>
20: 0x7fa9a827c0f1 - <unknown>
21: 0x7fa9a822acd9 - rustc_incremental[7e9745f68514030c]::persist::save::save_dep_graph
22: 0x7fa9a37f6045 - <unknown>
23: 0x7fa9a37a30bd - <unknown>
24: 0x7fa9a37c7ba7 - <unknown>
25: 0x7fa9a37c968d - <unknown>
26: 0x7fa9a2bbc73b - <unknown>
27: 0x7fa9a29c9b62 - <unknown>
28: 0x7fa9a2a4463c - <unknown>
29: 0x0 - <unknown>
error: the compiler unexpectedly panicked. this is a bug.
note: we would appreciate a bug report: https://github.com/rust-lang/rust/issues/new?labels=C-bug%2C+I-ICE%2C+T-compiler&template=ice.md
note: rustc 1.79.0 (129f3b996 2024-06-10) (built from a source tarball) running on x86_64-pokysdk-linux-gnu
note: compiler flags: --crate-type bin -C embed-bitcode=no -C debuginfo=2 -C incremental=[REDACTED]
note: some of the compiler flags provided by cargo are hidden
query stack during panic:
end of query stack
error: rustc interrupted by SIGSEGV, printing backtrace
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Reproduce cargo build --bin helloworld in the poky SDK environment using the reported Rust versions and compiler flags. Start at compiler/rustc_metadata/src/creader.rs:193 and review the linked commits, then verify the fix by confirming the build completes without the index-out-of-bounds panic or SIGSEGV.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- compilers
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100