Skip to content

Crashes in debug code - related to %? #7860

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
msullivan opened this issue Jul 17, 2013 · 1 comment
Closed

Crashes in debug code - related to %? #7860

msullivan opened this issue Jul 17, 2013 · 1 comment
Labels
A-codegen Area: Code generation I-crash Issue: The compiler crashes (SIGSEGV, SIGABRT, etc). Use I-ICE instead when the compiler panics.

Comments

@msullivan
Copy link
Contributor

When debugging is enabled for the rustc::middle::trans::meth module, and a program using trait bounded type params is compiled, there is a segfault in the string formatting. (Actually, it is nondeterministic; sometimes there is an assertion failure.)

The particular line that is triggering the failure is

debug!("rcvr_substs=%?", rcvr_substs.map(|t| bcx.ty_to_str(*t)));

(This isn't anything like the nicest way to formulate this debug output, but it should of course still work...)

I have not yet managed to produce a nice small test case, but I can trigger it with the following program (any program that uses trait parameterized functions should do, though)

fn print_thing<T: ToStr>(x: &T) {
    println(x.to_str());
}

fn main() {
    print_thing(&());
}

and the command RUST_LOG=rustc=1,rustc::middle::trans::meth ./x86_64-unknown-linux-gnu/stage1/bin/rustc simple-parametric.rs

I bisected and the commit that introduces the failure is e118555.

Example failure output

rust: ~"trans_method_callee(callee_id=11, this=expr(10: x), mentry=method_map_entry {self_arg: &T, explicit_self: sty_region(None, m_imm), origin: method_param({crate: 1, node: 48446},0,0,0)})"
rust: ~"origin=method_param({trait_id: {crate: 1, node: 48446}, method_num: 0, param_num: 0, bound_num: 0})"
rust: ~"method_ty_param_count: m_id: {crate: 1, node: 48462}, i_id: {crate: 1, node: 48464}"
Segmentation fault (core dumped)
@msullivan
Copy link
Contributor Author

Ah! The problem is a mismatch between the code generated by the bootstrap compiler and the library code for %?. The stage2 compiler works just fine, above, and the following code, compiled with the stage0 compiler, segfaults

fn main() {
    error!("%?", ~[1]);
}

@thestinger said he has a fix. A snapshot will also fix it.

flip1995 pushed a commit to flip1995/rust that referenced this issue Nov 4, 2021
Fix `question_mark` FP on custom error type

Closes rust-lang#7859

rust-lang#7840 aims to ignore `question_mark` when the return type is custom, which is [covered here](https://github.com/rust-lang/rust-clippy/blob/df65291edd6b89a241fed483ab165c32df468746/tests/ui/question_mark.rs#L144-L149). But this fails when there is a call in conditional predicate

changelog: [`question_mark`] Fix false positive when there is call in conditional predicate
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-codegen Area: Code generation I-crash Issue: The compiler crashes (SIGSEGV, SIGABRT, etc). Use I-ICE instead when the compiler panics.
Projects
None yet
Development

No branches or pull requests

1 participant