Skip to content
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

Parse panic doesn't seem to be caught? #3239

Closed
Xanewok opened this issue Dec 8, 2018 · 2 comments
Closed

Parse panic doesn't seem to be caught? #3239

Xanewok opened this issue Dec 8, 2018 · 2 comments
Labels
bug Panic, non-idempotency, invalid code, etc.

Comments

@Xanewok
Copy link
Member

Xanewok commented Dec 8, 2018

This showed up as a part of RLS test failure. The string in question is

/// Bar variant\nBar,\n/// Baz variant\nBaz\n}\n\n/// Bar struct\npub struct Bar<T>{}

Repro: https://github.com/Xanewok/simple_fmt/tree/master

I'd expect the parser to catch possible panics:

let result = catch_unwind(move || parser.0.parse_crate_mod());

however it seems to be an aborting panic? (no backtrace)

Is this completely on rustc side or can we do something here to not abort on parse error?

@Xanewok
Copy link
Member Author

Xanewok commented Dec 8, 2018

The panic is successfully caught when parsing bare { but not with }

The error for } is emitted at https://github.com/rust-lang/rust/blob/bdef56a3245460d1fb28c3b4d8ac4b17373c66ce/src/libsyntax/parse/lexer/tokentrees.rs#L169.

Digging deeper it seems that (can't see other suspiciously panicking code paths):

  1. parse_all_token_trees is called when calling maybe_file_to_stream in
  2. source_file_to_stream, which invokes
  3. panictry_buffer! raising
  4. FatalError

Is this that can be fixed in the parser so we can catch parse error panics? (cc @estebank who I know worked on the diagnostics wrt braces, delimiters)

@Xanewok
Copy link
Member Author

Xanewok commented Dec 8, 2018

It seems that creating parser

Input::Text(text) => parse::new_parser_from_source_str(

can panic as well (new_parser_from_source_str). I guess we should also catch the error here or use maybe_new_parser_from_source_str here instead.

@topecongiro topecongiro added the bug Panic, non-idempotency, invalid code, etc. label Dec 12, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Panic, non-idempotency, invalid code, etc.
Projects
None yet
Development

No branches or pull requests

2 participants