`#[link(kind = "static", name = "c")]` segfaults on run
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 119k
- Forks
- 16.1k
- PR merge metrics
- PR metrics pending
Description
While working on https://github.com/rust-lang/rust/pull/123974, I had a failure when running doctests of the unstable book. Rustdoc generates this code:
#![allow(unused_extern_crates)]
#![allow(internal_features)]
#![feature(test)]
#![feature(rustc_attrs)]
#![feature(coverage_attribute)]
#![feature(link_arg_attribute)]
#![allow(unused)]
extern crate test;
mod __doctest_0 {
fn main() {
#[link(kind = "link-arg", name = "--start-group")]
#[link(kind = "static", name = "c")] // Causing the segfault
#[link(kind = "static", name = "gcc")]
#[link(kind = "link-arg", name = "--end-group")]
extern "C" {}
}
#[rustc_test_marker = "/home/imperio/rust/rust/src/doc/unstable-book/src/language-features/link-arg-attribute.md - The_tracking_issue_for_this_feature_is__ (line 11)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("/home/imperio/rust/rust/src/doc/unstable-book/src/language-features/link-arg-attribute.md - The_tracking_issue_for_this_feature_is__ (line 11)"),
ignore: false,
ignore_message: None,
source_file: "_home_imperio_rust_rust_src_doc_unstable_book_src_language_features_link_arg_attribute_md",
start_line: 11,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: true,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(Ok::<(), String>(())),
)
};
}
#[rustc_main]
#[coverage(off)]
fn main() {
test::test_main(&["rustdoctest".to_string(),], vec![__doctest_0::TEST], None);
}
If you compile and run this program (on linux x86_64), it'll segfault. Commenting #[link(kind = "static", name = "c")] will make it run without problem.
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
Start by reproducing the generated program on Linux x86_64, comparing runs with and without #[link(kind = "static", name = "c")]. Then inspect rustdoc's generated doctest output and the compiler's handling of the link attributes; done means the doctest runs without a segmentation fault while retaining the link arguments.
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
- 38/100