Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Panic when attatching debugger #25515

Closed
nicolo-ribaudo opened this issue Sep 8, 2024 · 5 comments · Fixed by #25537
Closed

Panic when attatching debugger #25515

nicolo-ribaudo opened this issue Sep 8, 2024 · 5 comments · Fixed by #25537
Assignees
Labels
bug Something isn't working correctly

Comments

@nicolo-ribaudo
Copy link

Version: Deno 2.0.0-rc.1+ce1d668

Output before attaching the debugger:

$ RUST_BACKTRACE=full deno --inspect-brk --strace-ops -A ./node_modules/.bin/gulp deno-watch

Debugger listening on ws://127.0.0.1:9229/ws/67f0093e-4eea-4fa8-a4bb-8cc11de23e2e
Visit chrome://inspect to connect to the debugger.
Deno is waiting for debugger to connect.
[     0.010] op_add_main_module_handler                         : Dispatched Slow
[     0.010] op_add_main_module_handler                         : Completed Slow
[     0.011] op_set_wasm_streaming_callback                     : Dispatched Slow
[     0.011] op_set_wasm_streaming_callback                     : Completed Slow
[     0.011] op_set_format_exception_callback                   : Dispatched Slow
[     0.011] op_set_format_exception_callback                   : Completed Slow
[     0.011] op_bootstrap_args                                  : Dispatched Slow
[     0.011] op_bootstrap_args                                  : Completed Slow
[     0.011] op_node_guess_handle_type                          : Dispatched Slow
[     0.011] op_node_guess_handle_type                          : Completed Slow
[     0.011] op_is_terminal                                     : Dispatched Slow
[     0.011] op_is_terminal                                     : Completed Slow
[     0.011] op_is_terminal                                     : Dispatched Slow
[     0.011] op_is_terminal                                     : Completed Slow
[     0.011] op_bootstrap_pid                                   : Dispatched Slow
[     0.011] op_bootstrap_pid                                   : Completed Slow
[     0.012] op_node_child_ipc_pipe                             : Dispatched Slow
[     0.012] op_node_child_ipc_pipe                             : Completed Slow
[     0.012] op_require_is_request_relative                     : Dispatched Slow
[     0.012] op_require_is_request_relative                     : Completed Slow
[     0.012] op_require_resolve_lookup_paths                    : Dispatched Slow
[     0.012] op_require_resolve_lookup_paths                    : Completed Slow
[     0.012] op_require_try_self_parent_path                    : Dispatched Slow
[     0.012] op_require_try_self_parent_path                    : Completed Slow
[     0.012] op_require_try_self                                : Dispatched Slow
[     0.012] op_require_try_self                                : Completed Slow
[     0.012] op_require_path_is_absolute                        : Dispatched Slow
[     0.012] op_require_path_is_absolute                        : Completed Slow
[     0.012] op_require_path_resolve                            : Dispatched Slow
[     0.013] op_require_path_resolve                            : Completed Slow
[     0.013] op_require_stat                                    : Dispatched Slow
[     0.013] op_require_stat                                    : Completed Slow
[     0.013] op_require_real_path                               : Dispatched Slow
[     0.013] op_require_real_path                               : Completed Slow
[     0.013] op_require_real_path                               : Dispatched Slow
[     0.013] op_require_real_path                               : Completed Slow
[     0.013] op_require_path_dirname                            : Dispatched Slow
[     0.013] op_require_path_dirname                            : Completed Slow
[     0.013] op_require_real_path                               : Dispatched Slow
[     0.013] op_require_real_path                               : Completed Slow
[     0.013] op_require_path_dirname                            : Dispatched Slow
[     0.013] op_require_path_dirname                            : Completed Slow
[     0.013] op_require_node_module_paths                       : Dispatched Slow
[     0.013] op_require_node_module_paths                       : Completed Slow
[     0.013] op_require_path_basename                           : Dispatched Slow
[     0.013] op_require_path_basename                           : Completed Slow
[     0.013] op_require_read_file                               : Dispatched Slow
[     0.014] op_require_read_file                               : Completed Slow
[     0.014] op_require_read_closest_package_json               : Dispatched Slow
[     0.014] op_require_read_closest_package_json               : Completed Slow
[     0.014] op_url_parse                                       : Dispatched Slow
[     0.014] op_url_parse                                       : Completed Slow
[     0.014] op_url_get_serialization                           : Dispatched Slow
[     0.014] op_url_get_serialization                           : Completed Slow
[     0.014] op_url_reparse                                     : Dispatched Slow
[     0.014] op_url_reparse                                     : Completed Slow
[     0.014] op_url_get_serialization                           : Dispatched Slow
[     0.014] op_url_get_serialization                           : Completed Slow
[     0.014] op_eval_context                                    : Dispatched Slow
[     0.015] op_eval_context                                    : Completed Slow
[     0.015] op_require_path_dirname                            : Dispatched Slow
[     0.015] op_require_path_dirname                            : Completed Slow
[     0.015] op_require_break_on_next_statement                 : Dispatched Slow

Output after attaching the debugger:

Debugger session started.
[     4.004] op_get_env                                         : Dispatched Slow

============================================================
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: 2.0.0-rc.1+ce1d668
Args: ["deno", "--inspect-brk", "--strace-ops", "-A", "./node_modules/.bin/gulp", "deno-watch"]

thread 'main' panicked at runtime/ops/os/mod.rs:120:1:
already borrowed: BorrowMutError
stack backtrace:
   0:     0x5b33214e3635 - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::hd736fd5964392270
   1:     0x5b332151601b - core::fmt::write::hc6043626647b98ea
   2:     0x5b33214dd69f - std::io::Write::write_fmt::h0d24b3e0473045db
   3:     0x5b33214e340e - std::sys_common::backtrace::print::h45eb8174d25a1e76
   4:     0x5b33214e4e79 - std::panicking::default_hook::{{closure}}::haf3f0170eb4f3b53
   5:     0x5b33214e4c1a - std::panicking::default_hook::hb5d3b27aa9f6dcda
   6:     0x5b3321af95d8 - deno::setup_panic_hook::{{closure}}::he176d5da7fc31b77
   7:     0x5b33214e54eb - std::panicking::rust_panic_with_hook::h6b49d59f86ee588c
   8:     0x5b33214e5264 - std::panicking::begin_panic_handler::{{closure}}::hd4c2f7ed79b82b70
   9:     0x5b33214e3af9 - std::sys_common::backtrace::__rust_end_short_backtrace::h2946d6d32d7ea1ad
  10:     0x5b33214e4f97 - rust_begin_unwind
  11:     0x5b3321512f33 - core::panicking::panic_fmt::ha02418e5cd774672
  12:     0x5b3321510133 - core::cell::panic_already_borrowed::hcf28bb385d54cc1d
  13:     0x5b33224d1b44 - deno_runtime::ops::os::op_get_env::op_get_env::v8_fn_ptr_metrics::hdf29fe7ad7e56c16
  14:     0x5b33212e2146 - Builtins_CallApiCallbackGeneric

If needed I have a non-minimal (it uses gulp) reproduction

@bartlomieju bartlomieju added the bug Something isn't working correctly label Sep 8, 2024
@bartlomieju
Copy link
Member

Looks like we got some code that reenters JS and is keeping the RefCell borrow for too long.

@littledivy
Copy link
Member

littledivy commented Sep 9, 2024

Is it flaky? I can't reproduce it on macOS (arm64) and Linux (x86_64).

Here's what I am trying:

mkdir gulp-repro/ && cd gulp-repro/
npm init -y
npm i --save gulp

RUST_BACKTRACE=full deno --inspect-brk --strace-ops -A ./node_modules/.bin/gulp deno-watch

Output after debugger is attached:

...

Debugger session started.
[     6.232] op_require_break_on_next_statement                 : Completed Slow

Output after execution:

...

[    86.809] op_set_has_tick_scheduled                          : Dispatched Slow
[    86.809] op_set_has_tick_scheduled                          : Completed Slow
[    86.809] op_bootstrap_no_color                              : Dispatched Slow
[    86.809] op_bootstrap_no_color                              : Completed Slow
[    86.809] op_bootstrap_is_stderr_tty                         : Dispatched Slow
[    86.809] op_bootstrap_is_stderr_tty                         : Completed Slow
[    86.810] op_print                                           : Dispatched Slow
No gulpfile found
[    86.810] op_print                                           : Completed Slow
[    86.810] op_set_exit_code                                   : Dispatched Slow
[    86.810] op_set_exit_code                                   : Completed Slow
[    86.810] op_get_exit_code                                   : Dispatched Slow
[    86.810] op_get_exit_code                                   : Completed Slow
[    86.810] op_set_exit_code                                   : Dispatched Slow
[    86.810] op_set_exit_code                                   : Completed Slow
[    86.810] op_exit                                            : Dispatched Slow

@nicolo-ribaudo
Copy link
Author

nicolo-ribaudo commented Sep 9, 2024

I can reproduce it 100% of the times on Linux (x86_64), following exactly the steps you are following 🤔

I'm using this vscode config:

{
  "version": "0.2.0",
  "configurations": [
    {
      "name": "Attach",
      "port": 9229,
      "request": "attach",
      "type": "node"
    }
  ]
}

@nicolo-ribaudo
Copy link
Author

I can also easily and consistently reproduce it in an empty GitHub codespace.

@littledivy
Copy link
Member

Oh I can reproduce it with the Vscode debugger. I was trying it earlier with the Chrome inspector (chrome://inspect)

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
bug Something isn't working correctly
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants