deno icon indicating copy to clipboard operation
deno copied to clipboard

Segmentation fault (core dumped) error at startup on v1.46+

Open nberlette opened this issue 1 year ago • 13 comments

Version: Deno v1.46.1

I'm unable to import any of the files from my project starting with v1.46. Everything worked fine in v1.45.5.

To demonstrate, I've attached a quick screen recording below where I first attempt to start up the REPL and import a function named alias. It fails with a segfault error in v1.46.1. I then downgrade to v1.45.5 and attempt the same exact thing, and it imports it with no issues at all.

https://github.com/user-attachments/assets/fdf1c3d5-4458-4346-93cb-bdd74f398525

nberlette avatar Aug 24 '24 01:08 nberlette

I am not able to reproduce on Linux. Can you provide backtrace from a debugger like lldb?

littledivy avatar Aug 24 '24 03:08 littledivy

Of course. I'll run a backtrace on it shortly and post the results as soon as I have them

On Aug 23, 2024, at 8:56 PM, Divy Srivastava @.***> wrote:

I am not able to reproduce on Linux. Can you provide backtrace from a debugger like lldb?

— Reply to this email directly, view it on GitHub https://github.com/denoland/deno/issues/25192#issuecomment-2308039194, or unsubscribe https://github.com/notifications/unsubscribe-auth/ACVWWOGOOOJLLP7BBZPZEGTZTAAABAVCNFSM6AAAAABNBDNQB6VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDGMBYGAZTSMJZGQ. You are receiving this because you authored the thread.

nberlette avatar Aug 24 '24 04:08 nberlette

@littledivy Sorry it took so long. This isn't on my local machine (it's on a codespace instance) and I ran into a bunch of config issues trying to get lldb to work.

Here's the backtrace output from rust-lldb. I only included the real meat of the log, but if you want the entire thing just let me know. This seems to be the only relevant part though.

Thanks for your help!

* thread #4, name = 'tokio-runtime-w', stop reason = signal SIGSEGV: invalid permissions for mapped object (fault address: 0x79934c07dc20)
    frame #0: 0x000079934c07dc20
->  0x79934c07dc20: andb   $0x0, %al
    0x79934c07dc22: addb   %al, (%rax)
    0x79934c07dc24: xchgl  %ebx, %eax
    0x79934c07dc25: jns    0x79934c07dc27
(lldb) bt
* thread #4, name = 'tokio-runtime-w', stop reason = signal SIGSEGV: invalid permissions for mapped object (fault address: 0x79934c07dc20)
  * frame #0: 0x000079934c07dc20
    frame #1: 0x0000799360b91879 libgcc_s.so.1`___lldb_unnamed_symbol276 + 137
    frame #2: 0x0000799360b9214d libgcc_s.so.1`_Unwind_Resume + 397
    frame #3: 0x000061c20f10cebf deno`_$LT$swc_ecma_ast..typescript..TsAsExpr$u20$as$u20$swc_ecma_visit..generated..FoldWith$LT$V$GT$$GT$::fold_children_with::h821af894161de02f + 46
    frame #4: 0x000061c20f1063c7 deno`_$LT$alloc..boxed..Box$LT$T$GT$$u20$as$u20$swc_visit..util..map..Map$LT$T$GT$$GT$::map::hbf3c018b981e4f8a + 3085
    frame #5: 0x000061c20f10633e deno`_$LT$alloc..boxed..Box$LT$T$GT$$u20$as$u20$swc_visit..util..map..Map$LT$T$GT$$GT$::map::hbf3c018b981e4f8a + 2948
    frame #6: 0x000061c20f10acd4 deno`_$LT$swc_ecma_ast..expr..ParenExpr$u20$as$u20$swc_ecma_visit..generated..FoldWith$LT$V$GT$$GT$::fold_children_with::ha84f8e55acaf1737 + 25
    frame #7: 0x000061c20f10600b deno`_$LT$alloc..boxed..Box$LT$T$GT$$u20$as$u20$swc_visit..util..map..Map$LT$T$GT$$GT$::map::hbf3c018b981e4f8a + 2129
    frame #8: 0x000061c20f10ceaa deno`_$LT$swc_ecma_ast..typescript..TsAsExpr$u20$as$u20$swc_ecma_visit..generated..FoldWith$LT$V$GT$$GT$::fold_children_with::h821af894161de02f + 25
    frame #9: 0x000061c20f1063c7 deno`_$LT$alloc..boxed..Box$LT$T$GT$$u20$as$u20$swc_visit..util..map..Map$LT$T$GT$$GT$::map::hbf3c018b981e4f8a + 3085
    frame #10: 0x000061c20f1044ee deno`core::option::Option$LT$T$GT$::map::h74d952dd1bf9be3b + 17
    frame #11: 0x000061c20f10732b deno`_$LT$swc_ecma_ast..stmt..Stmt$u20$as$u20$swc_ecma_visit..generated..FoldWith$LT$V$GT$$GT$::fold_children_with::hd26d207793b1840d + 339
    frame #12: 0x000061c20f10d1f2 deno`_$LT$swc_ecma_utils..constructor..Injector$u20$as$u20$swc_ecma_visit..generated..Fold$GT$::fold_stmts::h62eec68dfd27330c + 270
    frame #13: 0x000061c20f10adcf deno`_$LT$swc_ecma_ast..stmt..BlockStmt$u20$as$u20$swc_ecma_visit..generated..FoldWith$LT$V$GT$$GT$::fold_children_with::h5052d946927a2b3c + 28
    frame #14: 0x000061c20f1076e6 deno`_$LT$swc_ecma_ast..stmt..Stmt$u20$as$u20$swc_ecma_visit..generated..FoldWith$LT$V$GT$$GT$::fold_children_with::hd26d207793b1840d + 1294
    frame #15: 0x000061c20f10d1f2 deno`_$LT$swc_ecma_utils..constructor..Injector$u20$as$u20$swc_ecma_visit..generated..Fold$GT$::fold_stmts::h62eec68dfd27330c + 270
    frame #16: 0x000061c20f10adcf deno`_$LT$swc_ecma_ast..stmt..BlockStmt$u20$as$u20$swc_ecma_visit..generated..FoldWith$LT$V$GT$$GT$::fold_children_with::h5052d946927a2b3c + 28
    frame #17: 0x000061c20f104550 deno`core::option::Option$LT$T$GT$::map::hc509a84199d50949 (.llvm.11817459882730434308) + 32
    frame #18: 0x000061c20f10cfeb deno`swc_ecma_utils::constructor::inject_after_super::hf9b6586d23b834b9 + 81
    frame #19: 0x000061c20f05ea6f deno`_$LT$swc_ecma_transforms_proposal..decorator_2022_03..Decorator2022_03$u20$as$u20$swc_ecma_visit..generated..VisitMut$GT$::visit_mut_class::h661318c16f611d29 + 624
    frame #20: 0x000061c20f065c9e deno`_$LT$swc_ecma_transforms_proposal..decorator_2022_03..Decorator2022_03$u20$as$u20$swc_ecma_visit..generated..VisitMut$GT$::visit_mut_module_items::hd975114cd76889d7 + 754
    frame #21: 0x000061c20eff19a2 deno`_$LT$swc_ecma_ast..module..Program$u20$as$u20$swc_ecma_visit..generated..FoldWith$LT$V$GT$$GT$::fold_with::he57b76433bfcdae6 + 1738
    frame #22: 0x000061c20f0153b6 deno`deno_ast::transpiling::fold_program::h13b0c8ce7d8d627a + 4297
    frame #23: 0x000061c20f013e07 deno`deno_ast::transpiling::transpile::hd4122acdc0a3ba69 + 285
    frame #24: 0x000061c20f013673 deno`deno_ast::transpiling::_$LT$impl$u20$deno_ast..parsed_source..ParsedSource$GT$::transpile::he6239135a75f8987 + 577
    frame #25: 0x000061c20d4b4142 deno`deno::emit::EmitParsedSourceHelper::transpile::h9e6bdeabdf331285 + 754
    frame #26: 0x000061c20d31c0f5 deno`tokio::runtime::task::raw::poll::h8762b0edd1042283 + 221
    frame #27: 0x000061c20f40f590 deno`std::sys_common::backtrace::__rust_begin_short_backtrace::h441af42626d0a10d + 432
    frame #28: 0x000061c20f411d12 deno`core::ops::function::FnOnce::call_once$u7b$$u7b$vtable.shim$u7d$$u7d$::h506cb4efabbeeb1b + 162
    frame #29: 0x000061c20d0c032b deno`std::sys::pal::unix::thread::Thread::new::thread_start::hb85dbfa54ba503d6 + 43
    frame #30: 0x0000799360b5cea7 libpthread.so.0`start_thread + 215
    frame #31: 0x0000799360938a6f libc.so.6`__clone + 63

nberlette avatar Aug 26 '24 01:08 nberlette

@littledivy based on the backtrace line frame #19: ... _$LT$swc_ecma_transforms_proposal..decorator_2022_03, I figured it must be at least related to the SWC decorators helper. So I tried removing all traces of decorators from one particular file, and bingo, it works as it should.


[!NOTE] Upon further inspection, it appears my previous statements were incorrect, and so I both apologize and retract what I said regarding the footprint of this bug. This appears now to be something specifically caused by the right combination of conditions in my particular codebase. It is not preventing the usage of Stage 3 decorators entirely, and it should not be impeding everyday users from being able to use them in their project. Sorry for jumping to conclusions 😟

nberlette avatar Sep 01 '24 18:09 nberlette

@nberlette can you share your code that uses decorators that caused this problem?

bartlomieju avatar Sep 02 '24 08:09 bartlomieju

@bartlomieju I've done some further investigation and narrowed down the issue. It looks like the error is specifically triggered by the use of the @bind decorator on a getter in one of the classes. This class is used extensively across the monorepo, which initially led me to mistakenly think the problem was with all decorators. I realized this mistake last night and meant to update my previous comments, but it seems I forgot to hit submit. Sorry about that.

I've included a simplified example of the code below. However, this snippet doesn't reproduce the segfault on its own, so it's unlikely to be very helpful without additional context. This bug is proving to be particularly elusive, and giving me some difficultly in coming up with an isolated minimal reproduction. Since the repo isn't public yet, I'm reluctant to share the full source here... but I'm more than happy to send you the complete file (or even the whole module graph) through a more private channel (email or Discord?) if that works for you.

// Simplified version of the working code
class WeakStorage<K extends WeakKey, V> {
  #storage = new WeakMap<WeakCollection<K, V>, WeakStorageArea<K, V>>();

  // Without the @bind decorator on 'storage', this works fine
  get storage(): WeakStorageArea {
    return this.#storage;
  }

  // ... 
}

// However, when I add the 'bind' decorator to the 'storage' getter (with no other changes) -> segfault
import { bind } from "jsr:@decorators/bind@^0.1.2";

class WeakStorage<K extends WeakKey, V> {
  #storage = new WeakMap<WeakCollection<K, V>, WeakStorageArea>();

  @bind get storage(): WeakStorageArea {
    return this.#storage;
  }

  // ...
}

nberlette avatar Sep 02 '24 10:09 nberlette

Yeah Discord would definitely work, thanks!

bartlomieju avatar Sep 02 '24 10:09 bartlomieju

I ran into this issue as well. And in my case it was caused by... as any assertion. I have a class with methods decorated with a memo decorator and the code refuses to run (no error or anything) if there's any assertion in the constructor. Here's a minimal reproduction:

function memo(
  fn: (this: Data, id: number) => string,
  _ctx: ClassMethodDecoratorContext,
) {
  const cache = new Map<number, string>();
  return function (this: Data, id: number): string {
    const val = cache.get(id);
    if (val) return val;
    const str = fn.call(this, id);
    cache.set(id, str);
    return str;
  };
}

export class Data {
  constructor() {
    const a = 1 as any;
  }

  @memo
  m(id: number): string {
    return "";
  }
}

greentore avatar Sep 10 '24 02:09 greentore


============================================================
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.3
Args: ["/home/divy/gh/deno/target/debug/deno", "run", "-A", "crash.ts"]

thread 'tokio-runtime-worker' panicked at /home/divy/.cargo/registry/src/index.crates.io-6f17d22bba15001f/swc_ecma_visit-0.104.8/src/lib.rs:552:9:
internal error: entered unreachable code: This visitor does not support TypeScript. This method fails for optimization purposes. Encountered in unreachable visitor: visit_mut_ts_type
stack backtrace:
   0: rust_begin_unwind
             at /rustc/3f5fd8dd41153bc5fdca9427e9e05be2c767ba23/library/std/src/panicking.rs:652:5
   1: core::panicking::panic_fmt
             at /rustc/3f5fd8dd41153bc5fdca9427e9e05be2c767ba23/library/core/src/panicking.rs:72:14
   2: swc_ecma_visit::fail_no_typescript
             at /home/divy/.cargo/registry/src/index.crates.io-6f17d22bba15001f/swc_ecma_visit-0.104.8/src/lib.rs:552:9
   3: <swc_ecma_utils::constructor::ExprInjector as swc_ecma_visit::generated::VisitMut>::visit_mut_ts_type
             at /home/divy/.cargo/registry/src/index.crates.io-6f17d22bba15001f/swc_ecma_visit-0.104.8/src/lib.rs:909:13
   4: <swc_ecma_ast::typescript::TsType as swc_ecma_visit::generated::VisitMutWith<V>>::visit_mut_with
             at /home/divy/.cargo/registry/src/index.crates.io-6f17d22bba15001f/swc_ecma_visit-0.104.8/src/generated.rs:63552:9
   5: <alloc::boxed::Box<T> as swc_ecma_visit::generated::VisitMutWith<V>>::visit_mut_with
             at /home/divy/.cargo/registry/src/index.crates.io-6f17d22bba15001f/swc_ecma_visit-0.104.8/src/generated.rs:65038:17
   6: <swc_ecma_ast::typescript::TsAsExpr as swc_ecma_visit::generated::VisitMutWith<V>>::visit_mut_children_with
             at /home/divy/.cargo/registry/src/index.crates.io-6f17d22bba15001f/swc_ecma_visit-0.104.8/src/generated.rs:62260:21
   7: swc_ecma_visit::generated::VisitMut::visit_mut_ts_as_expr
             at /home/divy/.cargo/registry/src/index.crates.io-6f17d22bba15001f/swc_ecma_visit-0.104.8/src/generated.rs:49818:9
   8: <swc_ecma_ast::typescript::TsAsExpr as swc_ecma_visit::generated::VisitMutWith<V>>::visit_mut_with
             at /home/divy/.cargo/registry/src/index.crates.io-6f17d22bba15001f/swc_ecma_visit-0.104.8/src/generated.rs:62243:9
   9: <swc_ecma_ast::expr::Expr as swc_ecma_visit::generated::VisitMutWith<V>>::visit_mut_children_with
             at /home/divy/.cargo/registry/src/index.crates.io-6f17d22bba15001f/swc_ecma_visit-0.104.8/src/generated.rs:59775:17
  10: <swc_ecma_utils::constructor::ExprInjector as swc_ecma_visit::generated::VisitMut>::visit_mut_expr
             at /home/divy/.cargo/registry/src/index.crates.io-6f17d22bba15001f/swc_ecma_utils-0.134.2/src/constructor.rs:129:9
  11: <swc_ecma_ast::expr::Expr as swc_ecma_visit::generated::VisitMutWith<V>>::visit_mut_with
             at /home/divy/.cargo/registry/src/index.crates.io-6f17d22bba15001f/swc_ecma_visit-0.104.8/src/generated.rs:59673:9
  12: <alloc::boxed::Box<T> as swc_ecma_visit::generated::VisitMutWith<V>>::visit_mut_with
             at /home/divy/.cargo/registry/src/index.crates.io-6f17d22bba15001f/swc_ecma_visit-0.104.8/src/generated.rs:65038:17
  13: <swc_ecma_ast::stmt::ExprStmt as swc_ecma_visit::generated::VisitMutWith<V>>::visit_mut_children_with
             at /home/divy/.cargo/registry/src/index.crates.io-6f17d22bba15001f/swc_ecma_visit-0.104.8/src/generated.rs:59827:21
  14: swc_ecma_visit::generated::VisitMut::visit_mut_expr_stmt
             at /home/divy/.cargo/registry/src/index.crates.io-6f17d22bba15001f/swc_ecma_visit-0.104.8/src/generated.rs:48808:9
  15: <swc_ecma_ast::stmt::ExprStmt as swc_ecma_visit::generated::VisitMutWith<V>>::visit_mut_with
             at /home/divy/.cargo/registry/src/index.crates.io-6f17d22bba15001f/swc_ecma_visit-0.104.8/src/generated.rs:59817:9
  16: <swc_ecma_ast::stmt::Stmt as swc_ecma_visit::generated::VisitMutWith<V>>::visit_mut_children_with
             at /home/divy/.cargo/registry/src/index.crates.io-6f17d22bba15001f/swc_ecma_visit-0.104.8/src/generated.rs:61922:17
  17: swc_ecma_visit::generated::VisitMut::visit_mut_stmt
             at /home/divy/.cargo/registry/src/index.crates.io-6f17d22bba15001f/swc_ecma_visit-0.104.8/src/generated.rs:49686:9
  18: <swc_ecma_ast::stmt::Stmt as swc_ecma_visit::generated::VisitMutWith<V>>::visit_mut_with
             at /home/divy/.cargo/registry/src/index.crates.io-6f17d22bba15001f/swc_ecma_visit-0.104.8/src/generated.rs:61862:9
  19: <swc_ecma_utils::constructor::Injector as swc_ecma_visit::generated::Fold>::fold_stmts::{{closure}}
             at /home/divy/.cargo/registry/src/index.crates.io-6f17d22bba15001f/swc_ecma_utils-0.134.2/src/constructor.rs:86:17
  20: core::iter::traits::iterator::Iterator::for_each::call::{{closure}}
             at /rustc/3f5fd8dd41153bc5fdca9427e9e05be2c767ba23/library/core/src/iter/traits/iterator.rs:815:29
  21: <alloc::vec::into_iter::IntoIter<T,A> as core::iter::traits::iterator::Iterator>::fold
             at /rustc/3f5fd8dd41153bc5fdca9427e9e05be2c767ba23/library/alloc/src/vec/into_iter.rs:312:25
  22: core::iter::traits::iterator::Iterator::for_each
             at /rustc/3f5fd8dd41153bc5fdca9427e9e05be2c767ba23/library/core/src/iter/traits/iterator.rs:818:9
  23: <swc_ecma_utils::constructor::Injector as swc_ecma_visit::generated::Fold>::fold_stmts
             at /home/divy/.cargo/registry/src/index.crates.io-6f17d22bba15001f/swc_ecma_utils-0.134.2/src/constructor.rs:58:9
  24: <alloc::vec::Vec<swc_ecma_ast::stmt::Stmt> as swc_ecma_visit::generated::FoldWith<V>>::fold_with
             at /home/divy/.cargo/registry/src/index.crates.io-6f17d22bba15001f/swc_ecma_visit-0.104.8/src/generated.rs:107852:9
  25: <swc_ecma_ast::stmt::BlockStmt as swc_ecma_visit::generated::FoldWith<V>>::fold_children_with
             at /home/divy/.cargo/registry/src/index.crates.io-6f17d22bba15001f/swc_ecma_visit-0.104.8/src/generated.rs:101973:31
  26: swc_ecma_visit::generated::Fold::fold_block_stmt
             at /home/divy/.cargo/registry/src/index.crates.io-6f17d22bba15001f/swc_ecma_visit-0.104.8/src/generated.rs:91478:9
  27: <swc_ecma_ast::stmt::BlockStmt as swc_ecma_visit::generated::FoldWith<V>>::fold_with
             at /home/divy/.cargo/registry/src/index.crates.io-6f17d22bba15001f/swc_ecma_visit-0.104.8/src/generated.rs:101965:9
  28: <core::option::Option<swc_ecma_ast::stmt::BlockStmt> as swc_ecma_visit::generated::FoldWith<V>>::fold_children_with::{{closure}}
             at /home/divy/.cargo/registry/src/index.crates.io-6f17d22bba15001f/swc_ecma_visit-0.104.8/src/generated.rs:107497:26
  29: core::option::Option<T>::map
             at /rustc/3f5fd8dd41153bc5fdca9427e9e05be2c767ba23/library/core/src/option.rs:1075:29
  30: <core::option::Option<swc_ecma_ast::stmt::BlockStmt> as swc_ecma_visit::generated::FoldWith<V>>::fold_children_with
             at /home/divy/.cargo/registry/src/index.crates.io-6f17d22bba15001f/swc_ecma_visit-0.104.8/src/generated.rs:107497:9
  31: swc_ecma_visit::generated::Fold::fold_opt_block_stmt
             at /home/divy/.cargo/registry/src/index.crates.io-6f17d22bba15001f/swc_ecma_visit-0.104.8/src/generated.rs:92245:9
  32: <core::option::Option<swc_ecma_ast::stmt::BlockStmt> as swc_ecma_visit::generated::FoldWith<V>>::fold_with
             at /home/divy/.cargo/registry/src/index.crates.io-6f17d22bba15001f/swc_ecma_visit-0.104.8/src/generated.rs:107492:9
  33: swc_ecma_utils::constructor::inject_after_super
             at /home/divy/.cargo/registry/src/index.crates.io-6f17d22bba15001f/swc_ecma_utils-0.134.2/src/constructor.rs:16:14
  34: <swc_ecma_transforms_proposal::decorator_impl::DecoratorPass as swc_ecma_visit::generated::VisitMut>::visit_mut_class
             at /home/divy/.cargo/registry/src/index.crates.io-6f17d22bba15001f/swc_ecma_transforms_proposal-0.179.0/src/decorator_impl.rs:821:17
  35: <swc_ecma_ast::class::Class as swc_ecma_visit::generated::VisitMutWith<V>>::visit_mut_with
             at /home/divy/.cargo/registry/src/index.crates.io-6f17d22bba15001f/swc_ecma_visit-0.104.8/src/generated.rs:59023:9
  36: <alloc::boxed::Box<T> as swc_ecma_visit::generated::VisitMutWith<V>>::visit_mut_with
             at /home/divy/.cargo/registry/src/index.crates.io-6f17d22bba15001f/swc_ecma_visit-0.104.8/src/generated.rs:65038:17
  37: <swc_ecma_ast::decl::ClassDecl as swc_ecma_visit::generated::VisitMutWith<V>>::visit_mut_children_with
             at /home/divy/.cargo/registry/src/index.crates.io-6f17d22bba15001f/swc_ecma_visit-0.104.8/src/generated.rs:59092:21
  38: swc_ecma_visit::generated::VisitMut::visit_mut_class_decl
             at /home/divy/.cargo/registry/src/index.crates.io-6f17d22bba15001f/swc_ecma_visit-0.104.8/src/generated.rs:48598:9
  39: <swc_ecma_ast::decl::ClassDecl as swc_ecma_visit::generated::VisitMutWith<V>>::visit_mut_with
             at /home/divy/.cargo/registry/src/index.crates.io-6f17d22bba15001f/swc_ecma_visit-0.104.8/src/generated.rs:59078:9
  40: <swc_ecma_ast::decl::Decl as swc_ecma_visit::generated::VisitMutWith<V>>::visit_mut_children_with
             at /home/divy/.cargo/registry/src/index.crates.io-6f17d22bba15001f/swc_ecma_visit-0.104.8/src/generated.rs:59379:17
  41: swc_ecma_visit::generated::VisitMut::visit_mut_decl
             at /home/divy/.cargo/registry/src/index.crates.io-6f17d22bba15001f/swc_ecma_visit-0.104.8/src/generated.rs:48675:9
  42: <swc_ecma_ast::decl::Decl as swc_ecma_visit::generated::VisitMutWith<V>>::visit_mut_with
             at /home/divy/.cargo/registry/src/index.crates.io-6f17d22bba15001f/swc_ecma_visit-0.104.8/src/generated.rs:59373:9
  43: <swc_ecma_ast::stmt::Stmt as swc_ecma_visit::generated::VisitMutWith<V>>::visit_mut_children_with
             at /home/divy/.cargo/registry/src/index.crates.io-6f17d22bba15001f/swc_ecma_visit-0.104.8/src/generated.rs:61919:17
  44: <swc_ecma_transforms_proposal::decorator_impl::DecoratorPass as swc_ecma_visit::generated::VisitMut>::visit_mut_stmt
             at /home/divy/.cargo/registry/src/index.crates.io-6f17d22bba15001f/swc_ecma_transforms_proposal-0.179.0/src/decorator_impl.rs:1791:17
  45: <swc_ecma_ast::stmt::Stmt as swc_ecma_visit::generated::VisitMutWith<V>>::visit_mut_with
             at /home/divy/.cargo/registry/src/index.crates.io-6f17d22bba15001f/swc_ecma_visit-0.104.8/src/generated.rs:61862:9
  46: <swc_ecma_ast::module::ModuleItem as swc_ecma_visit::generated::VisitMutWith<V>>::visit_mut_children_with
             at /home/divy/.cargo/registry/src/index.crates.io-6f17d22bba15001f/swc_ecma_visit-0.104.8/src/generated.rs:61085:17
  47: <swc_ecma_transforms_proposal::decorator_impl::DecoratorPass as swc_ecma_visit::generated::VisitMut>::visit_mut_module_item
             at /home/divy/.cargo/registry/src/index.crates.io-6f17d22bba15001f/swc_ecma_transforms_proposal-0.179.0/src/decorator_impl.rs:1585:17
  48: <swc_ecma_ast::module::ModuleItem as swc_ecma_visit::generated::VisitMutWith<V>>::visit_mut_with
             at /home/divy/.cargo/registry/src/index.crates.io-6f17d22bba15001f/swc_ecma_visit-0.104.8/src/generated.rs:61076:9
  49: <swc_ecma_transforms_proposal::decorator_impl::DecoratorPass as swc_ecma_visit::generated::VisitMut>::visit_mut_module_items
             at /home/divy/.cargo/registry/src/index.crates.io-6f17d22bba15001f/swc_ecma_transforms_proposal-0.179.0/src/decorator_impl.rs:1599:13
  50: <alloc::vec::Vec<swc_ecma_ast::module::ModuleItem> as swc_ecma_visit::generated::VisitMutWith<V>>::visit_mut_with
             at /home/divy/.cargo/registry/src/index.crates.io-6f17d22bba15001f/swc_ecma_visit-0.104.8/src/generated.rs:64398:9
  51: <swc_ecma_ast::module::Module as swc_ecma_visit::generated::VisitMutWith<V>>::visit_mut_children_with
             at /home/divy/.cargo/registry/src/index.crates.io-6f17d22bba15001f/swc_ecma_visit-0.104.8/src/generated.rs:61009:21
  52: swc_ecma_visit::generated::VisitMut::visit_mut_module
             at /home/divy/.cargo/registry/src/index.crates.io-6f17d22bba15001f/swc_ecma_visit-0.104.8/src/generated.rs:49214:9
  53: <swc_ecma_ast::module::Module as swc_ecma_visit::generated::VisitMutWith<V>>::visit_mut_with
             at /home/divy/.cargo/registry/src/index.crates.io-6f17d22bba15001f/swc_ecma_visit-0.104.8/src/generated.rs:60995:9
  54: <swc_ecma_ast::module::Program as swc_ecma_visit::generated::VisitMutWith<V>>::visit_mut_children_with
             at /home/divy/.cargo/registry/src/index.crates.io-6f17d22bba15001f/swc_ecma_visit-0.104.8/src/generated.rs:61547:17
  55: swc_ecma_visit::generated::VisitMut::visit_mut_program
             at /home/divy/.cargo/registry/src/index.crates.io-6f17d22bba15001f/swc_ecma_visit-0.104.8/src/generated.rs:49581:9
  56: <swc_ecma_ast::module::Program as swc_ecma_visit::generated::VisitMutWith<V>>::visit_mut_with
             at /home/divy/.cargo/registry/src/index.crates.io-6f17d22bba15001f/swc_ecma_visit-0.104.8/src/generated.rs:61541:9
  57: <swc_ecma_visit::Folder<V> as swc_ecma_visit::generated::Fold>::fold_program
             at /home/divy/.cargo/registry/src/index.crates.io-6f17d22bba15001f/swc_ecma_visit-0.104.8/src/lib.rs:292:13
  58: <swc_visit::Optional<V> as swc_ecma_visit::generated::Fold>::fold_program
             at /home/divy/.cargo/registry/src/index.crates.io-6f17d22bba15001f/swc_ecma_visit-0.104.8/src/generated.rs:100405:13
  59: swc_ecma_visit::<impl swc_ecma_visit::generated::Fold for swc_visit::AndThen<A,B>>::fold_program
             at /home/divy/.cargo/registry/src/index.crates.io-6f17d22bba15001f/swc_ecma_visit-0.104.8/src/lib.rs:26:17
  60: swc_ecma_visit::<impl swc_ecma_visit::generated::Fold for swc_visit::AndThen<A,B>>::fold_program
             at /home/divy/.cargo/registry/src/index.crates.io-6f17d22bba15001f/swc_ecma_visit-0.104.8/src/lib.rs:27:9
  61: swc_ecma_visit::<impl swc_ecma_visit::generated::Fold for swc_visit::AndThen<A,B>>::fold_program
             at /home/divy/.cargo/registry/src/index.crates.io-6f17d22bba15001f/swc_ecma_visit-0.104.8/src/lib.rs:27:9
  62: swc_ecma_visit::<impl swc_ecma_visit::generated::Fold for swc_visit::AndThen<A,B>>::fold_program
             at /home/divy/.cargo/registry/src/index.crates.io-6f17d22bba15001f/swc_ecma_visit-0.104.8/src/lib.rs:27:9
  63: <swc_ecma_ast::module::Program as swc_ecma_visit::generated::FoldWith<V>>::fold_with
             at /home/divy/.cargo/registry/src/index.crates.io-6f17d22bba15001f/swc_ecma_visit-0.104.8/src/generated.rs:104610:9
  64: deno_ast::transpiling::fold_program::{{closure}}::{{closure}}
             at /home/divy/.cargo/registry/src/index.crates.io-6f17d22bba15001f/deno_ast-0.42.0/src/transpiling/mod.rs:489:7
  65: scoped_tls::ScopedKey<T>::set
             at /home/divy/.cargo/registry/src/index.crates.io-6f17d22bba15001f/scoped-tls-1.0.1/src/lib.rs:137:9
  66: better_scoped_tls::ScopedKey<T>::set
             at /home/divy/.cargo/registry/src/index.crates.io-6f17d22bba15001f/better_scoped_tls-0.1.1/src/lib.rs:55:9
  67: deno_ast::transpiling::fold_program::{{closure}}
             at /home/divy/.cargo/registry/src/index.crates.io-6f17d22bba15001f/deno_ast-0.42.0/src/transpiling/mod.rs:488:5
  68: scoped_tls::ScopedKey<T>::set
             at /home/divy/.cargo/registry/src/index.crates.io-6f17d22bba15001f/scoped-tls-1.0.1/src/lib.rs:137:9
  69: better_scoped_tls::ScopedKey<T>::set
             at /home/divy/.cargo/registry/src/index.crates.io-6f17d22bba15001f/better_scoped_tls-0.1.1/src/lib.rs:55:9
  70: deno_ast::transpiling::fold_program
             at /home/divy/.cargo/registry/src/index.crates.io-6f17d22bba15001f/deno_ast-0.42.0/src/transpiling/mod.rs:487:16
  71: deno_ast::transpiling::transpile::{{closure}}
             at /home/divy/.cargo/registry/src/index.crates.io-6f17d22bba15001f/deno_ast-0.42.0/src/transpiling/mod.rs:337:5
  72: deno_ast::parsed_source::Globals::with::{{closure}}
             at /home/divy/.cargo/registry/src/index.crates.io-6f17d22bba15001f/deno_ast-0.42.0/src/parsed_source.rs:54:55
  73: scoped_tls::ScopedKey<T>::set
             at /home/divy/.cargo/registry/src/index.crates.io-6f17d22bba15001f/scoped-tls-1.0.1/src/lib.rs:137:9
  74: better_scoped_tls::ScopedKey<T>::set
             at /home/divy/.cargo/registry/src/index.crates.io-6f17d22bba15001f/better_scoped_tls-0.1.1/src/lib.rs:55:9
  75: deno_ast::parsed_source::Globals::with
             at /home/divy/.cargo/registry/src/index.crates.io-6f17d22bba15001f/deno_ast-0.42.0/src/parsed_source.rs:54:5
  76: deno_ast::transpiling::transpile
             at /home/divy/.cargo/registry/src/index.crates.io-6f17d22bba15001f/deno_ast-0.42.0/src/transpiling/mod.rs:336:17
  77: deno_ast::transpiling::<impl deno_ast::parsed_source::ParsedSource>::transpile_owned
             at /home/divy/.cargo/registry/src/index.crates.io-6f17d22bba15001f/deno_ast-0.42.0/src/transpiling/mod.rs:267:8
  78: deno_ast::transpiling::<impl deno_ast::parsed_source::ParsedSource>::transpile
             at /home/divy/.cargo/registry/src/index.crates.io-6f17d22bba15001f/deno_ast-0.42.0/src/transpiling/mod.rs:207:11
  79: deno::emit::EmitParsedSourceHelper::transpile
             at /home/divy/gh/deno/cli/emit.rs:266:8
  80: deno::emit::Emitter::emit_parsed_source::{{closure}}::{{closure}}
             at /home/divy/gh/deno/cli/emit.rs:119:13
  81: deno_unsync::tokio::task::spawn_blocking::{{closure}}
             at /home/divy/.cargo/registry/src/index.crates.io-6f17d22bba15001f/deno_unsync-0.4.1/src/tokio/task.rs:76:74
  82: <tokio::runtime::blocking::task::BlockingTask<T> as core::future::future::Future>::poll
             at /home/divy/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.36.0/src/runtime/blocking/task.rs:42:21
  83: tokio::runtime::task::core::Core<T,S>::poll::{{closure}}
             at /home/divy/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.36.0/src/runtime/task/core.rs:328:17
  84: tokio::loom::std::unsafe_cell::UnsafeCell<T>::with_mut
             at /home/divy/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.36.0/src/loom/std/unsafe_cell.rs:16:9
  85: tokio::runtime::task::core::Core<T,S>::poll
             at /home/divy/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.36.0/src/runtime/task/core.rs:317:13
  86: tokio::runtime::task::harness::poll_future::{{closure}}
             at /home/divy/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.36.0/src/runtime/task/harness.rs:485:19
  87: <core::panic::unwind_safe::AssertUnwindSafe<F> as core::ops::function::FnOnce<()>>::call_once
             at /rustc/3f5fd8dd41153bc5fdca9427e9e05be2c767ba23/library/core/src/panic/unwind_safe.rs:272:9
  88: std::panicking::try::do_call
             at /rustc/3f5fd8dd41153bc5fdca9427e9e05be2c767ba23/library/std/src/panicking.rs:559:40
  89: __rust_try
  90: std::panicking::try
             at /rustc/3f5fd8dd41153bc5fdca9427e9e05be2c767ba23/library/std/src/panicking.rs:523:19
  91: std::panic::catch_unwind
             at /rustc/3f5fd8dd41153bc5fdca9427e9e05be2c767ba23/library/std/src/panic.rs:149:14
  92: tokio::runtime::task::harness::poll_future
             at /home/divy/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.36.0/src/runtime/task/harness.rs:473:18
  93: tokio::runtime::task::harness::Harness<T,S>::poll_inner
             at /home/divy/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.36.0/src/runtime/task/harness.rs:208:27
  94: tokio::runtime::task::harness::Harness<T,S>::poll
             at /home/divy/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.36.0/src/runtime/task/harness.rs:153:15
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.

Backtrace with debug build and following script:

function memo() {}

class Data {
  constructor() {
    1 as any // works if I comment this line
  }

  @memo
  m() {}
}

littledivy avatar Sep 19 '24 17:09 littledivy

@dsherret maybe there is a misconfigured visitor in deno_ast? need some help :)

littledivy avatar Sep 19 '24 17:09 littledivy

Same issue! (see Known [email protected])

Just one-line error message (on Ubuntu 20.04.6 LTS):

[1]    139572 segmentation fault (core dumped)  deno test --allow-read --allow-net ../lib

The same issue appears also on Windows 11 WSL.

nmtigor avatar Oct 16 '24 15:10 nmtigor

To simplify the reproduction, add a file /path_to/set.ts/src/test/segfault.ts with contents

import { Bufr } from "../lib/compiling/Bufr.ts";

new Bufr();

Then run with deno 2.0.0

deno test segfault.ts

It outputs

[1]    141274 segmentation fault (core dumped)  deno test segfault.ts

The same issue appears with deno run segfault.ts.

With deno 1.45.5, there are no issues.

nmtigor avatar Oct 16 '24 15:10 nmtigor

Not sure if this is related, but I've also been seeing occasional segfaults in the CI of deployctl. Sometimes it succeeds though.

https://github.com/denoland/deployctl/actions/runs/11402529122/job/31728939591#step:8:149

/home/runner/work/_temp/811c36e8-49ba-4291-b595-443655b47377.sh: line 4:  1970 Segmentation fault      (core dumped) deno run --allow-read --allow-env --allow-net ./tools/bundle.ts ./src/utils/mod.ts > ./action/latest.deps.js
Error: Process completed with exit code 139.

magurotuna avatar Oct 18 '24 11:10 magurotuna

I just ran into this Segmentation fault on the bind decorator as well. Strangely, I didn't have to remove all usage (it only caused a crash in certain places, but not sure what the common theme is)

I think the name of this Github issue should probably be renamed to something like Segmentation fault (core dumped) error on bind decorator so that it's clear what this issue is tracking

Also, I wonder if the SWC issue is related to https://github.com/denoland/deno/issues/24745

SebastienGllmt avatar Dec 05 '24 11:12 SebastienGllmt

With deno 2.2.3, it already works fine by me. Thanks!

nmtigor avatar Mar 11 '25 07:03 nmtigor