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

panicked at 'Failed to parse float after checks: ParseFloatError { kind: Invalid }' #1403

Closed
charlesxsh opened this issue Jul 16, 2021 · 3 comments
Assignees
Labels
bug Something isn't working

Comments

@charlesxsh
Copy link

Describe the bug
thread 'main' panicked at 'Failed to parse float after checks: ParseFloatError { kind: Invalid }'

To Reproduce
Input:
{eZa$*${eZa$*${e74n|44|444,446444444444444444.6444444444446444444444644444444464444444444444444444444444444444444444444444444444444444444444444444444444444444444444444644444464464444444444444464444444446444444444444444444444444444444444444446444444

Code:

fn main(){
    // let data = input

    let mut context = Context::new();
    context.eval(data);

}

Output

thread 'main' panicked at 'Failed to parse float after checks: ParseFloatError { kind: Invalid }', /home/xsh/.cargo/registry/src/github.aaakk.us.kg-1ecc6299db9ec823/Boa-0.11.0/src/syntax/lexer/number.rs:384:50
stack backtrace:
   0: <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt
   1: core::fmt::write
   2: std::io::Write::write_fmt
   3: std::panicking::default_hook::{{closure}}
   4: std::panicking::default_hook
   5: std::panicking::rust_panic_with_hook
   6: rust_begin_unwind
   7: core::panicking::panic_fmt
   8: core::result::unwrap_failed
   9: core::result::Result<T,E>::expect
             at /home/xsh/code/rust-compiler/src/libcore/result.rs:963
  10: <boa::syntax::lexer::number::NumberLiteral as boa::syntax::lexer::Tokenizer<R>>::lex
             at /home/xsh/.cargo/registry/src/github.aaakk.us.kg-1ecc6299db9ec823/Boa-0.11.0/src/syntax/lexer/number.rs:384
  11: boa::syntax::lexer::Lexer<R>::next
             at /home/xsh/.cargo/registry/src/github.aaakk.us.kg-1ecc6299db9ec823/Boa-0.11.0/src/syntax/lexer/mod.rs:250
  12: boa::syntax::parser::cursor::buffered_lexer::BufferedLexer<R>::fill
             at /home/xsh/.cargo/registry/src/github.aaakk.us.kg-1ecc6299db9ec823/Boa-0.11.0/src/syntax/parser/cursor/buffered_lexer/mod.rs:134
  13: boa::syntax::parser::cursor::buffered_lexer::BufferedLexer<R>::peek
             at /home/xsh/.cargo/registry/src/github.aaakk.us.kg-1ecc6299db9ec823/Boa-0.11.0/src/syntax/parser/cursor/buffered_lexer/mod.rs:219
  14: boa::syntax::parser::cursor::Cursor<R>::peek
             at /home/xsh/.cargo/registry/src/github.aaakk.us.kg-1ecc6299db9ec823/Boa-0.11.0/src/syntax/parser/cursor/mod.rs:61
  15: <boa::syntax::parser::expression::assignment::AssignmentExpression as boa::syntax::parser::TokenParser<R>>::parse
             at /home/xsh/.cargo/registry/src/github.aaakk.us.kg-1ecc6299db9ec823/Boa-0.11.0/src/syntax/parser/expression/assignment/mod.rs:86
  16: <boa::syntax::parser::expression::Expression as boa::syntax::parser::TokenParser<R>>::parse
             at /home/xsh/.cargo/registry/src/github.aaakk.us.kg-1ecc6299db9ec823/Boa-0.11.0/src/syntax/parser/expression/mod.rs:90
  17: <boa::syntax::parser::expression::primary::template::TemplateLiteral as boa::syntax::parser::TokenParser<R>>::parse
             at /home/xsh/.cargo/registry/src/github.aaakk.us.kg-1ecc6299db9ec823/Boa-0.11.0/src/syntax/parser/expression/primary/template/mod.rs:68
  18: <boa::syntax::parser::expression::primary::PrimaryExpression as boa::syntax::parser::TokenParser<R>>::parse
             at /home/xsh/.cargo/registry/src/github.aaakk.us.kg-1ecc6299db9ec823/Boa-0.11.0/src/syntax/parser/expression/primary/mod.rs:141
  19: <boa::syntax::parser::expression::left_hand_side::member::MemberExpression as boa::syntax::parser::TokenParser<R>>::parse
             at /home/xsh/.cargo/registry/src/github.aaakk.us.kg-1ecc6299db9ec823/Boa-0.11.0/src/syntax/parser/expression/left_hand_side/member.rs:77
  20: <boa::syntax::parser::expression::left_hand_side::LeftHandSideExpression as boa::syntax::parser::TokenParser<R>>::parse
             at /home/xsh/.cargo/registry/src/github.aaakk.us.kg-1ecc6299db9ec823/Boa-0.11.0/src/syntax/parser/expression/left_hand_side/mod.rs:67
  21: <boa::syntax::parser::expression::update::UpdateExpression as boa::syntax::parser::TokenParser<R>>::parse
             at /home/xsh/.cargo/registry/src/github.aaakk.us.kg-1ecc6299db9ec823/Boa-0.11.0/src/syntax/parser/expression/update.rs:79
  22: <boa::syntax::parser::expression::assignment::exponentiation::ExponentiationExpression as boa::syntax::parser::TokenParser<R>>::parse
             at /home/xsh/.cargo/registry/src/github.aaakk.us.kg-1ecc6299db9ec823/Boa-0.11.0/src/syntax/parser/expression/assignment/exponentiation.rs:91
  23: <boa::syntax::parser::expression::MultiplicativeExpression as boa::syntax::parser::TokenParser<R>>::parse
             at /home/xsh/.cargo/registry/src/github.aaakk.us.kg-1ecc6299db9ec823/Boa-0.11.0/src/syntax/parser/expression/mod.rs:90
  24: <boa::syntax::parser::expression::AdditiveExpression as boa::syntax::parser::TokenParser<R>>::parse
             at /home/xsh/.cargo/registry/src/github.aaakk.us.kg-1ecc6299db9ec823/Boa-0.11.0/src/syntax/parser/expression/mod.rs:82
  25: <boa::syntax::parser::expression::ShiftExpression as boa::syntax::parser::TokenParser<R>>::parse
             at /home/xsh/.cargo/registry/src/github.aaakk.us.kg-1ecc6299db9ec823/Boa-0.11.0/src/syntax/parser/expression/mod.rs:82
  26: <boa::syntax::parser::expression::RelationalExpression as boa::syntax::parser::TokenParser<R>>::parse
             at /home/xsh/.cargo/registry/src/github.aaakk.us.kg-1ecc6299db9ec823/Boa-0.11.0/src/syntax/parser/expression/mod.rs:489
  27: <boa::syntax::parser::expression::EqualityExpression as boa::syntax::parser::TokenParser<R>>::parse
             at /home/xsh/.cargo/registry/src/github.aaakk.us.kg-1ecc6299db9ec823/Boa-0.11.0/src/syntax/parser/expression/mod.rs:82
  28: <boa::syntax::parser::expression::BitwiseANDExpression as boa::syntax::parser::TokenParser<R>>::parse
             at /home/xsh/.cargo/registry/src/github.aaakk.us.kg-1ecc6299db9ec823/Boa-0.11.0/src/syntax/parser/expression/mod.rs:82
  29: <boa::syntax::parser::expression::BitwiseXORExpression as boa::syntax::parser::TokenParser<R>>::parse
             at /home/xsh/.cargo/registry/src/github.aaakk.us.kg-1ecc6299db9ec823/Boa-0.11.0/src/syntax/parser/expression/mod.rs:82
  30: <boa::syntax::parser::expression::BitwiseORExpression as boa::syntax::parser::TokenParser<R>>::parse
             at /home/xsh/.cargo/registry/src/github.aaakk.us.kg-1ecc6299db9ec823/Boa-0.11.0/src/syntax/parser/expression/mod.rs:82
  31: <boa::syntax::parser::expression::ShortCircuitExpression as boa::syntax::parser::TokenParser<R>>::parse
             at /home/xsh/.cargo/registry/src/github.aaakk.us.kg-1ecc6299db9ec823/Boa-0.11.0/src/syntax/parser/expression/mod.rs:218
  32: <boa::syntax::parser::expression::assignment::conditional::ConditionalExpression as boa::syntax::parser::TokenParser<R>>::parse
             at /home/xsh/.cargo/registry/src/github.aaakk.us.kg-1ecc6299db9ec823/Boa-0.11.0/src/syntax/parser/expression/assignment/conditional.rs:68
  33: <boa::syntax::parser::expression::assignment::AssignmentExpression as boa::syntax::parser::TokenParser<R>>::parse
             at /home/xsh/.cargo/registry/src/github.aaakk.us.kg-1ecc6299db9ec823/Boa-0.11.0/src/syntax/parser/expression/assignment/mod.rs:175
  34: <boa::syntax::parser::expression::Expression as boa::syntax::parser::TokenParser<R>>::parse
             at /home/xsh/.cargo/registry/src/github.aaakk.us.kg-1ecc6299db9ec823/Boa-0.11.0/src/syntax/parser/expression/mod.rs:82
  35: <boa::syntax::parser::expression::primary::template::TemplateLiteral as boa::syntax::parser::TokenParser<R>>::parse
             at /home/xsh/.cargo/registry/src/github.aaakk.us.kg-1ecc6299db9ec823/Boa-0.11.0/src/syntax/parser/expression/primary/template/mod.rs:68
  36: <boa::syntax::parser::expression::primary::PrimaryExpression as boa::syntax::parser::TokenParser<R>>::parse
             at /home/xsh/.cargo/registry/src/github.aaakk.us.kg-1ecc6299db9ec823/Boa-0.11.0/src/syntax/parser/expression/primary/mod.rs:141
  37: <boa::syntax::parser::expression::left_hand_side::member::MemberExpression as boa::syntax::parser::TokenParser<R>>::parse
             at /home/xsh/.cargo/registry/src/github.aaakk.us.kg-1ecc6299db9ec823/Boa-0.11.0/src/syntax/parser/expression/left_hand_side/member.rs:77
  38: <boa::syntax::parser::expression::left_hand_side::LeftHandSideExpression as boa::syntax::parser::TokenParser<R>>::parse
             at /home/xsh/.cargo/registry/src/github.aaakk.us.kg-1ecc6299db9ec823/Boa-0.11.0/src/syntax/parser/expression/left_hand_side/mod.rs:67
  39: <boa::syntax::parser::expression::update::UpdateExpression as boa::syntax::parser::TokenParser<R>>::parse
             at /home/xsh/.cargo/registry/src/github.aaakk.us.kg-1ecc6299db9ec823/Boa-0.11.0/src/syntax/parser/expression/update.rs:79
  40: <boa::syntax::parser::expression::assignment::exponentiation::ExponentiationExpression as boa::syntax::parser::TokenParser<R>>::parse
             at /home/xsh/.cargo/registry/src/github.aaakk.us.kg-1ecc6299db9ec823/Boa-0.11.0/src/syntax/parser/expression/assignment/exponentiation.rs:91
  41: <boa::syntax::parser::expression::MultiplicativeExpression as boa::syntax::parser::TokenParser<R>>::parse
             at /home/xsh/.cargo/registry/src/github.aaakk.us.kg-1ecc6299db9ec823/Boa-0.11.0/src/syntax/parser/expression/mod.rs:90
  42: <boa::syntax::parser::expression::AdditiveExpression as boa::syntax::parser::TokenParser<R>>::parse
             at /home/xsh/.cargo/registry/src/github.aaakk.us.kg-1ecc6299db9ec823/Boa-0.11.0/src/syntax/parser/expression/mod.rs:82
  43: <boa::syntax::parser::expression::ShiftExpression as boa::syntax::parser::TokenParser<R>>::parse
             at /home/xsh/.cargo/registry/src/github.aaakk.us.kg-1ecc6299db9ec823/Boa-0.11.0/src/syntax/parser/expression/mod.rs:82
  44: <boa::syntax::parser::expression::RelationalExpression as boa::syntax::parser::TokenParser<R>>::parse
             at /home/xsh/.cargo/registry/src/github.aaakk.us.kg-1ecc6299db9ec823/Boa-0.11.0/src/syntax/parser/expression/mod.rs:489
  45: <boa::syntax::parser::expression::EqualityExpression as boa::syntax::parser::TokenParser<R>>::parse
             at /home/xsh/.cargo/registry/src/github.aaakk.us.kg-1ecc6299db9ec823/Boa-0.11.0/src/syntax/parser/expression/mod.rs:82
  46: <boa::syntax::parser::expression::BitwiseANDExpression as boa::syntax::parser::TokenParser<R>>::parse
             at /home/xsh/.cargo/registry/src/github.aaakk.us.kg-1ecc6299db9ec823/Boa-0.11.0/src/syntax/parser/expression/mod.rs:82
  47: <boa::syntax::parser::expression::BitwiseXORExpression as boa::syntax::parser::TokenParser<R>>::parse
             at /home/xsh/.cargo/registry/src/github.aaakk.us.kg-1ecc6299db9ec823/Boa-0.11.0/src/syntax/parser/expression/mod.rs:82
  48: <boa::syntax::parser::expression::BitwiseORExpression as boa::syntax::parser::TokenParser<R>>::parse
             at /home/xsh/.cargo/registry/src/github.aaakk.us.kg-1ecc6299db9ec823/Boa-0.11.0/src/syntax/parser/expression/mod.rs:82
  49: <boa::syntax::parser::expression::ShortCircuitExpression as boa::syntax::parser::TokenParser<R>>::parse
             at /home/xsh/.cargo/registry/src/github.aaakk.us.kg-1ecc6299db9ec823/Boa-0.11.0/src/syntax/parser/expression/mod.rs:218
  50: <boa::syntax::parser::expression::assignment::conditional::ConditionalExpression as boa::syntax::parser::TokenParser<R>>::parse
             at /home/xsh/.cargo/registry/src/github.aaakk.us.kg-1ecc6299db9ec823/Boa-0.11.0/src/syntax/parser/expression/assignment/conditional.rs:68
  51: <boa::syntax::parser::expression::assignment::AssignmentExpression as boa::syntax::parser::TokenParser<R>>::parse
             at /home/xsh/.cargo/registry/src/github.aaakk.us.kg-1ecc6299db9ec823/Boa-0.11.0/src/syntax/parser/expression/assignment/mod.rs:175
  52: <boa::syntax::parser::expression::Expression as boa::syntax::parser::TokenParser<R>>::parse
             at /home/xsh/.cargo/registry/src/github.aaakk.us.kg-1ecc6299db9ec823/Boa-0.11.0/src/syntax/parser/expression/mod.rs:82
  53: <boa::syntax::parser::statement::expression::ExpressionStatement as boa::syntax::parser::TokenParser<R>>::parse
             at /home/xsh/.cargo/registry/src/github.aaakk.us.kg-1ecc6299db9ec823/Boa-0.11.0/src/syntax/parser/statement/expression/mod.rs:46
  54: <boa::syntax::parser::statement::Statement as boa::syntax::parser::TokenParser<R>>::parse
             at /home/xsh/.cargo/registry/src/github.aaakk.us.kg-1ecc6299db9ec823/Boa-0.11.0/src/syntax/parser/statement/mod.rs:200
  55: <boa::syntax::parser::statement::StatementListItem as boa::syntax::parser::TokenParser<R>>::parse
             at /home/xsh/.cargo/registry/src/github.aaakk.us.kg-1ecc6299db9ec823/Boa-0.11.0/src/syntax/parser/statement/mod.rs:353
  56: <boa::syntax::parser::statement::StatementList as boa::syntax::parser::TokenParser<R>>::parse
             at /home/xsh/.cargo/registry/src/github.aaakk.us.kg-1ecc6299db9ec823/Boa-0.11.0/src/syntax/parser/statement/mod.rs:274
  57: <boa::syntax::parser::statement::block::Block as boa::syntax::parser::TokenParser<R>>::parse
             at /home/xsh/.cargo/registry/src/github.aaakk.us.kg-1ecc6299db9ec823/Boa-0.11.0/src/syntax/parser/statement/block/mod.rs:84
  58: <boa::syntax::parser::statement::Statement as boa::syntax::parser::TokenParser<R>>::parse
             at /home/xsh/.cargo/registry/src/github.aaakk.us.kg-1ecc6299db9ec823/Boa-0.11.0/src/syntax/parser/statement/mod.rs:177
  59: <boa::syntax::parser::statement::StatementListItem as boa::syntax::parser::TokenParser<R>>::parse
             at /home/xsh/.cargo/registry/src/github.aaakk.us.kg-1ecc6299db9ec823/Boa-0.11.0/src/syntax/parser/statement/mod.rs:353
  60: <boa::syntax::parser::statement::StatementList as boa::syntax::parser::TokenParser<R>>::parse
             at /home/xsh/.cargo/registry/src/github.aaakk.us.kg-1ecc6299db9ec823/Boa-0.11.0/src/syntax/parser/statement/mod.rs:274
  61: <boa::syntax::parser::ScriptBody as boa::syntax::parser::TokenParser<R>>::parse
             at /home/xsh/.cargo/registry/src/github.aaakk.us.kg-1ecc6299db9ec823/Boa-0.11.0/src/syntax/parser/mod.rs:159
  62: <boa::syntax::parser::Script as boa::syntax::parser::TokenParser<R>>::parse
             at /home/xsh/.cargo/registry/src/github.aaakk.us.kg-1ecc6299db9ec823/Boa-0.11.0/src/syntax/parser/mod.rs:136
  63: boa::syntax::parser::Parser<R>::parse_all
             at /home/xsh/.cargo/registry/src/github.aaakk.us.kg-1ecc6299db9ec823/Boa-0.11.0/src/syntax/parser/mod.rs:105
  64: boa::context::Context::eval
             at /home/xsh/.cargo/registry/src/github.aaakk.us.kg-1ecc6299db9ec823/Boa-0.11.0/src/context.rs:712

Expected behavior
eval should return error properly instead of panic

Build environment (please complete the following information):

  • OS: Ubuntu
  • Version: 18.04
  • Target triple: x86_64-unknown-linux-gnu
  • Rustc version: rustc 1.46.0

Additional context

@charlesxsh charlesxsh added the bug Something isn't working label Jul 16, 2021
@hle0
Copy link
Contributor

hle0 commented Oct 4, 2021

Do you know if this is still an issue? boa-cli, which also uses Context.eval, fails to reproduce this. It just says Uncaught "SyntaxError": "abrupt end". Perhaps this has been fixed (probably by #1110)? Also, if not, is there a simpler string that causes the same issue?

@jedel1043
Copy link
Member

I think it's fixed, but maybe we should improve the error message with something more descriptive. E.g. V8 prints "Missing } in template expression"

@Razican Razican added this to the v0.14.0 milestone Jan 31, 2022
@Razican Razican self-assigned this Jan 31, 2022
@Razican Razican removed this from the v0.14.0 milestone Feb 5, 2022
@Razican
Copy link
Member

Razican commented Feb 5, 2022

I'm closing this. Error messages can be improved, but the panic doesn't exist anymore in Boa.

@Razican Razican closed this as completed Feb 5, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

4 participants