Repository: deno
Issue: Segfault with attaching debugger
Labels: bug

### Steps to reproduce

Note: I couldn't reliably reproduce the segmentation fault. I archived the entire project directory with git archive and attempted reproduction in another dev container, but the issue did not reoccur. The following is for reference purposes only.

1. My environment.
```
macOS Sonoma 14.5
Docker Desktop 4.30.0
Cursor IDE 0.40.4
Deno 2.0.0-rc.2 (Devcontainer Dockerfile)
```
2. Clone the repository:
   `git clone -b debugger-segfault https://github.com/jeiea/deno_report.git`
    Make sure to check out the correct branch.
3. Open the cloned directory in VSCode, then run the command:  *Dev Containers: Reopen in Container*.
5. After the container builds, open `main.ts` and press F5.

### Expected behavior

The debugger should stop at the debugger statement.

### Actual behavior

The debug task stops immediately.

### Additional context

<summary>
I managed to capture debugging information using lldb and found a segfault stack trace.
<details>

```
➜ git:(debug/abort) ✗  cd /workspaces/project ; /usr/bin/env RUST_BACKTRACE=full 'VSCODE_INSPECTOR_OPTIONS=:::{"inspe
ctorIpc":"/tmp/node-cdp.326-bb675a64-7.sock","deferredMode":false,"waitForDebugger":"","onlyEntrypoint":false,"autoAttachMode":"always","mandatePortTr
acking":true,"fileCallback":"/tmp/node-debug-callback-ec67ca8f89c8fd1e"}' /usr/bin/lldb -- /usr/bin/deno run --inspect-wait --allow-all ./main.ts 
Traceback (most recent call last):
  File "<string>", line 1, in <module>
ModuleNotFoundError: No module named 'lldb.embedded_interpreter'
(lldb) target create "/usr/bin/deno"
Current executable set to '/usr/bin/deno' (aarch64).
(lldb) settings set -- target.run-args  "run" "--inspect-wait" "--allow-all" "./main.ts"
(lldb) run
Process 3112 launched: '/usr/bin/deno' (aarch64)
Debugger listening on ws://127.0.0.1:9229/ws/6cd7c667-661b-41d5-ab82-06918a8ad73f
Visit chrome://inspect to connect to the debugger.
Deno is waiting for debugger to connect.
Debugger session started.
Process 3112 stopped
* thread #1, name = 'deno', stop reason = signal SIGSEGV: invalid address (fault address: 0xffffffffffffffff)
    frame #0: 0x0000aaaaadbe1efc deno`v8::internal::Context::module() const + 28
deno`v8::internal::Context::module:
->  0xaaaaadbe1efc <+28>: ldur   x9, [x8, #-0x1]
    0xaaaaadbe1f00 <+32>: ldurh  w9, [x9, #0xb]
    0xaaaaadbe1f04 <+36>: cmp    w9, #0xe3
    0xaaaaadbe1f08 <+40>: b.ne   0xaaaaadbe1ef8            ; <+24>
(lldb) bt all
* thread #1, name = 'deno', stop reason = signal SIGSEGV: invalid address (fault address: 0xffffffffffffffff)
  * frame #0: 0x0000aaaaadbe1efc deno`v8::internal::Context::module() const + 28
    frame #1: 0x0000aaaaad9bd0fc deno`v8::internal::ScopeIterator::VisitLocals(std::__Cr::function<bool (v8::internal::Handle<v8::internal::String>, v8::internal::Handle<v8::internal::Object>, v8::internal::ScopeIterator::ScopeType)> const&, v8::internal::ScopeIterator::Mode, v8::internal::ScopeIterator::ScopeType) const + 696
    frame #2: 0x0000aaaaad9bb9c4 deno`v8::internal::ScopeIterator::VisitLocalScope(std::__Cr::function<bool (v8::internal::Handle<v8::internal::String>, v8::internal::Handle<v8::internal::Object>, v8::internal::ScopeIterator::ScopeType)> const&, v8::internal::ScopeIterator::Mode, v8::internal::ScopeIterator::ScopeType) const + 80
    frame #3: 0x0000aaaaad9bb2cc deno`v8::internal::ScopeIterator::DeclaresLocals(v8::internal::ScopeIterator::Mode) const + 164
    frame #4: 0x0000aaaaad9c0588 deno`v8::internal::DebugScopeIterator::Advance() + 64
    frame #5: 0x0000aaaaae3f703c deno`v8_inspector::V8DebuggerAgentImpl::currentCallFrames(std::__Cr::unique_ptr<std::__Cr::vector<std::__Cr::unique_ptr<v8_inspector::protocol::Debugger::CallFrame, std::__Cr::default_delete<v8_inspector::protocol::Debugger::CallFrame> >, std::__Cr::allocator<std::__Cr::unique_ptr<v8_inspector::protocol::Debugger::CallFrame, std::__Cr::default_delete<v8_inspector::protocol::Debugger::CallFrame> > > >, std::__Cr::default_delete<std::__Cr::vector<std::__Cr::unique_ptr<v8_inspector::protocol::Debugger::CallFrame, std::__Cr::default_delete<v8_inspector::protocol::Debugger::CallFrame> >, std::__Cr::allocator<std::__Cr::unique_ptr<v8_inspector::protocol::Debugger::CallFrame, std::__Cr::default_delete<v8_inspector::protocol::Debugger::CallFrame> > > > > >*) + 644
    frame #6: 0x0000aaaaae3ed61c deno`v8_inspector::V8DebuggerAgentImpl::didPause(int, v8::Local<v8::Value>, std::__Cr::vector<int, std::__Cr::allocator<int> > const&, v8::debug::ExceptionType, bool, v8::base::EnumSet<v8::debug::BreakReason, int>) + 2644
    frame #7: 0x0000aaaaae3dc044 deno`v8_inspector::V8InspectorImpl::forEachSession(int, std::__Cr::function<void (v8_inspector::V8InspectorSessionImpl*)> const&) + 756
    frame #8: 0x0000aaaaae3e2cf0 deno`v8_inspector::V8Debugger::handleProgramBreak(v8::Local<v8::Context>, v8::Local<v8::Value>, std::__Cr::vector<int, std::__Cr::allocator<int> > const&, v8::base::EnumSet<v8::debug::BreakReason, int>, v8::debug::ExceptionType, bool) + 608
    frame #9: 0x0000aaaaad9c3424 deno`v8::internal::Debug::OnDebugBreak(v8::internal::Handle<v8::internal::FixedArray>, v8::internal::StepAction, v8::base::EnumSet<v8::debug::BreakReason, int>) + 344
    frame #10: 0x0000aaaaad9c297c deno`v8::internal::Debug::Break(v8::internal::JavaScriptFrame*, v8::internal::Handle<v8::internal::JSFunction>) + 1088
    frame #11: 0x0000aaaaade5f074 deno`v8::internal::Runtime_DebugBreakOnBytecode(int, unsigned long*, v8::internal::Isolate*) + 196
    frame #12: 0x0000aaaaaec435c4 deno`Builtins_CEntry_Return2_ArgvOnStack_NoBuiltinExit + 100
    frame #13: 0x0000aaaaaed18a70 deno`Builtins_DebugBreak2Handler + 80
    frame #14: 0x0000aaaaaeba6240 deno`Builtins_InterpreterEntryTrampoline + 288
    frame #15: 0x0000aaaaaebe830c deno`Builtins_GeneratorPrototypeNext + 140
    frame #16: 0x0000aaaaaeba3d34 deno`Builtins_JSEntryTrampoline + 180
    frame #17: 0x0000aaaaaeba397c deno`Builtins_JSEntry + 188
    frame #18: 0x0000aaaaad9f1530 deno`v8::internal::(anonymous namespace)::Invoke(v8::internal::Isolate*, v8::internal::(anonymous namespace)::InvokeParams const&) + 1604
    frame #19: 0x0000aaaaad9f1dbc deno`v8::internal::(anonymous namespace)::InvokeWithTryCatch(v8::internal::Isolate*, v8::internal::(anonymous namespace)::InvokeParams const&) + 92
    frame #20: 0x0000aaaaad9f1e90 deno`v8::internal::Execution::TryCall(v8::internal::Isolate*, v8::internal::Handle<v8::internal::Object>, v8::internal::Handle<v8::internal::Object>, int, v8::internal::Handle<v8::internal::Object>*, v8::internal::Execution::MessageHandling, v8::internal::MaybeHandle<v8::internal::Object>*) + 124
    frame #21: 0x0000aaaaadd7b7f0 deno`v8::internal::SourceTextModule::ExecuteModule(v8::internal::Isolate*, v8::internal::Handle<v8::internal::SourceTextModule>, v8::internal::MaybeHandle<v8::internal::Object>*) + 164
    frame #22: 0x0000aaaaadd7b154 deno`v8::internal::SourceTextModule::InnerModuleEvaluation(v8::internal::Isolate*, v8::internal::Handle<v8::internal::SourceTextModule>, v8::internal::ZoneForwardList<v8::internal::Handle<v8::internal::SourceTextModule> >*, unsigned int*) + 924
    frame #23: 0x0000aaaaadd7af84 deno`v8::internal::SourceTextModule::InnerModuleEvaluation(v8::internal::Isolate*, v8::internal::Handle<v8::internal::SourceTextModule>, v8::internal::ZoneForwardList<v8::internal::Handle<v8::internal::SourceTextModule> >*, unsigned int*) + 460
    frame #24: 0x0000aaaaadd7ac7c deno`v8::internal::SourceTextModule::Evaluate(v8::internal::Isolate*, v8::internal::Handle<v8::internal::SourceTextModule>) + 240
    frame #25: 0x0000aaaaadd47980 deno`v8::internal::Module::Evaluate(v8::internal::Isolate*, v8::internal::Handle<v8::internal::Module>) + 228
    frame #26: 0x0000aaaaad8ebeb0 deno`v8::Module::Evaluate(v8::Local<v8::Context>) + 556
    frame #27: 0x0000aaaab07c8858 deno`deno_core::modules::map::ModuleMap::mod_evaluate::h01efb854dc2212e3 + 596
    frame #28: 0x0000aaaab07ecfa0 deno`deno_core::runtime::jsruntime::JsRuntime::mod_evaluate::h47fa68b92f6b1174 + 64
    frame #29: 0x0000aaaaaf19c914 deno`deno::worker::CliMainWorker::evaluate_module_possibly_with_npm::_$u7b$$u7b$closure$u7d$$u7d$::h0ae5ac4cb102e77b + 148
    frame #30: 0x0000aaaaaf19bb9c deno`deno::worker::CliMainWorker::execute_main_module_possibly_with_npm::_$u7b$$u7b$closure$u7d$$u7d$::h42adcde395f81aba + 816
    frame #31: 0x0000aaaaaf19afd4 deno`deno::worker::CliMainWorker::run::_$u7b$$u7b$closure$u7d$$u7d$::h310e9370cf2bb718 + 648
    frame #32: 0x0000aaaaaf1b19c4 deno`deno::run_subcommand::_$u7b$$u7b$closure$u7d$$u7d$::_$u7b$$u7b$closure$u7d$$u7d$::he828cd9a8f82f52f + 3244
    frame #33: 0x0000aaaaaf1a665c deno`deno::spawn_subcommand::_$u7b$$u7b$closure$u7d$$u7d$::h7bc6f56dde254128 + 112
    frame #34: 0x0000aaaaaedd1ee8 deno`_$LT$deno_unsync..tokio..task..MaskFutureAsSend$LT$F$GT$$u20$as$u20$core..future..future..Future$GT$::poll::h3fe065a46748b337 + 12
    frame #35: 0x0000aaaaaef5ece8 deno`tokio::runtime::task::raw::poll::hfc0593ec9c11e028 + 72
    frame #36: 0x0000aaaaaf1b57d4 deno`deno::main::h5d16eefb091ea8c9 + 3256
    frame #37: 0x0000aaaaaee6c1cc deno`std::sys_common::backtrace::__rust_begin_short_backtrace::h4b19a8d1b955a482 + 8
    frame #38: 0x0000aaaaaee73308 deno`std::rt::lang_start::_$u7b$$u7b$closure$u7d$$u7d$::hdc5a0f786cbf0fa3 + 12
    frame #39: 0x0000aaaaaed82d64 deno`std::rt::lang_start_internal::hd1567374aba5b64a + 828
    frame #40: 0x0000aaaaaee732f4 deno`std::rt::lang_start::hc5a9419d268ab127 + 40
    frame #41: 0x0000aaaaaf2164a4 deno`main + 12
    frame #42: 0x0000fffff7d273fc libc.so.6`___lldb_unnamed_symbol2962 + 108
    frame #43: 0x0000fffff7d274cc libc.so.6`__libc_start_main + 152
    frame #44: 0x0000aaaaad878034 deno`_start + 52
  thread #2, name = 'V8 DefaultWorke'
    frame #0: 0x0000fffff7d79df8 libc.so.6`___lldb_unnamed_symbol3262 + 200
    frame #1: 0x0000fffff7d7c8fc libc.so.6`pthread_cond_wait + 520
    frame #2: 0x0000aaaaad89fea0 deno`v8::platform::DefaultWorkerThreadsTaskRunner::WorkerThread::Run() + 144
    frame #3: 0x0000aaaaad896868 deno`v8::base::ThreadEntry(void*) + 136
    frame #4: 0x0000fffff7d7d5c8 libc.so.6`___lldb_unnamed_symbol3291 + 724
    frame #5: 0x0000fffff7de5edc libc.so.6`___lldb_unnamed_symbol3660 + 12
  thread #3, name = 'V8 DefaultWorke'
    frame #0: 0x0000fffff7d79df8 libc.so.6`___lldb_unnamed_symbol3262 + 200
    frame #1: 0x0000fffff7d7c8fc libc.so.6`pthread_cond_wait + 520
    frame #2: 0x0000aaaaad89fea0 deno`v8::platform::DefaultWorkerThreadsTaskRunner::WorkerThread::Run() + 144
    frame #3: 0x0000aaaaad896868 deno`v8::base::ThreadEntry(void*) + 136
    frame #4: 0x0000fffff7d7d5c8 libc.so.6`___lldb_unnamed_symbol3291 + 724
    frame #5: 0x0000fffff7de5edc libc.so.6`___lldb_unnamed_symbol3660 + 12
  thread #4, name = 'V8 DefaultWorke'
    frame #0: 0x0000fffff7d79df8 libc.so.6`___lldb_unnamed_symbol3262 + 200
    frame #1: 0x0000fffff7d7c8fc libc.so.6`pthread_cond_wait + 520
    frame #2: 0x0000aaaaad89fea0 deno`v8::platform::DefaultWorkerThreadsTaskRunner::WorkerThread::Run() + 144
    frame #3: 0x0000aaaaad896868 deno`v8::base::ThreadEntry(void*) + 136
    frame #4: 0x0000fffff7d7d5c8 libc.so.6`___lldb_unnamed_symbol3291 + 724
    frame #5: 0x0000fffff7de5edc libc.so.6`___lldb_unnamed_symbol3660 + 12
  thread #5, name = 'V8 DefaultWorke'
    frame #0: 0x0000fffff7d79df8 libc.so.6`___lldb_unnamed_symbol3262 + 200
    frame #1: 0x0000fffff7d7c8fc libc.so.6`pthread_cond_wait + 520
    frame #2: 0x0000aaaaad89fea0 deno`v8::platform::DefaultWorkerThreadsTaskRunner::WorkerThread::Run() + 144
    frame #3: 0x0000aaaaad896868 deno`v8::base::ThreadEntry(void*) + 136
    frame #4: 0x0000fffff7d7d5c8 libc.so.6`___lldb_unnamed_symbol3291 + 724
    frame #5: 0x0000fffff7de5edc libc.so.6`___lldb_unnamed_symbol3660 + 12
  thread #6, name = 'V8 DefaultWorke'
    frame #0: 0x0000fffff7d79df8 libc.so.6`___lldb_unnamed_symbol3262 + 200
    frame #1: 0x0000fffff7d7c8fc libc.so.6`pthread_cond_wait + 520
    frame #2: 0x0000aaaaad89fea0 deno`v8::platform::DefaultWorkerThreadsTaskRunner::WorkerThread::Run() + 144
    frame #3: 0x0000aaaaad896868 deno`v8::base::ThreadEntry(void*) + 136
    frame #4: 0x0000fffff7d7d5c8 libc.so.6`___lldb_unnamed_symbol3291 + 724
    frame #5: 0x0000fffff7de5edc libc.so.6`___lldb_unnamed_symbol3660 + 12
  thread #7, name = 'V8 DefaultWorke'
    frame #0: 0x0000fffff7d79df8 libc.so.6`___lldb_unnamed_symbol3262 + 200
    frame #1: 0x0000fffff7d7c8fc libc.so.6`pthread_cond_wait + 520
    frame #2: 0x0000aaaaad89fea0 deno`v8::platform::DefaultWorkerThreadsTaskRunner::WorkerThread::Run() + 144
    frame #3: 0x0000aaaaad896868 deno`v8::base::ThreadEntry(void*) + 136
    frame #4: 0x0000fffff7d7d5c8 libc.so.6`___lldb_unnamed_symbol3291 + 724
    frame #5: 0x0000fffff7de5edc libc.so.6`___lldb_unnamed_symbol3660 + 12
  thread #8, name = 'V8 DefaultWorke'
    frame #0: 0x0000fffff7d79df8 libc.so.6`___lldb_unnamed_symbol3262 + 200
    frame #1: 0x0000fffff7d7c8fc libc.so.6`pthread_cond_wait + 520
    frame #2: 0x0000aaaaad89fea0 deno`v8::platform::DefaultWorkerThreadsTaskRunner::WorkerThread::Run() + 144
    frame #3: 0x0000aaaaad896868 deno`v8::base::ThreadEntry(void*) + 136
    frame #4: 0x0000fffff7d7d5c8 libc.so.6`___lldb_unnamed_symbol3291 + 724
    frame #5: 0x0000fffff7de5edc libc.so.6`___lldb_unnamed_symbol3660 + 12
  thread #9, name = 'V8 DefaultWorke'
    frame #0: 0x0000fffff7d79df8 libc.so.6`___lldb_unnamed_symbol3262 + 200
    frame #1: 0x0000fffff7d7c8fc libc.so.6`pthread_cond_wait + 520
    frame #2: 0x0000aaaaad89fea0 deno`v8::platform::DefaultWorkerThreadsTaskRunner::WorkerThread::Run() + 144
    frame #3: 0x0000aaaaad896868 deno`v8::base::ThreadEntry(void*) + 136
    frame #4: 0x0000fffff7d7d5c8 libc.so.6`___lldb_unnamed_symbol3291 + 724
    frame #5: 0x0000fffff7de5edc libc.so.6`___lldb_unnamed_symbol3660 + 12
  thread #10, name = 'V8 DefaultWorke'
    frame #0: 0x0000fffff7d79df8 libc.so.6`___lldb_unnamed_symbol3262 + 200
    frame #1: 0x0000fffff7d7c8fc libc.so.6`pthread_cond_wait + 520
    frame #2: 0x0000aaaaad89fea0 deno`v8::platform::DefaultWorkerThreadsTaskRunner::WorkerThread::Run() + 144
    frame #3: 0x0000aaaaad896868 deno`v8::base::ThreadEntry(void*) + 136
    frame #4: 0x0000fffff7d7d5c8 libc.so.6`___lldb_unnamed_symbol3291 + 724
    frame #5: 0x0000fffff7de5edc libc.so.6`___lldb_unnamed_symbol3660 + 12
  thread #11, name = 'tokio-runtime-w'
    frame #0: 0x0000fffff7de1c24 libc.so.6`syscall + 36
    frame #1: 0x0000aaaab089c384 deno`_$LT$parking_lot_core..thread_parker..imp..ThreadParker$u20$as$u20$parking_lot_core..thread_parker..ThreadParkerT$GT$::park_until::hcd188b0b29c42938 + 136
    frame #2: 0x0000aaaab089d128 deno`parking_lot::condvar::Condvar::wait_until_internal::hd55ab2fcd912bb79 + 252
    frame #3: 0x0000aaaab08459a0 deno`std::sys_common::backtrace::__rust_begin_short_backtrace::hbf33c25a1e8912c5 + 548
    frame #4: 0x0000aaaab0847ed0 deno`core::ops::function::FnOnce::call_once$u7b$$u7b$vtable.shim$u7d$$u7d$::hdcabae7d0223c3f4 + 164
    frame #5: 0x0000aaaaaed9d418 deno`std::sys::pal::unix::thread::Thread::new::thread_start::haf793f2025a74235 + 52
    frame #6: 0x0000fffff7d7d5c8 libc.so.6`___lldb_unnamed_symbol3291 + 724
    frame #7: 0x0000fffff7de5edc libc.so.6`___lldb_unnamed_symbol3660 + 12
  thread #12, name = 'tokio-runtime-w'
    frame #0: 0x0000fffff7de1c24 libc.so.6`syscall + 36
    frame #1: 0x0000aaaab089c384 deno`_$LT$parking_lot_core..thread_parker..imp..ThreadParker$u20$as$u20$parking_lot_core..thread_parker..ThreadParkerT$GT$::park_until::hcd188b0b29c42938 + 136
    frame #2: 0x0000aaaab089d128 deno`parking_lot::condvar::Condvar::wait_until_internal::hd55ab2fcd912bb79 + 252
    frame #3: 0x0000aaaab08459a0 deno`std::sys_common::backtrace::__rust_begin_short_backtrace::hbf33c25a1e8912c5 + 548
    frame #4: 0x0000aaaab0847ed0 deno`core::ops::function::FnOnce::call_once$u7b$$u7b$vtable.shim$u7d$$u7d$::hdcabae7d0223c3f4 + 164
    frame #5: 0x0000aaaaaed9d418 deno`std::sys::pal::unix::thread::Thread::new::thread_start::haf793f2025a74235 + 52
    frame #6: 0x0000fffff7d7d5c8 libc.so.6`___lldb_unnamed_symbol3291 + 724
    frame #7: 0x0000fffff7de5edc libc.so.6`___lldb_unnamed_symbol3660 + 12
  thread #13, name = 'tokio-runtime-w'
    frame #0: 0x0000fffff7de1c24 libc.so.6`syscall + 36
    frame #1: 0x0000aaaab089c384 deno`_$LT$parking_lot_core..thread_parker..imp..ThreadParker$u20$as$u20$parking_lot_core..thread_parker..ThreadParkerT$GT$::park_until::hcd188b0b29c42938 + 136
    frame #2: 0x0000aaaab089d128 deno`parking_lot::condvar::Condvar::wait_until_internal::hd55ab2fcd912bb79 + 252
    frame #3: 0x0000aaaab08459a0 deno`std::sys_common::backtrace::__rust_begin_short_backtrace::hbf33c25a1e8912c5 + 548
    frame #4: 0x0000aaaab0847ed0 deno`core::ops::function::FnOnce::call_once$u7b$$u7b$vtable.shim$u7d$$u7d$::hdcabae7d0223c3f4 + 164
    frame #5: 0x0000aaaaaed9d418 deno`std::sys::pal::unix::thread::Thread::new::thread_start::haf793f2025a74235 + 52
    frame #6: 0x0000fffff7d7d5c8 libc.so.6`___lldb_unnamed_symbol3291 + 724
    frame #7: 0x0000fffff7de5edc libc.so.6`___lldb_unnamed_symbol3660 + 12
  thread #14, name = 'deno'
    frame #0: 0x0000fffff7de607c libc.so.6`epoll_pwait + 156
    frame #1: 0x0000aaaab0884778 deno`mio::poll::Poll::poll::h311122ee393af9b6 + 200
    frame #2: 0x0000aaaab0865f38 deno`tokio::runtime::io::driver::Driver::turn::h0b361a022580a73e + 344
    frame #3: 0x0000aaaab0868720 deno`tokio::runtime::time::Driver::park_internal::ha535b1807fb3fe4e + 736
    frame #4: 0x0000aaaab085ff84 deno`tokio::runtime::scheduler::current_thread::Context::park::h22cb4c5a5f7aa83a + 528
    frame #5: 0x0000aaaaaf719c68 deno`std::sys_common::backtrace::__rust_begin_short_backtrace::hb946e8317a5cefee + 2296
    frame #6: 0x0000aaaaaf72d654 deno`core::ops::function::FnOnce::call_once$u7b$$u7b$vtable.shim$u7d$$u7d$::ha7368470ebf8860a + 176
    frame #7: 0x0000aaaaaed9d418 deno`std::sys::pal::unix::thread::Thread::new::thread_start::haf793f2025a74235 + 52
    frame #8: 0x0000fffff7d7d5c8 libc.so.6`___lldb_unnamed_symbol3291 + 724
    frame #9: 0x0000fffff7de5edc libc.so.6`___lldb_unnamed_symbol3660 + 12
```
</details>
</summary>