Skip to content

Borrow panic in object internal methods #1059

Closed

Description

@Razican

The OrdinaryDefineOwnProperty() function can panic with the following error message:

thread 'main' panicked at 'Object already borrowed: BorrowMutError', boa/src/object/internal_methods.rs:198:18

This has been observed when running this ECMAScript test.

This is the full backtrace:

   0: rust_begin_unwind
             at /rustc/e1884a8e3c3e813aada8254edfa120e85bf5ffca/library/std/src/panicking.rs:495:5
   1: core::panicking::panic_fmt
             at /rustc/e1884a8e3c3e813aada8254edfa120e85bf5ffca/library/core/src/panicking.rs:92:14
   2: core::option::expect_none_failed
             at /rustc/e1884a8e3c3e813aada8254edfa120e85bf5ffca/library/core/src/option.rs:1268:5
   3: boa::object::internal_methods::<impl boa::object::gcobject::GcObject>::ordinary_define_own_property
   4: boa::object::internal_methods::<impl boa::object::gcobject::GcObject>::set
   5: boa::object::internal_methods::<impl boa::object::gcobject::GcObject>::set
   6: boa::value::Value::set_field
   7: <boa::syntax::ast::node::operator::assign::Assign as boa::exec::Executable>::run
   8: <boa::syntax::ast::node::statement_list::StatementList as boa::exec::Executable>::run
   9: boa::object::gcobject::GcObject::call
  10: boa::object::internal_methods::<impl boa::object::gcobject::GcObject>::get
  11: boa::value::Value::get_field
  12: boa::object::gcobject::GcObject::to_json
  13: boa::value::Value::to_json
  14: boa::builtins::json::Json::stringify
  15: boa::object::gcobject::GcObject::call
  16: <boa::syntax::ast::node::call::Call as boa::exec::Executable>::run
  17: <boa::syntax::ast::node::Node as boa::exec::Executable>::run
  18: <boa::syntax::ast::node::statement_list::StatementList as boa::exec::Executable>::run
  19: boa::context::Context::eval
  20: boa_tester::exec::<impl boa_tester::Test>::run_once
  21: boa_tester::exec::<impl boa_tester::Test>::run
  22: boa_tester::main

It seems that when we call self.insert() here we are re-borrowing the object.

You can check this issue by running the following command:

RUST_BACKTRACE=1 cargo run --release --bin boa_tester -- run -v -s test/built-ins/JSON/stringify/property-order.js

Activity

  1. added
    A-Bug
    C-Builtins
    A-Execution
    on Jan 11, 2021
  2. added this to the v0.12.0 milestone on Jan 11, 2021
  3. modified the milestones: v0.12.0, v0.13.0 on May 22, 2021
  4. modified the milestones: v0.13.0, v0.12.0 on May 29, 2021
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-BugA-ExecutionC-Builtins

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions