Skip to content

Rustdoc crashes on broken code #33678

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
Manishearth opened this issue May 17, 2016 · 8 comments
Closed

Rustdoc crashes on broken code #33678

Manishearth opened this issue May 17, 2016 · 8 comments
Labels
E-easy Call for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue. E-mentor Call for participation: This issue has a mentor. Use #t-compiler/help on Zulip for discussion. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue.

Comments

@Manishearth
Copy link
Member

Manishearth commented May 17, 2016

(If you want to work on this, see this comment)

pub struct Foo(String);

impl Iterator for Foo {
  type Item = String;
  /// yo yo
  fn next(&mut self) -> Option<String> {
    Some(self.0)
  }
}

gives

$ RUST_BACKTRACE=1 rustdoc crash.rs
crash.rs:7:10: 7:14 error: cannot move out of borrowed content [E0507]
crash.rs:7     Some(self.0)
                    ^~~~
error: internal compiler error: unexpected panic
note: the compiler unexpectedly panicked. this is a bug.
note: we would appreciate a bug report: https://github.com/rust-lang/rust/blob/master/CONTRIBUTING.md#bug-reports
note: run with `RUST_BACKTRACE=1` for a backtrace
thread 'rustc' panicked at 'called `Option::unwrap()` on a `None` value', ../src/libcore/option.rs:325
stack backtrace:
   1:     0x7fdf2c31c0e0 - std::sys::backtrace::tracing::imp::write::h9fb600083204ae7f
   2:     0x7fdf2c329ceb - std::panicking::default_hook::_$u7b$$u7b$closure$u7d$$u7d$::hca543c34f11229ac
   3:     0x7fdf2c32988c - std::panicking::default_hook::hc2c969e7453d080c
   4:     0x7fdf2c2ef2b8 - std::panicking::rust_panic_with_hook::hfe203e3083c2b544
   5:     0x7fdf2c329f31 - std::panicking::begin_panic::h4889569716505182
   6:     0x7fdf2c2f135a - std::panicking::begin_panic_fmt::h484cd47786497f03
   7:     0x7fdf2c329ece - rust_begin_unwind
   8:     0x7fdf2c3739bf - core::panicking::panic_fmt::h257ceb0aa351d801
   9:     0x7fdf2c3744b8 - core::panicking::panic::h4bb1497076d04ab9
  10:     0x7fdf2c86f41d - rustdoc::core::run_core::hb4f6a9182e0af11b
  11:     0x7fdf2c867835 - std::panicking::try::call::h0edabd498a0d5785
  12:     0x7fdf2c33848b - __rust_try
  13:     0x7fdf2c33842e - __rust_maybe_catch_panic
  14:     0x7fdf2c8695c5 - _<F as std..boxed..FnBox<A>>::call_box::he57876f7aa4d18c3
  15:     0x7fdf2c327df4 - std::sys::thread::Thread::new::thread_start::h6f266e069bf4ec2b
  16:     0x7fdf244206a9 - start_thread
  17:     0x7fdf2bf75eec - clone
  18:                0x0 - <unknown>
@Manishearth Manishearth added T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ labels May 17, 2016
@Manishearth
Copy link
Member Author

This is happening because of this line and the subsequent unwrap.

It seems intentional?

@Manishearth
Copy link
Member Author

Ah, it's a result of https://github.com/rust-lang/rust/pull/31507/files. We should make it abort or propagate errors instead

@Manishearth Manishearth added E-easy Call for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue. E-mentor Call for participation: This issue has a mentor. Use #t-compiler/help on Zulip for discussion. labels May 17, 2016
@Manishearth
Copy link
Member Author

To fix this bug, we should replace the return None here with a sess.fatal("Compilation failed, aborting rustdoc") or something.

Please let me know if you want to work on this!

@Manishearth
Copy link
Member Author

I use make -j4 ./x86_64-unknown-linux-gnu/stage2/bin/rustdoc (target may vary) to build this, btw.

@crimsun
Copy link

crimsun commented May 17, 2016

@Manishearth Would love to assist with this low-hanging fruit; pls see my local branch. I'm very new to Rust, and in the change I retained similar wording to line 151.

Here is the output from a local build using the above crash.rs's contents:

$ ./bin/rustdoc -V && RUST_BACKTRACE=1 ./bin/rustdoc ../test.rs 
rustdoc 1.10.0-dev (fa5597900 2016-05-17)
../test.rs:7:10: 7:14 error: cannot move out of borrowed content [E0507]
../test.rs:7     Some(self.0)
                      ^~~~
error: Compilation aborted in rustdoc!

Welcome your guidance and comments.

@Manishearth
Copy link
Member Author

That's the first step, we should also remove the unwrap and the Option, https://github.com/crimsun/rust/blob/fa55979005c8acbff651037ee3e98325ad7f1552/src/librustdoc/core.rs#L209 should no longer use Some and the unwrap after that can be removed.

I prefer "Compilation failed, aborting rustdoc", since the mental model is not that rustdoc itself compiles things.

@crimsun
Copy link

crimsun commented May 17, 2016

Thank you! I've updated the branch based on your comments with nearly identical output:

$ ./bin/rustdoc -V && RUST_BACKTRACE=1 ./bin/rustdoc ../test.rs 
rustdoc 1.10.0-dev (fa5597900 2016-05-17)
../test.rs:7:10: 7:14 error: cannot move out of borrowed content [E0507]
../test.rs:7     Some(self.0)
                      ^~~~
error: Compilation failed, aborting rustdoc

@Manishearth
Copy link
Member Author

Looks good, squash the commits and make a pull request!

crimsun pushed a commit to crimsun/rust that referenced this issue May 17, 2016
…pping.

Removed Option use and comment to match.
bors added a commit that referenced this issue May 19, 2016
Resolved rustdoc crash (#33678) by aborting instead of unwrapping.

Also removed Option use and comment to match.

Fixes #33678
critiqjo pushed a commit to critiqjo/rustdoc that referenced this issue Dec 16, 2016
Resolved rustdoc crash (#33678) by aborting instead of unwrapping.

Also removed Option use and comment to match.

Fixes rust-lang/rust#33678
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
E-easy Call for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue. E-mentor Call for participation: This issue has a mentor. Use #t-compiler/help on Zulip for discussion. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue.
Projects
None yet
Development

No branches or pull requests

2 participants