Skip to content

Parser Panic #240

Closed
Closed

Description

@adumbidiot

When putting the following in test.js:
var`a = 1;
running the command cargo run -- test.js will give the following panic:

    Finished dev [unoptimized + debuginfo] target(s) in 0.14s
     Running `target\debug\boa.exe test.js`
thread 'main' panicked at '1:4: Unexpected '`'', src/lib\syntax\lexer.rs:620:22
stack backtrace:
   0:     0x7ff636d9a689 - backtrace::backtrace::trace_unsynchronized
                               at C:\Users\VssAdministrator\.cargo\registry\src\github.com-1ecc6299db9ec823\backtrace-0.3.40\src\backtrace\mod.rs:66
   1:     0x7ff636d9a689 - std::sys_common::backtrace::_print_fmt
                               at /rustc/212b2c7da87f3086af535b33a9ca6b5242f2d5a7\/src\libstd\sys_common\backtrace.rs:77
   2:     0x7ff636d9a689 - std::sys_common::backtrace::_print::{{impl}}::fmt
                               at /rustc/212b2c7da87f3086af535b33a9ca6b5242f2d5a7\/src\libstd\sys_common\backtrace.rs:59
   3:     0x7ff636db007b - core::fmt::write
                               at /rustc/212b2c7da87f3086af535b33a9ca6b5242f2d5a7\/src\libcore\fmt\mod.rs:1052
   4:     0x7ff636d98244 - std::io::Write::write_fmt<std::sys::windows::stdio::Stderr>
                               at /rustc/212b2c7da87f3086af535b33a9ca6b5242f2d5a7\/src\libstd\io\mod.rs:1428
   5:     0x7ff636d9cfbc - std::sys_common::backtrace::_print
                               at /rustc/212b2c7da87f3086af535b33a9ca6b5242f2d5a7\/src\libstd\sys_common\backtrace.rs:62
   6:     0x7ff636d9cfbc - std::sys_common::backtrace::print
                               at /rustc/212b2c7da87f3086af535b33a9ca6b5242f2d5a7\/src\libstd\sys_common\backtrace.rs:49
   7:     0x7ff636d9cfbc - std::panicking::default_hook::{{closure}}
                               at /rustc/212b2c7da87f3086af535b33a9ca6b5242f2d5a7\/src\libstd\panicking.rs:204
   8:     0x7ff636d9cc0c - std::panicking::default_hook
                               at /rustc/212b2c7da87f3086af535b33a9ca6b5242f2d5a7\/src\libstd\panicking.rs:224
   9:     0x7ff636d9d70f - std::panicking::rust_panic_with_hook
                               at /rustc/212b2c7da87f3086af535b33a9ca6b5242f2d5a7\/src\libstd\panicking.rs:472
  10:     0x7ff636d9d295 - std::panicking::begin_panic_handler
                               at /rustc/212b2c7da87f3086af535b33a9ca6b5242f2d5a7\/src\libstd\panicking.rs:380
  11:     0x7ff636d9d20c - std::panicking::begin_panic_fmt
                               at /rustc/212b2c7da87f3086af535b33a9ca6b5242f2d5a7\/src\libstd\panicking.rs:334
  12:     0x7ff6369f4511 - boa::syntax::lexer::Lexer::lex
                               at C:\Users\nathaniel\Documents\GitHub\boa\src\lib\syntax\lexer.rs:620
  13:     0x7ff6369f3121 - boa::parser_expr
                               at C:\Users\nathaniel\Documents\GitHub\boa\src\lib\lib.rs:24
  14:     0x7ff6369f32b8 - boa::forward
                               at C:\Users\nathaniel\Documents\GitHub\boa\src\lib\lib.rs:33
  15:     0x7ff6369f36b8 - boa::exec
                               at C:\Users\nathaniel\Documents\GitHub\boa\src\lib\lib.rs:56
  16:     0x7ff6369f1d7d - boa::main
                               at C:\Users\nathaniel\Documents\GitHub\boa\src\bin\bin.rs:38
  17:     0x7ff6369f2335 - std::rt::lang_start::{{closure}}<core::result::Result<(), std::io::error::Error>>
                               at /rustc/212b2c7da87f3086af535b33a9ca6b5242f2d5a7\src\libstd\rt.rs:67
  18:     0x7ff636d9d137 - std::rt::lang_start_internal::{{closure}}
                               at /rustc/212b2c7da87f3086af535b33a9ca6b5242f2d5a7\/src\libstd\rt.rs:52
  19:     0x7ff636d9d137 - std::panicking::try::do_call<closure-0,i32>
                               at /rustc/212b2c7da87f3086af535b33a9ca6b5242f2d5a7\/src\libstd\panicking.rs:305
  20:     0x7ff636da06a2 - panic_unwind::__rust_maybe_catch_panic
                               at /rustc/212b2c7da87f3086af535b33a9ca6b5242f2d5a7\/src\libpanic_unwind\lib.rs:86
  21:     0x7ff636d9d932 - std::panicking::try
                               at /rustc/212b2c7da87f3086af535b33a9ca6b5242f2d5a7\/src\libstd\panicking.rs:281
  22:     0x7ff636d9d932 - std::panic::catch_unwind
                               at /rustc/212b2c7da87f3086af535b33a9ca6b5242f2d5a7\/src\libstd\panic.rs:394
  23:     0x7ff636d9d932 - std::rt::lang_start_internal
                               at /rustc/212b2c7da87f3086af535b33a9ca6b5242f2d5a7\/src\libstd\rt.rs:51
  24:     0x7ff6369f230b - std::rt::lang_start<core::result::Result<(), std::io::error::Error>>
                               at /rustc/212b2c7da87f3086af535b33a9ca6b5242f2d5a7\src\libstd\rt.rs:67
  25:     0x7ff6369f2100 - main
  26:     0x7ff636db6878 - invoke_main
                               at d:\agent\_work\5\s\src\vctools\crt\vcstartup\src\startup\exe_common.inl:78
  27:     0x7ff636db6878 - __scrt_common_main_seh
                               at d:\agent\_work\5\s\src\vctools\crt\vcstartup\src\startup\exe_common.inl:288
  28:     0x7fff816a7bd4 - BaseThreadInitThunk
  29:     0x7fff82acced1 - RtlUserThreadStart
error: process didn't exit successfully: `target\debug\boa.exe test.js` (exit code: 101)

This should probably be an error, not a panic.

Activity

  1. jasonwilliams commented on Feb 2, 2020

    @jasonwilliams
    Member

    Thanks @adumbidiot
    You’ve touched upon on a deeper problem Boa has right now, which is lack of error handling on all layers. The best way for us to get up and running was to just let things panic, but we should put some work in to have proper stderr messages, maybe starting with the lexer/parser.

  2. added
    A-Bug
    Help Wanted
    on Feb 2, 2020
  3. adumbidiot commented on Feb 2, 2020

    @adumbidiot
    ContributorAuthor

    Would it be helpful to try to replace some of the panics in the lexer with the LexerErrors?

  4. croraf commented on Feb 2, 2020

    @croraf
    Contributor

    @jasonwilliams I guess a LexerError is when the user inputs something that is not allowed as per JS specification. That will show him that his code is invalid. What happens here is that ` is not implemented in Boa, so I think "panic" is ok, as it is actually bugs out in Boa before realizing it is invalid as per JS syntax.

    If template literals were implemented it should show LexerError, something like:
    image

    image

  5. adumbidiot commented on Feb 2, 2020

    @adumbidiot
    ContributorAuthor

    I still kinda feel like the engine should still return an error. Just as older engines reject newer syntax with lexing and parsing errors and such, I feel like Boa should reject syntax it doesn't support with errors.

  6. jasonwilliams commented on Feb 2, 2020

    @jasonwilliams
    Member
  7. jasonwilliams commented on Feb 4, 2020

    @jasonwilliams
    Member

    This has now been fixed, thanks @adumbidiot

  8. adumbidiot commented on Feb 4, 2020

    @adumbidiot
    ContributorAuthor

    I feel like a lot more work has to be done here; My pull only fixed some of the lexer panics and none of the parser panics.

  9. added
    C-Parser
    on Mar 31, 2020
  10. jasonwilliams commented on Mar 31, 2020

    @jasonwilliams
    Member

    @adumbidiot have you tried this against the new parser?

  11. added a commit that references this issue on Mar 31, 2020
  12. jasonwilliams commented on Apr 13, 2020

    @jasonwilliams
    Member

    I'm going to close this issue as the main problem in question has been fixed, and some other parser issues have been resolved.

    If there are new issues we should make a ticket for them

  13. linked a pull request that will close this issueAdd ECMAScript test suite (test262) #567on Sep 2, 2020
  14. added this to the v0.10.0 milestone on Sep 2, 2020
  15. Razican commented on Sep 2, 2020

    @Razican
    Member

    I want to re-open this, since it seems this is now also panicking. We should never panic, and checking what this gives in Firefox, for example, I can see the following:

    Uncaught SyntaxError: `` literal not terminated before end of script
    

    So, let's re-open it and track it, since we get this panic:

    I/O error: Unterminated template literal
    thread 'main' panicked at 'explicit panic', boa/src/lib.rs:94:13
    note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
    

    It seems that in the test262 branch this is fixed:

    "SyntaxError": "I/O error: Unterminated template literal"
    
  16. reopened this on Sep 2, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-BugC-ParserHelp Wanted

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions