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

Deno has panicked when prototype.__defineSetter__ used on built-in objects #744

Open
vdata1 opened this issue May 14, 2024 · 4 comments
Open
Labels
bug Something isn't working good first issue Good for newcomers

Comments

@vdata1
Copy link

vdata1 commented May 14, 2024

Hi,
I want to report the following bug found while using prototype.__defineSetter__ on Deno's built-in objects:

Details:

Version: Deno 1.42.1
Platform: linux x86_64

============================================================
Deno has panicked. This is a bug in Deno. Please report this
at https://github.com/denoland/deno/issues/new.
If you can reliably reproduce this panic, include the
reproduction steps and re-run with the RUST_BACKTRACE=1 env
var set and include the backtrace in your report.

Platform: linux x86_64
Version: 1.42.1
Args: ["deno", "run", "9.ts"]

thread 'main' panicked at /home/runner/.cargo/registry/src/index.crates.io-6f17d22bba15001f/deno_core-0.272.0/error.rs:420:71:
called Result::unwrap() on an Err value: ExpectedObject("undefined")
stack backtrace:
0: rust_begin_unwind
at /rustc/07dca489ac2d933c78d3c5158e3f43beefeb02ce/library/std/src/panicking.rs:645:5
1: core::panicking::panic_fmt
at /rustc/07dca489ac2d933c78d3c5158e3f43beefeb02ce/library/core/src/panicking.rs:72:14
2: core::result::unwrap_failed
at /rustc/07dca489ac2d933c78d3c5158e3f43beefeb02ce/library/core/src/result.rs:1649:5
3: deno_core::error::JsError::inner_from_v8_exception
4: deno_core::error::exception_to_err_result
5: deno_core::runtime::jsruntime::JsRuntime::poll_event_loop
6: deno_core::runtime::jsruntime::JsRuntime::run_event_loop::{{closure}}
7: deno_runtime::worker::MainWorker::run_event_loop::{{closure}}
8: deno::worker::CliMainWorker::run::{{closure}}
9: deno::tools::run::run_script::{{closure}}
10: deno::spawn_subcommand::{{closure}}
11: <deno_unsync::task::MaskFutureAsSend as core::future::future::Future>::poll
12: tokio::runtime::task::raw::poll
13: deno::main
note: Some details are omitted, run with RUST_BACKTRACE=full for a verbose backtrace.

How To Reproduce:

Run the following script:

Array.prototype.__defineSetter__(0, function () {});  // I tested it also with "Object" instead of "Array".

//To trigger deno panic
a;  
@bartlomieju bartlomieju added good first issue Good for newcomers bug Something isn't working labels May 14, 2024
@bartlomieju
Copy link
Member

The fix needs to happen in deno_core on this line:

Some(frames_v8) => serde_v8::from_v8(scope, frames_v8.into()).unwrap(),

The .unwrap() should be replaced with .unwrap_or_else(Vec::new).

@peko-thunder
Copy link

@bartlomieju
Will deprecated features be implemented in Deno?
I would like to try if only to fix Panic.

@bartlomieju
Copy link
Member

@bartlomieju Will deprecated features be implemented in Deno?

Is Object.prototype.__defineSetter__ deprecated? It's supported by the V8 engine so we must handle this situation gracefully.

I would like to try if only to fix Panic.

Please do, feel free to open a PR and ping me there with questions.

@peko-thunder
Copy link

@bartlomieju
Thanks for the reply, I'll start working on a fix.

Object.prototype.__defineSetter__ is not defined in type and I couldn't find the implementation.
So I mistakenly thought it was unimplemented.

@bartlomieju bartlomieju transferred this issue from denoland/deno May 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working good first issue Good for newcomers
Projects
None yet
Development

No branches or pull requests

3 participants