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: environment must be declarative #2719

Closed
langston-barrett opened this issue Mar 21, 2023 · 3 comments · Fixed by #2980
Closed

panic: environment must be declarative #2719

langston-barrett opened this issue Mar 21, 2023 · 3 comments · Fixed by #2980
Labels
bug Something isn't working E-Medium Medium difficulty problem good first issue Good for newcomers

Comments

@langston-barrett
Copy link

Found with tree-crasher on 0e01a74. Let me know if you still want more bug reports, I'll stop posting for now to avoid spamming you!

with({ p1:1,  }) {k[oa>>2]=d;}
{
  let a12345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890 = 1,
      b = "";
}
Uncaught: ReferenceError: k is not defined
thread 'main' panicked at 'environment must be declarative', boa_engine/src/environments/runtime.rs:248:14
stack backtrace:
   0: rust_begin_unwind
             at /rustc/2c8cc343237b8f7d5a3c3703e3a87f2eb2c54a74/library/std/src/panicking.rs:575:5
   1: core::panicking::panic_fmt
             at /rustc/2c8cc343237b8f7d5a3c3703e3a87f2eb2c54a74/library/core/src/panicking.rs:64:14
   2: core::panicking::panic_display
             at /rustc/2c8cc343237b8f7d5a3c3703e3a87f2eb2c54a74/library/core/src/panicking.rs:147:5
   3: core::panicking::panic_str
             at /rustc/2c8cc343237b8f7d5a3c3703e3a87f2eb2c54a74/library/core/src/panicking.rs:131:5
   4: core::option::expect_failed
             at /rustc/2c8cc343237b8f7d5a3c3703e3a87f2eb2c54a74/library/core/src/option.rs:1924:5
   5: boa_engine::environments::runtime::DeclarativeEnvironmentStack::put_value
   6: <boa_engine::vm::opcode::define::DefInitLet as boa_engine::vm::opcode::Operation>::execute
   7: boa_engine::vm::<impl boa_engine::context::Context>::run
   8: boa_engine::context::Context::execute
   9: boa_engine::context::Context::eval_script
  10: boa::main
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.
@langston-barrett langston-barrett added the bug Something isn't working label Mar 21, 2023
@jasonwilliams
Copy link
Member

jasonwilliams commented Apr 12, 2023

Hey @langston-barrett this fuzzer is interesting, do you have a guide or steps on how you’re using this with Boa?

the reference error seems correct but the panic shouldn’t be there.

@jasonwilliams jasonwilliams added E-Medium Medium difficulty problem good first issue Good for newcomers labels Apr 12, 2023
@langston-barrett
Copy link
Author

Thanks for the interest @jasonwilliams! Good news is, it's really easy! The simplest set-up would be:

tree-crasher-javascript corpus/ boa

where corpus/ is a big collection of JavaScript files. This will only find really fatal errors like segfaults, though.

The one I actually use is:

systemd-run --scope -p MemoryMax=16G -p MemorySwapMax=0B --user unshare -Umn tree-crasher-javascript --interesting-stderr "(?m)^thread 'main' panicked at" corpus/ boa

That limits the RAM and network access of the fuzzed processes and also finds panics in additions to segfaults. I usually use a corpus of files that boa was able to successfully parse/execute.

Documentation is available here: https://langston-barrett.github.io/tree-crasher/

@jedel1043
Copy link
Member

This is fixed, just needs to be added to our tests to avoid regressions.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working E-Medium Medium difficulty problem good first issue Good for newcomers
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants