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

Panic on unreachable code when converting object to JSON #1064

Closed
Razican opened this issue Jan 12, 2021 · 0 comments · Fixed by #1201
Closed

Panic on unreachable code when converting object to JSON #1064

Razican opened this issue Jan 12, 2021 · 0 comments · Fixed by #1201
Labels
bug Something isn't working builtins PRs and Issues related to builtins/intrinsics execution Issues or PRs related to code execution
Milestone

Comments

@Razican
Copy link
Member

Razican commented Jan 12, 2021

In some cases, when we try to convert a specifically built object to JSON, we can get a panic because we try to convert an undefined or Symbol value to JSON.

This happens in the following 2 tests from the Test262 test suite:

You can reproduce it by running:

RUST_BACKTRACE=1 cargo run --release --bin boa_tester -- run -v -s {file}

Where {file} is one of the two above. The panic that gets generated is this one:

thread 'main' panicked at 'internal error: entered unreachable code: Symbols and Undefined JSON Values depend on parent type', boa/src/value/mod.rs:245:17

And the stack trace this one:

   0: rust_begin_unwind
             at /rustc/e1884a8e3c3e813aada8254edfa120e85bf5ffca/library/std/src/panicking.rs:495:5
   1: std::panicking::begin_panic_fmt
             at /rustc/e1884a8e3c3e813aada8254edfa120e85bf5ffca/library/std/src/panicking.rs:437:5
   2: boa::value::Value::to_json
   3: boa::value::Value::to_json
   4: boa::builtins::json::Json::stringify
   5: boa::object::gcobject::GcObject::call
   6: <boa::syntax::ast::node::call::Call as boa::exec::Executable>::run
   7: <boa::syntax::ast::node::call::Call as boa::exec::Executable>::run
   8: <boa::syntax::ast::node::statement_list::StatementList as boa::exec::Executable>::run
   9: boa::context::Context::eval
  10: boa_tester::exec::<impl boa_tester::Test>::run_once
  11: boa_tester::exec::<impl boa_tester::Test>::run
  12: boa_tester::main
@Razican Razican added bug Something isn't working builtins PRs and Issues related to builtins/intrinsics execution Issues or PRs related to code execution labels Jan 12, 2021
@Razican Razican added this to the v0.12.0 milestone Jan 12, 2021
@Razican Razican mentioned this issue Jan 12, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working builtins PRs and Issues related to builtins/intrinsics execution Issues or PRs related to code execution
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant