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

SWC has a segfault condition #8840

Closed
kdy1 opened this issue Apr 11, 2024 · 33 comments · Fixed by #8867
Closed

SWC has a segfault condition #8840

kdy1 opened this issue Apr 11, 2024 · 33 comments · Fixed by #8867
Milestone

Comments

@kdy1 kdy1 self-assigned this Apr 11, 2024
@bgw
Copy link

bgw commented Apr 11, 2024

While reproducing vercel/next.js#63924 in valgrind:

==153952== Thread 18 tokio-runtime-w:
==153952== Conditional jump or move depends on uninitialised value(s)
==153952==	at 0x240FC324: swc_ecma_parser::parser::expr::ops::<impl swc_ecma_parser::parser::Parser<I>>::parse_unary_expr (ops.rs:0)
==153952==	by 0x240FA153: swc_ecma_parser::parser::expr::ops::<impl swc_ecma_parser::parser::Parser<I>>::parse_bin_expr (ops.rs:14)
==153952==	by 0x240FE1B3: parse_cond_expr<swc_ecma_parser::lexer::Lexer> (expr.rs:217)
==153952==	by 0x240FE1B3: swc_ecma_parser::parser::expr::<impl swc_ecma_parser::parser::Parser<I>>::parse_assignment_expr_base (expr.rs:140)
==153952==	by 0x240FD533: swc_ecma_parser::parser::expr::<impl swc_ecma_parser::parser::Parser<I>>::parse_assignment_expr (expr.rs:72)
==153952==	by 0x240FCF87: swc_ecma_parser::parser::expr::<impl swc_ecma_parser::parser::Parser<I>>::parse_expr (expr.rs:18)
==153952==	by 0x240916A7: {closure#0} (lib.rs:505)
==153952==	by 0x240916A7: with_file_parser<alloc::boxed::Box<swc_ecma_ast::expr::Expr, alloc::alloc::Global>, swc_ecma_parser::parse_file_as_expr::{closure_env#0}> (lib.rs:473)
==153952==	by 0x240916A7: swc_ecma_parser::parse_file_as_expr (lib.rs:497)
==153952==	by 0x23DFBE2F: swc_ecma_transforms_react::jsx::parse_expr_for_jsx (mod.rs:123)
==153952==	by 0x2104918F: swc_ecma_transforms_react::jsx::jsx (mod.rs:209)
==153952==	by 0x20F2B707: swc_ecma_transforms_react::react (lib.rs:63)
==153952==	by 0x2089E03F: {async_fn#0} (mod.rs:178)
==153952==	by 0x2089E03F: {async_block#1} (parse.rs:394)
==153952==	by 0x2089E03F: {closure#0} (parse.rs:429)
==153952==	by 0x2089E03F: scoped_tls::ScopedKey<T>::set (lib.rs:137)
==153952==	by 0x208A001B: {closure#0} (parse.rs:429)
==153952==	by 0x208A001B: scoped_tls::ScopedKey<T>::set (lib.rs:137)
==153952==	by 0x2089CA6F: {closure#0} (parse.rs:429)
==153952==	by 0x2089CA6F: scoped_tls::ScopedKey<T>::set (lib.rs:137)
==153952==  Uninitialised value was created by a stack allocation
==153952==	at 0x240B8F34: swc_ecma_parser::parser::input::Buffer<I>::had_line_break_before_cur (input.rs:351)

@kdy1 kdy1 removed their assignment Apr 11, 2024
@kdy1 kdy1 added this to the Planned milestone Apr 11, 2024
@dsherret
Copy link
Contributor

dsherret commented Apr 11, 2024

This is the latest valgrind output I get.

Output
$ rm -rf deno_dir ; DENO_DIR=$(pwd)/deno_dir ./valgrind-3.22.0/coregrind/valgrind --tool=memcheck --track-origins=yes ./deno run https://deno.land/x/dax@0.39.2/mod.ts
==14552== Memcheck, a memory error detector
==14552== Copyright (C) 2002-2022, and GNU GPL'd, by Julian Seward et al.
==14552== Using Valgrind-3.22.0 and LibVEX; rerun with -h for copyright info
==14552== Command: ./deno run https://deno.land/x/dax@0.39.2/mod.ts
==14552==
==14552== Warning: set address range perms: large range [0x70600000000, 0x709fffff000) (noaccess)
==14552== Warning: set address range perms: large range [0x70800000000, 0x709fffff000) (noaccess)
==14552== Warning: set address range perms: large range [0xf615000, 0x2f654000) (noaccess)
==14552== Use of uninitialised value of size 8
==14552==    at 0x5B9CDD1: <swc_ecma_transforms_proposal::decorator_2022_03::Decorator202203 as swc_ecma_visit::VisitMut>::visit_mut_stmt (in /mnt/v/scratch/deno)
==14552==    by 0x5B9D132: <swc_ecma_transforms_proposal::decorator_2022_03::Decorator202203 as swc_ecma_visit::VisitMut>::visit_mut_stmts (in /mnt/v/scratch/deno)
==14552==    by 0x5B9D132: <swc_ecma_transforms_proposal::decorator_2022_03::Decorator202203 as swc_ecma_visit::VisitMut>::visit_mut_stmts (in /mnt/v/scratch/deno)
==14552==    by 0x5B9D132: <swc_ecma_transforms_proposal::decorator_2022_03::Decorator202203 as swc_ecma_visit::VisitMut>::visit_mut_stmts (in /mnt/v/scratch/deno)
==14552==    by 0x5B9BEDE: <swc_ecma_transforms_proposal::decorator_2022_03::Decorator202203 as swc_ecma_visit::VisitMut>::visit_mut_module_items (in /mnt/v/scratch/deno)
==14552==    by 0x5AC621C: deno_ast::transpiling::fold_program (in /mnt/v/scratch/deno)
==14552==    by 0x5AC3E27: deno_ast::transpiling::<impl deno_ast::parsed_source::ParsedSource>::transpile (in /mnt/v/scratch/deno)
==14552==    by 0x429761A: deno::emit::Emitter::emit_parsed_source (in /mnt/v/scratch/deno)
==14552==    by 0x435E4F6: deno::module_loader::PreparedModuleLoader::load_prepared_module (in /mnt/v/scratch/deno)
==14552==    by 0x435F497: <deno::module_loader::CliModuleLoader as deno_core::modules::loaders::ModuleLoader>::load (in /mnt/v/scratch/deno)
==14552==    by 0x5E1C06A: <deno_core::modules::recursive_load::RecursiveModuleLoad as futures_core::stream::Stream>::poll_next::{{closure}} (in /mnt/v/scratch/deno)
==14552==    by 0x5E1B11F: <deno_core::modules::recursive_load::RecursiveModuleLoad as futures_core::stream::Stream>::poll_next (in /mnt/v/scratch/deno)
==14552==  Uninitialised value was created by a stack allocation
==14552==    at 0x5D083B1: <swc_ecma_ast::stmt::Stmt as core::clone::Clone>::clone (in /mnt/v/scratch/deno)
==14552==
==14552== Invalid read of size 8
==14552==    at 0x5B9CDD1: <swc_ecma_transforms_proposal::decorator_2022_03::Decorator202203 as swc_ecma_visit::VisitMut>::visit_mut_stmt (in /mnt/v/scratch/deno)
==14552==    by 0x5B9D132: <swc_ecma_transforms_proposal::decorator_2022_03::Decorator202203 as swc_ecma_visit::VisitMut>::visit_mut_stmts (in /mnt/v/scratch/deno)
==14552==    by 0x5B9D132: <swc_ecma_transforms_proposal::decorator_2022_03::Decorator202203 as swc_ecma_visit::VisitMut>::visit_mut_stmts (in /mnt/v/scratch/deno)
==14552==    by 0x5B9D132: <swc_ecma_transforms_proposal::decorator_2022_03::Decorator202203 as swc_ecma_visit::VisitMut>::visit_mut_stmts (in /mnt/v/scratch/deno)
==14552==    by 0x5B9BEDE: <swc_ecma_transforms_proposal::decorator_2022_03::Decorator202203 as swc_ecma_visit::VisitMut>::visit_mut_module_items (in /mnt/v/scratch/deno)
==14552==    by 0x5AC621C: deno_ast::transpiling::fold_program (in /mnt/v/scratch/deno)
==14552==    by 0x5AC3E27: deno_ast::transpiling::<impl deno_ast::parsed_source::ParsedSource>::transpile (in /mnt/v/scratch/deno)
==14552==    by 0x429761A: deno::emit::Emitter::emit_parsed_source (in /mnt/v/scratch/deno)
==14552==    by 0x435E4F6: deno::module_loader::PreparedModuleLoader::load_prepared_module (in /mnt/v/scratch/deno)
==14552==    by 0x435F497: <deno::module_loader::CliModuleLoader as deno_core::modules::loaders::ModuleLoader>::load (in /mnt/v/scratch/deno)
==14552==    by 0x5E1C06A: <deno_core::modules::recursive_load::RecursiveModuleLoad as futures_core::stream::Stream>::poll_next::{{closure}} (in /mnt/v/scratch/deno)
==14552==    by 0x5E1B11F: <deno_core::modules::recursive_load::RecursiveModuleLoad as futures_core::stream::Stream>::poll_next (in /mnt/v/scratch/deno)
==14552==  Address 0x0 is not stack'd, malloc'd or (recently) free'd
==14552==
==14552== Conditional jump or move depends on uninitialised value(s)
==14552==    at 0x5B9CDDC: <swc_ecma_transforms_proposal::decorator_2022_03::Decorator202203 as swc_ecma_visit::VisitMut>::visit_mut_stmt (in /mnt/v/scratch/deno)
==14552==    by 0x5B9D132: <swc_ecma_transforms_proposal::decorator_2022_03::Decorator202203 as swc_ecma_visit::VisitMut>::visit_mut_stmts (in /mnt/v/scratch/deno)
==14552==    by 0x5B9D132: <swc_ecma_transforms_proposal::decorator_2022_03::Decorator202203 as swc_ecma_visit::VisitMut>::visit_mut_stmts (in /mnt/v/scratch/deno)
==14552==    by 0x5B9D132: <swc_ecma_transforms_proposal::decorator_2022_03::Decorator202203 as swc_ecma_visit::VisitMut>::visit_mut_stmts (in /mnt/v/scratch/deno)
==14552==    by 0x5B9BEDE: <swc_ecma_transforms_proposal::decorator_2022_03::Decorator202203 as swc_ecma_visit::VisitMut>::visit_mut_module_items (in /mnt/v/scratch/deno)
==14552==    by 0x5AC621C: deno_ast::transpiling::fold_program (in /mnt/v/scratch/deno)
==14552==    by 0x5AC3E27: deno_ast::transpiling::<impl deno_ast::parsed_source::ParsedSource>::transpile (in /mnt/v/scratch/deno)
==14552==    by 0x429761A: deno::emit::Emitter::emit_parsed_source (in /mnt/v/scratch/deno)
==14552==    by 0x435E4F6: deno::module_loader::PreparedModuleLoader::load_prepared_module (in /mnt/v/scratch/deno)
==14552==    by 0x435F497: <deno::module_loader::CliModuleLoader as deno_core::modules::loaders::ModuleLoader>::load (in /mnt/v/scratch/deno)
==14552==    by 0x5E1C06A: <deno_core::modules::recursive_load::RecursiveModuleLoad as futures_core::stream::Stream>::poll_next::{{closure}} (in /mnt/v/scratch/deno)
==14552==    by 0x5E1B11F: <deno_core::modules::recursive_load::RecursiveModuleLoad as futures_core::stream::Stream>::poll_next (in /mnt/v/scratch/deno)
==14552==  Uninitialised value was created by a stack allocation
==14552==    at 0x5B9D010: <swc_ecma_transforms_proposal::decorator_2022_03::Decorator202203 as swc_ecma_visit::VisitMut>::visit_mut_stmts (in /mnt/v/scratch/deno)
==14552==
==14552== Use of uninitialised value of size 8
==14552==    at 0x5B9CE02: <swc_ecma_transforms_proposal::decorator_2022_03::Decorator202203 as swc_ecma_visit::VisitMut>::visit_mut_stmt (in /mnt/v/scratch/deno)
==14552==    by 0x5B9D132: <swc_ecma_transforms_proposal::decorator_2022_03::Decorator202203 as swc_ecma_visit::VisitMut>::visit_mut_stmts (in /mnt/v/scratch/deno)
==14552==    by 0x5B9D132: <swc_ecma_transforms_proposal::decorator_2022_03::Decorator202203 as swc_ecma_visit::VisitMut>::visit_mut_stmts (in /mnt/v/scratch/deno)
==14552==    by 0x5B9D132: <swc_ecma_transforms_proposal::decorator_2022_03::Decorator202203 as swc_ecma_visit::VisitMut>::visit_mut_stmts (in /mnt/v/scratch/deno)
==14552==    by 0x5B9BEDE: <swc_ecma_transforms_proposal::decorator_2022_03::Decorator202203 as swc_ecma_visit::VisitMut>::visit_mut_module_items (in /mnt/v/scratch/deno)
==14552==    by 0x5AC621C: deno_ast::transpiling::fold_program (in /mnt/v/scratch/deno)
==14552==    by 0x5AC3E27: deno_ast::transpiling::<impl deno_ast::parsed_source::ParsedSource>::transpile (in /mnt/v/scratch/deno)
==14552==    by 0x429761A: deno::emit::Emitter::emit_parsed_source (in /mnt/v/scratch/deno)
==14552==    by 0x435E4F6: deno::module_loader::PreparedModuleLoader::load_prepared_module (in /mnt/v/scratch/deno)
==14552==    by 0x435F497: <deno::module_loader::CliModuleLoader as deno_core::modules::loaders::ModuleLoader>::load (in /mnt/v/scratch/deno)
==14552==    by 0x5E1C06A: <deno_core::modules::recursive_load::RecursiveModuleLoad as futures_core::stream::Stream>::poll_next::{{closure}} (in /mnt/v/scratch/deno)
==14552==    by 0x5E1B11F: <deno_core::modules::recursive_load::RecursiveModuleLoad as futures_core::stream::Stream>::poll_next (in /mnt/v/scratch/deno)
==14552==  Uninitialised value was created by a stack allocation
==14552==    at 0x5B9D010: <swc_ecma_transforms_proposal::decorator_2022_03::Decorator202203 as swc_ecma_visit::VisitMut>::visit_mut_stmts (in /mnt/v/scratch/deno)
==14552==
==14552== Conditional jump or move depends on uninitialised value(s)
==14552==    at 0x5B9CE5C: <swc_ecma_transforms_proposal::decorator_2022_03::Decorator202203 as swc_ecma_visit::VisitMut>::visit_mut_stmt (in /mnt/v/scratch/deno)
==14552==    by 0x5B9D132: <swc_ecma_transforms_proposal::decorator_2022_03::Decorator202203 as swc_ecma_visit::VisitMut>::visit_mut_stmts (in /mnt/v/scratch/deno)
==14552==    by 0x5B9D132: <swc_ecma_transforms_proposal::decorator_2022_03::Decorator202203 as swc_ecma_visit::VisitMut>::visit_mut_stmts (in /mnt/v/scratch/deno)
==14552==    by 0x5B9D132: <swc_ecma_transforms_proposal::decorator_2022_03::Decorator202203 as swc_ecma_visit::VisitMut>::visit_mut_stmts (in /mnt/v/scratch/deno)
==14552==    by 0x5B9BEDE: <swc_ecma_transforms_proposal::decorator_2022_03::Decorator202203 as swc_ecma_visit::VisitMut>::visit_mut_module_items (in /mnt/v/scratch/deno)
==14552==    by 0x5AC621C: deno_ast::transpiling::fold_program (in /mnt/v/scratch/deno)
==14552==    by 0x5AC3E27: deno_ast::transpiling::<impl deno_ast::parsed_source::ParsedSource>::transpile (in /mnt/v/scratch/deno)
==14552==    by 0x429761A: deno::emit::Emitter::emit_parsed_source (in /mnt/v/scratch/deno)
==14552==    by 0x435E4F6: deno::module_loader::PreparedModuleLoader::load_prepared_module (in /mnt/v/scratch/deno)
==14552==    by 0x435F497: <deno::module_loader::CliModuleLoader as deno_core::modules::loaders::ModuleLoader>::load (in /mnt/v/scratch/deno)
==14552==    by 0x5E1C06A: <deno_core::modules::recursive_load::RecursiveModuleLoad as futures_core::stream::Stream>::poll_next::{{closure}} (in /mnt/v/scratch/deno)
==14552==    by 0x5E1B11F: <deno_core::modules::recursive_load::RecursiveModuleLoad as futures_core::stream::Stream>::poll_next (in /mnt/v/scratch/deno)
==14552==  Uninitialised value was created by a stack allocation
==14552==    at 0x5B9D010: <swc_ecma_transforms_proposal::decorator_2022_03::Decorator202203 as swc_ecma_visit::VisitMut>::visit_mut_stmts (in /mnt/v/scratch/deno)
==14552==
==14552== Conditional jump or move depends on uninitialised value(s)
==14552==    at 0x5B9CE67: <swc_ecma_transforms_proposal::decorator_2022_03::Decorator202203 as swc_ecma_visit::VisitMut>::visit_mut_stmt (in /mnt/v/scratch/deno)
==14552==    by 0x5B9D132: <swc_ecma_transforms_proposal::decorator_2022_03::Decorator202203 as swc_ecma_visit::VisitMut>::visit_mut_stmts (in /mnt/v/scratch/deno)
==14552==    by 0x5B9D132: <swc_ecma_transforms_proposal::decorator_2022_03::Decorator202203 as swc_ecma_visit::VisitMut>::visit_mut_stmts (in /mnt/v/scratch/deno)
==14552==    by 0x5B9D132: <swc_ecma_transforms_proposal::decorator_2022_03::Decorator202203 as swc_ecma_visit::VisitMut>::visit_mut_stmts (in /mnt/v/scratch/deno)
==14552==    by 0x5B9BEDE: <swc_ecma_transforms_proposal::decorator_2022_03::Decorator202203 as swc_ecma_visit::VisitMut>::visit_mut_module_items (in /mnt/v/scratch/deno)
==14552==    by 0x5AC621C: deno_ast::transpiling::fold_program (in /mnt/v/scratch/deno)
==14552==    by 0x5AC3E27: deno_ast::transpiling::<impl deno_ast::parsed_source::ParsedSource>::transpile (in /mnt/v/scratch/deno)
==14552==    by 0x429761A: deno::emit::Emitter::emit_parsed_source (in /mnt/v/scratch/deno)
==14552==    by 0x435E4F6: deno::module_loader::PreparedModuleLoader::load_prepared_module (in /mnt/v/scratch/deno)
==14552==    by 0x435F497: <deno::module_loader::CliModuleLoader as deno_core::modules::loaders::ModuleLoader>::load (in /mnt/v/scratch/deno)
==14552==    by 0x5E1C06A: <deno_core::modules::recursive_load::RecursiveModuleLoad as futures_core::stream::Stream>::poll_next::{{closure}} (in /mnt/v/scratch/deno)
==14552==    by 0x5E1B11F: <deno_core::modules::recursive_load::RecursiveModuleLoad as futures_core::stream::Stream>::poll_next (in /mnt/v/scratch/deno)
==14552==  Uninitialised value was created by a stack allocation
==14552==    at 0x5B9D010: <swc_ecma_transforms_proposal::decorator_2022_03::Decorator202203 as swc_ecma_visit::VisitMut>::visit_mut_stmts (in /mnt/v/scratch/deno)
==14552==
==14552== Use of uninitialised value of size 8
==14552==    at 0x5B9B3A3: <swc_ecma_transforms_proposal::decorator_2022_03::Decorator202203 as swc_ecma_visit::VisitMut>::visit_mut_expr (in /mnt/v/scratch/deno)
==14552==    by 0x5B9CE74: <swc_ecma_transforms_proposal::decorator_2022_03::Decorator202203 as swc_ecma_visit::VisitMut>::visit_mut_stmt (in /mnt/v/scratch/deno)
==14552==    by 0x5B9D132: <swc_ecma_transforms_proposal::decorator_2022_03::Decorator202203 as swc_ecma_visit::VisitMut>::visit_mut_stmts (in /mnt/v/scratch/deno)
==14552==    by 0x5B9D132: <swc_ecma_transforms_proposal::decorator_2022_03::Decorator202203 as swc_ecma_visit::VisitMut>::visit_mut_stmts (in /mnt/v/scratch/deno)
==14552==    by 0x5B9D132: <swc_ecma_transforms_proposal::decorator_2022_03::Decorator202203 as swc_ecma_visit::VisitMut>::visit_mut_stmts (in /mnt/v/scratch/deno)
==14552==    by 0x5B9BEDE: <swc_ecma_transforms_proposal::decorator_2022_03::Decorator202203 as swc_ecma_visit::VisitMut>::visit_mut_module_items (in /mnt/v/scratch/deno)
==14552==    by 0x5AC621C: deno_ast::transpiling::fold_program (in /mnt/v/scratch/deno)
==14552==    by 0x5AC3E27: deno_ast::transpiling::<impl deno_ast::parsed_source::ParsedSource>::transpile (in /mnt/v/scratch/deno)
==14552==    by 0x429761A: deno::emit::Emitter::emit_parsed_source (in /mnt/v/scratch/deno)
==14552==    by 0x435E4F6: deno::module_loader::PreparedModuleLoader::load_prepared_module (in /mnt/v/scratch/deno)
==14552==    by 0x435F497: <deno::module_loader::CliModuleLoader as deno_core::modules::loaders::ModuleLoader>::load (in /mnt/v/scratch/deno)
==14552==    by 0x5E1C06A: <deno_core::modules::recursive_load::RecursiveModuleLoad as futures_core::stream::Stream>::poll_next::{{closure}} (in /mnt/v/scratch/deno)
==14552==  Uninitialised value was created by a stack allocation
==14552==    at 0x5B9D010: <swc_ecma_transforms_proposal::decorator_2022_03::Decorator202203 as swc_ecma_visit::VisitMut>::visit_mut_stmts (in /mnt/v/scratch/deno)
==14552==
==14552== Use of uninitialised value of size 8
==14552==    at 0x5B87037: swc_ecma_visit::visit_mut_member_expr (in /mnt/v/scratch/deno)
==14552==    by 0x5B9B4AD: <swc_ecma_transforms_proposal::decorator_2022_03::Decorator202203 as swc_ecma_visit::VisitMut>::visit_mut_expr (in /mnt/v/scratch/deno)
==14552==    by 0x5B9CE74: <swc_ecma_transforms_proposal::decorator_2022_03::Decorator202203 as swc_ecma_visit::VisitMut>::visit_mut_stmt (in /mnt/v/scratch/deno)
==14552==    by 0x5B9D132: <swc_ecma_transforms_proposal::decorator_2022_03::Decorator202203 as swc_ecma_visit::VisitMut>::visit_mut_stmts (in /mnt/v/scratch/deno)
==14552==    by 0x5B9D132: <swc_ecma_transforms_proposal::decorator_2022_03::Decorator202203 as swc_ecma_visit::VisitMut>::visit_mut_stmts (in /mnt/v/scratch/deno)
==14552==    by 0x5B9D132: <swc_ecma_transforms_proposal::decorator_2022_03::Decorator202203 as swc_ecma_visit::VisitMut>::visit_mut_stmts (in /mnt/v/scratch/deno)
==14552==    by 0x5B9BEDE: <swc_ecma_transforms_proposal::decorator_2022_03::Decorator202203 as swc_ecma_visit::VisitMut>::visit_mut_module_items (in /mnt/v/scratch/deno)
==14552==    by 0x5AC621C: deno_ast::transpiling::fold_program (in /mnt/v/scratch/deno)
==14552==    by 0x5AC3E27: deno_ast::transpiling::<impl deno_ast::parsed_source::ParsedSource>::transpile (in /mnt/v/scratch/deno)
==14552==    by 0x429761A: deno::emit::Emitter::emit_parsed_source (in /mnt/v/scratch/deno)
==14552==    by 0x435E4F6: deno::module_loader::PreparedModuleLoader::load_prepared_module (in /mnt/v/scratch/deno)
==14552==    by 0x435F497: <deno::module_loader::CliModuleLoader as deno_core::modules::loaders::ModuleLoader>::load (in /mnt/v/scratch/deno)
==14552==  Uninitialised value was created by a stack allocation
==14552==    at 0x5B9D010: <swc_ecma_transforms_proposal::decorator_2022_03::Decorator202203 as swc_ecma_visit::VisitMut>::visit_mut_stmts (in /mnt/v/scratch/deno)
==14552==
==14552== Invalid read of size 8
==14552==    at 0x5B9B3A3: <swc_ecma_transforms_proposal::decorator_2022_03::Decorator202203 as swc_ecma_visit::VisitMut>::visit_mut_expr (in /mnt/v/scratch/deno)
==14552==    by 0x5B8703F: swc_ecma_visit::visit_mut_member_expr (in /mnt/v/scratch/deno)
==14552==    by 0x5B9B4AD: <swc_ecma_transforms_proposal::decorator_2022_03::Decorator202203 as swc_ecma_visit::VisitMut>::visit_mut_expr (in /mnt/v/scratch/deno)
==14552==    by 0x5B8703F: swc_ecma_visit::visit_mut_member_expr (in /mnt/v/scratch/deno)
==14552==    by 0x5B9B4AD: <swc_ecma_transforms_proposal::decorator_2022_03::Decorator202203 as swc_ecma_visit::VisitMut>::visit_mut_expr (in /mnt/v/scratch/deno)
==14552==    by 0x5B9CE74: <swc_ecma_transforms_proposal::decorator_2022_03::Decorator202203 as swc_ecma_visit::VisitMut>::visit_mut_stmt (in /mnt/v/scratch/deno)
==14552==    by 0x5B9D132: <swc_ecma_transforms_proposal::decorator_2022_03::Decorator202203 as swc_ecma_visit::VisitMut>::visit_mut_stmts (in /mnt/v/scratch/deno)
==14552==    by 0x5B9D132: <swc_ecma_transforms_proposal::decorator_2022_03::Decorator202203 as swc_ecma_visit::VisitMut>::visit_mut_stmts (in /mnt/v/scratch/deno)
==14552==    by 0x5B9D132: <swc_ecma_transforms_proposal::decorator_2022_03::Decorator202203 as swc_ecma_visit::VisitMut>::visit_mut_stmts (in /mnt/v/scratch/deno)
==14552==    by 0x5B9BEDE: <swc_ecma_transforms_proposal::decorator_2022_03::Decorator202203 as swc_ecma_visit::VisitMut>::visit_mut_module_items (in /mnt/v/scratch/deno)
==14552==    by 0x5AC621C: deno_ast::transpiling::fold_program (in /mnt/v/scratch/deno)
==14552==    by 0x5AC3E27: deno_ast::transpiling::<impl deno_ast::parsed_source::ParsedSource>::transpile (in /mnt/v/scratch/deno)
==14552==  Address 0xc038000000000000 is not stack'd, malloc'd or (recently) free'd
==14552==
==14552==
==14552== Process terminating with default action of signal 11 (SIGSEGV)
==14552==  General Protection Fault
==14552==    at 0x5B9B3A3: <swc_ecma_transforms_proposal::decorator_2022_03::Decorator202203 as swc_ecma_visit::VisitMut>::visit_mut_expr (in /mnt/v/scratch/deno)
==14552==    by 0x5B8703F: swc_ecma_visit::visit_mut_member_expr (in /mnt/v/scratch/deno)
==14552==    by 0x5B9B4AD: <swc_ecma_transforms_proposal::decorator_2022_03::Decorator202203 as swc_ecma_visit::VisitMut>::visit_mut_expr (in /mnt/v/scratch/deno)
==14552==    by 0x5B8703F: swc_ecma_visit::visit_mut_member_expr (in /mnt/v/scratch/deno)
==14552==    by 0x5B9B4AD: <swc_ecma_transforms_proposal::decorator_2022_03::Decorator202203 as swc_ecma_visit::VisitMut>::visit_mut_expr (in /mnt/v/scratch/deno)
==14552==    by 0x5B9CE74: <swc_ecma_transforms_proposal::decorator_2022_03::Decorator202203 as swc_ecma_visit::VisitMut>::visit_mut_stmt (in /mnt/v/scratch/deno)
==14552==    by 0x5B9D132: <swc_ecma_transforms_proposal::decorator_2022_03::Decorator202203 as swc_ecma_visit::VisitMut>::visit_mut_stmts (in /mnt/v/scratch/deno)
==14552==    by 0x5B9D132: <swc_ecma_transforms_proposal::decorator_2022_03::Decorator202203 as swc_ecma_visit::VisitMut>::visit_mut_stmts (in /mnt/v/scratch/deno)
==14552==    by 0x5B9D132: <swc_ecma_transforms_proposal::decorator_2022_03::Decorator202203 as swc_ecma_visit::VisitMut>::visit_mut_stmts (in /mnt/v/scratch/deno)
==14552==    by 0x5B9BEDE: <swc_ecma_transforms_proposal::decorator_2022_03::Decorator202203 as swc_ecma_visit::VisitMut>::visit_mut_module_items (in /mnt/v/scratch/deno)
==14552==    by 0x5AC621C: deno_ast::transpiling::fold_program (in /mnt/v/scratch/deno)
==14552==    by 0x5AC3E27: deno_ast::transpiling::<impl deno_ast::parsed_source::ParsedSource>::transpile (in /mnt/v/scratch/deno)
==14552==
==14552== HEAP SUMMARY:
==14552==     in use at exit: 11,786,044 bytes in 68,414 blocks
==14552==   total heap usage: 151,363 allocs, 82,949 frees, 36,613,131 bytes allocated
==14552==
==14552== LEAK SUMMARY:
==14552==    definitely lost: 576 bytes in 192 blocks
==14552==    indirectly lost: 0 bytes in 0 blocks
==14552==      possibly lost: 7,422,263 bytes in 54,498 blocks
==14552==    still reachable: 4,363,205 bytes in 13,724 blocks
==14552==                       of which reachable via heuristic:
==14552==                         length64           : 128,440 bytes in 289 blocks
==14552==                         newarray           : 225,360 bytes in 4,695 blocks
==14552==         suppressed: 0 bytes in 0 blocks
==14552== Rerun with --leak-check=full to see details of leaked memory
==14552==
==14552== For lists of detected and suppressed errors, rerun with: -s
==14552== ERROR SUMMARY: 9 errors from 9 contexts (suppressed: 0 from 0)
Segmentation fault

It strangely only occurs when building from our CI (using the deno-linux-x86_64 artifact https://github.com/denoland/deno/actions/runs/8640318958?pr=23187#artifacts) and not with a local build. I'm unfortuantely not good at this kind of debugging in Linux and haven't gotten far trying to reproduce it on other platforms.

@kdy1
Copy link
Member Author

kdy1 commented Apr 11, 2024

@dsherret Do you have latest-working-version?
Hopefully including rustc

@kdy1
Copy link
Member Author

kdy1 commented Apr 11, 2024

Myabe related: rust-lang/rust#91979

@kdy1
Copy link
Member Author

kdy1 commented Apr 11, 2024

Also maybe related: #8695

@dsherret
Copy link
Contributor

dsherret commented Apr 11, 2024

I unfortunately don't have the version it starts occurring, but it was working in Rust 1.77.2 and this diff of the Cargo.lock shows when it was last working (https://github.com/denoland/deno/pull/23187/files#diff-13ee4b2252c9e516a0547f2891aa2105c3ca71c6d7a1e682c69be97998dfc87e). It's only a few patch releases away for most of the crates luckily.

Output with latest published crates as of this post (basically the same as above)
$ rm -rf deno_dir ; DENO_DIR=$(pwd)/deno_dir ./valgrind-3.22.0/coregrind/valgrind --tool=memcheck --track-origins=yes ./deno run https://deno.land/x/dax@0.39.2/mod.ts
==14580== Memcheck, a memory error detector
==14580== Copyright (C) 2002-2022, and GNU GPL'd, by Julian Seward et al.
==14580== Using Valgrind-3.22.0 and LibVEX; rerun with -h for copyright info
==14580== Command: ./deno run https://deno.land/x/dax@0.39.2/mod.ts
==14580==
==14580== Warning: set address range perms: large range [0x2f9e00000000, 0x2fa1fffff000) (noaccess)
==14580== Warning: set address range perms: large range [0x2fa000000000, 0x2fa1fffff000) (noaccess)
==14580== Warning: set address range perms: large range [0xf616000, 0x2f655000) (noaccess)
==14580== Use of uninitialised value of size 8
==14580==    at 0x5B9E29F: <swc_ecma_transforms_proposal::decorator_2022_03::Decorator202203 as swc_ecma_visit::VisitMut>::visit_mut_stmt (in /mnt/v/scratch/deno)
==14580==    by 0x5B9E600: <swc_ecma_transforms_proposal::decorator_2022_03::Decorator202203 as swc_ecma_visit::VisitMut>::visit_mut_stmts (in /mnt/v/scratch/deno)
==14580==    by 0x5B9E600: <swc_ecma_transforms_proposal::decorator_2022_03::Decorator202203 as swc_ecma_visit::VisitMut>::visit_mut_stmts (in /mnt/v/scratch/deno)
==14580==    by 0x5B9E600: <swc_ecma_transforms_proposal::decorator_2022_03::Decorator202203 as swc_ecma_visit::VisitMut>::visit_mut_stmts (in /mnt/v/scratch/deno)
==14580==    by 0x5B9D3AC: <swc_ecma_transforms_proposal::decorator_2022_03::Decorator202203 as swc_ecma_visit::VisitMut>::visit_mut_module_items (in /mnt/v/scratch/deno)
==14580==    by 0x5AC7530: deno_ast::transpiling::fold_program (in /mnt/v/scratch/deno)
==14580==    by 0x5AC5162: deno_ast::transpiling::<impl deno_ast::parsed_source::ParsedSource>::transpile (in /mnt/v/scratch/deno)
==14580==    by 0x4298618: deno::emit::Emitter::emit_parsed_source (in /mnt/v/scratch/deno)
==14580==    by 0x435F4F4: deno::module_loader::PreparedModuleLoader::load_prepared_module (in /mnt/v/scratch/deno)
==14580==    by 0x4360495: <deno::module_loader::CliModuleLoader as deno_core::modules::loaders::ModuleLoader>::load (in /mnt/v/scratch/deno)
==14580==    by 0x5E1CEDA: <deno_core::modules::recursive_load::RecursiveModuleLoad as futures_core::stream::Stream>::poll_next::{{closure}} (in /mnt/v/scratch/deno)
==14580==    by 0x5E1BF8F: <deno_core::modules::recursive_load::RecursiveModuleLoad as futures_core::stream::Stream>::poll_next (in /mnt/v/scratch/deno)
==14580==  Uninitialised value was created by a stack allocation
==14580==    at 0x5D0934A: <swc_ecma_ast::stmt::Stmt as core::clone::Clone>::clone (in /mnt/v/scratch/deno)
==14580==
==14580== Invalid read of size 8
==14580==    at 0x5B9E29F: <swc_ecma_transforms_proposal::decorator_2022_03::Decorator202203 as swc_ecma_visit::VisitMut>::visit_mut_stmt (in /mnt/v/scratch/deno)
==14580==    by 0x5B9E600: <swc_ecma_transforms_proposal::decorator_2022_03::Decorator202203 as swc_ecma_visit::VisitMut>::visit_mut_stmts (in /mnt/v/scratch/deno)
==14580==    by 0x5B9E600: <swc_ecma_transforms_proposal::decorator_2022_03::Decorator202203 as swc_ecma_visit::VisitMut>::visit_mut_stmts (in /mnt/v/scratch/deno)
==14580==    by 0x5B9E600: <swc_ecma_transforms_proposal::decorator_2022_03::Decorator202203 as swc_ecma_visit::VisitMut>::visit_mut_stmts (in /mnt/v/scratch/deno)
==14580==    by 0x5B9D3AC: <swc_ecma_transforms_proposal::decorator_2022_03::Decorator202203 as swc_ecma_visit::VisitMut>::visit_mut_module_items (in /mnt/v/scratch/deno)
==14580==    by 0x5AC7530: deno_ast::transpiling::fold_program (in /mnt/v/scratch/deno)
==14580==    by 0x5AC5162: deno_ast::transpiling::<impl deno_ast::parsed_source::ParsedSource>::transpile (in /mnt/v/scratch/deno)
==14580==    by 0x4298618: deno::emit::Emitter::emit_parsed_source (in /mnt/v/scratch/deno)
==14580==    by 0x435F4F4: deno::module_loader::PreparedModuleLoader::load_prepared_module (in /mnt/v/scratch/deno)
==14580==    by 0x4360495: <deno::module_loader::CliModuleLoader as deno_core::modules::loaders::ModuleLoader>::load (in /mnt/v/scratch/deno)
==14580==    by 0x5E1CEDA: <deno_core::modules::recursive_load::RecursiveModuleLoad as futures_core::stream::Stream>::poll_next::{{closure}} (in /mnt/v/scratch/deno)
==14580==    by 0x5E1BF8F: <deno_core::modules::recursive_load::RecursiveModuleLoad as futures_core::stream::Stream>::poll_next (in /mnt/v/scratch/deno)
==14580==  Address 0x419d00000012 is not stack'd, malloc'd or (recently) free'd
==14580==
==14580== Conditional jump or move depends on uninitialised value(s)
==14580==    at 0x5B9E2AA: <swc_ecma_transforms_proposal::decorator_2022_03::Decorator202203 as swc_ecma_visit::VisitMut>::visit_mut_stmt (in /mnt/v/scratch/deno)
==14580==    by 0x5B9E600: <swc_ecma_transforms_proposal::decorator_2022_03::Decorator202203 as swc_ecma_visit::VisitMut>::visit_mut_stmts (in /mnt/v/scratch/deno)
==14580==    by 0x5B9E600: <swc_ecma_transforms_proposal::decorator_2022_03::Decorator202203 as swc_ecma_visit::VisitMut>::visit_mut_stmts (in /mnt/v/scratch/deno)
==14580==    by 0x5B9E600: <swc_ecma_transforms_proposal::decorator_2022_03::Decorator202203 as swc_ecma_visit::VisitMut>::visit_mut_stmts (in /mnt/v/scratch/deno)
==14580==    by 0x5B9D3AC: <swc_ecma_transforms_proposal::decorator_2022_03::Decorator202203 as swc_ecma_visit::VisitMut>::visit_mut_module_items (in /mnt/v/scratch/deno)
==14580==    by 0x5AC7530: deno_ast::transpiling::fold_program (in /mnt/v/scratch/deno)
==14580==    by 0x5AC5162: deno_ast::transpiling::<impl deno_ast::parsed_source::ParsedSource>::transpile (in /mnt/v/scratch/deno)
==14580==    by 0x4298618: deno::emit::Emitter::emit_parsed_source (in /mnt/v/scratch/deno)
==14580==    by 0x435F4F4: deno::module_loader::PreparedModuleLoader::load_prepared_module (in /mnt/v/scratch/deno)
==14580==    by 0x4360495: <deno::module_loader::CliModuleLoader as deno_core::modules::loaders::ModuleLoader>::load (in /mnt/v/scratch/deno)
==14580==    by 0x5E1CEDA: <deno_core::modules::recursive_load::RecursiveModuleLoad as futures_core::stream::Stream>::poll_next::{{closure}} (in /mnt/v/scratch/deno)
==14580==    by 0x5E1BF8F: <deno_core::modules::recursive_load::RecursiveModuleLoad as futures_core::stream::Stream>::poll_next (in /mnt/v/scratch/deno)
==14580==  Uninitialised value was created by a stack allocation
==14580==    at 0x5B9E4DE: <swc_ecma_transforms_proposal::decorator_2022_03::Decorator202203 as swc_ecma_visit::VisitMut>::visit_mut_stmts (in /mnt/v/scratch/deno)
==14580==
==14580== Use of uninitialised value of size 8
==14580==    at 0x5B9E2D0: <swc_ecma_transforms_proposal::decorator_2022_03::Decorator202203 as swc_ecma_visit::VisitMut>::visit_mut_stmt (in /mnt/v/scratch/deno)
==14580==    by 0x5B9E600: <swc_ecma_transforms_proposal::decorator_2022_03::Decorator202203 as swc_ecma_visit::VisitMut>::visit_mut_stmts (in /mnt/v/scratch/deno)
==14580==    by 0x5B9E600: <swc_ecma_transforms_proposal::decorator_2022_03::Decorator202203 as swc_ecma_visit::VisitMut>::visit_mut_stmts (in /mnt/v/scratch/deno)
==14580==    by 0x5B9E600: <swc_ecma_transforms_proposal::decorator_2022_03::Decorator202203 as swc_ecma_visit::VisitMut>::visit_mut_stmts (in /mnt/v/scratch/deno)
==14580==    by 0x5B9D3AC: <swc_ecma_transforms_proposal::decorator_2022_03::Decorator202203 as swc_ecma_visit::VisitMut>::visit_mut_module_items (in /mnt/v/scratch/deno)
==14580==    by 0x5AC7530: deno_ast::transpiling::fold_program (in /mnt/v/scratch/deno)
==14580==    by 0x5AC5162: deno_ast::transpiling::<impl deno_ast::parsed_source::ParsedSource>::transpile (in /mnt/v/scratch/deno)
==14580==    by 0x4298618: deno::emit::Emitter::emit_parsed_source (in /mnt/v/scratch/deno)
==14580==    by 0x435F4F4: deno::module_loader::PreparedModuleLoader::load_prepared_module (in /mnt/v/scratch/deno)
==14580==    by 0x4360495: <deno::module_loader::CliModuleLoader as deno_core::modules::loaders::ModuleLoader>::load (in /mnt/v/scratch/deno)
==14580==    by 0x5E1CEDA: <deno_core::modules::recursive_load::RecursiveModuleLoad as futures_core::stream::Stream>::poll_next::{{closure}} (in /mnt/v/scratch/deno)
==14580==    by 0x5E1BF8F: <deno_core::modules::recursive_load::RecursiveModuleLoad as futures_core::stream::Stream>::poll_next (in /mnt/v/scratch/deno)
==14580==  Uninitialised value was created by a stack allocation
==14580==    at 0x5B9E4DE: <swc_ecma_transforms_proposal::decorator_2022_03::Decorator202203 as swc_ecma_visit::VisitMut>::visit_mut_stmts (in /mnt/v/scratch/deno)
==14580==
==14580== Conditional jump or move depends on uninitialised value(s)
==14580==    at 0x5B9E32A: <swc_ecma_transforms_proposal::decorator_2022_03::Decorator202203 as swc_ecma_visit::VisitMut>::visit_mut_stmt (in /mnt/v/scratch/deno)
==14580==    by 0x5B9E600: <swc_ecma_transforms_proposal::decorator_2022_03::Decorator202203 as swc_ecma_visit::VisitMut>::visit_mut_stmts (in /mnt/v/scratch/deno)
==14580==    by 0x5B9E600: <swc_ecma_transforms_proposal::decorator_2022_03::Decorator202203 as swc_ecma_visit::VisitMut>::visit_mut_stmts (in /mnt/v/scratch/deno)
==14580==    by 0x5B9E600: <swc_ecma_transforms_proposal::decorator_2022_03::Decorator202203 as swc_ecma_visit::VisitMut>::visit_mut_stmts (in /mnt/v/scratch/deno)
==14580==    by 0x5B9D3AC: <swc_ecma_transforms_proposal::decorator_2022_03::Decorator202203 as swc_ecma_visit::VisitMut>::visit_mut_module_items (in /mnt/v/scratch/deno)
==14580==    by 0x5AC7530: deno_ast::transpiling::fold_program (in /mnt/v/scratch/deno)
==14580==    by 0x5AC5162: deno_ast::transpiling::<impl deno_ast::parsed_source::ParsedSource>::transpile (in /mnt/v/scratch/deno)
==14580==    by 0x4298618: deno::emit::Emitter::emit_parsed_source (in /mnt/v/scratch/deno)
==14580==    by 0x435F4F4: deno::module_loader::PreparedModuleLoader::load_prepared_module (in /mnt/v/scratch/deno)
==14580==    by 0x4360495: <deno::module_loader::CliModuleLoader as deno_core::modules::loaders::ModuleLoader>::load (in /mnt/v/scratch/deno)
==14580==    by 0x5E1CEDA: <deno_core::modules::recursive_load::RecursiveModuleLoad as futures_core::stream::Stream>::poll_next::{{closure}} (in /mnt/v/scratch/deno)
==14580==    by 0x5E1BF8F: <deno_core::modules::recursive_load::RecursiveModuleLoad as futures_core::stream::Stream>::poll_next (in /mnt/v/scratch/deno)
==14580==  Uninitialised value was created by a stack allocation
==14580==    at 0x5B9E4DE: <swc_ecma_transforms_proposal::decorator_2022_03::Decorator202203 as swc_ecma_visit::VisitMut>::visit_mut_stmts (in /mnt/v/scratch/deno)
==14580==
==14580== Conditional jump or move depends on uninitialised value(s)
==14580==    at 0x5B9E335: <swc_ecma_transforms_proposal::decorator_2022_03::Decorator202203 as swc_ecma_visit::VisitMut>::visit_mut_stmt (in /mnt/v/scratch/deno)
==14580==    by 0x5B9E600: <swc_ecma_transforms_proposal::decorator_2022_03::Decorator202203 as swc_ecma_visit::VisitMut>::visit_mut_stmts (in /mnt/v/scratch/deno)
==14580==    by 0x5B9E600: <swc_ecma_transforms_proposal::decorator_2022_03::Decorator202203 as swc_ecma_visit::VisitMut>::visit_mut_stmts (in /mnt/v/scratch/deno)
==14580==    by 0x5B9E600: <swc_ecma_transforms_proposal::decorator_2022_03::Decorator202203 as swc_ecma_visit::VisitMut>::visit_mut_stmts (in /mnt/v/scratch/deno)
==14580==    by 0x5B9D3AC: <swc_ecma_transforms_proposal::decorator_2022_03::Decorator202203 as swc_ecma_visit::VisitMut>::visit_mut_module_items (in /mnt/v/scratch/deno)
==14580==    by 0x5AC7530: deno_ast::transpiling::fold_program (in /mnt/v/scratch/deno)
==14580==    by 0x5AC5162: deno_ast::transpiling::<impl deno_ast::parsed_source::ParsedSource>::transpile (in /mnt/v/scratch/deno)
==14580==    by 0x4298618: deno::emit::Emitter::emit_parsed_source (in /mnt/v/scratch/deno)
==14580==    by 0x435F4F4: deno::module_loader::PreparedModuleLoader::load_prepared_module (in /mnt/v/scratch/deno)
==14580==    by 0x4360495: <deno::module_loader::CliModuleLoader as deno_core::modules::loaders::ModuleLoader>::load (in /mnt/v/scratch/deno)
==14580==    by 0x5E1CEDA: <deno_core::modules::recursive_load::RecursiveModuleLoad as futures_core::stream::Stream>::poll_next::{{closure}} (in /mnt/v/scratch/deno)
==14580==    by 0x5E1BF8F: <deno_core::modules::recursive_load::RecursiveModuleLoad as futures_core::stream::Stream>::poll_next (in /mnt/v/scratch/deno)
==14580==  Uninitialised value was created by a stack allocation
==14580==    at 0x5B9E4DE: <swc_ecma_transforms_proposal::decorator_2022_03::Decorator202203 as swc_ecma_visit::VisitMut>::visit_mut_stmts (in /mnt/v/scratch/deno)
==14580==
==14580== Use of uninitialised value of size 8
==14580==    at 0x5B9C871: <swc_ecma_transforms_proposal::decorator_2022_03::Decorator202203 as swc_ecma_visit::VisitMut>::visit_mut_expr (in /mnt/v/scratch/deno)
==14580==    by 0x5B9E342: <swc_ecma_transforms_proposal::decorator_2022_03::Decorator202203 as swc_ecma_visit::VisitMut>::visit_mut_stmt (in /mnt/v/scratch/deno)
==14580==    by 0x5B9E600: <swc_ecma_transforms_proposal::decorator_2022_03::Decorator202203 as swc_ecma_visit::VisitMut>::visit_mut_stmts (in /mnt/v/scratch/deno)
==14580==    by 0x5B9E600: <swc_ecma_transforms_proposal::decorator_2022_03::Decorator202203 as swc_ecma_visit::VisitMut>::visit_mut_stmts (in /mnt/v/scratch/deno)
==14580==    by 0x5B9E600: <swc_ecma_transforms_proposal::decorator_2022_03::Decorator202203 as swc_ecma_visit::VisitMut>::visit_mut_stmts (in /mnt/v/scratch/deno)
==14580==    by 0x5B9D3AC: <swc_ecma_transforms_proposal::decorator_2022_03::Decorator202203 as swc_ecma_visit::VisitMut>::visit_mut_module_items (in /mnt/v/scratch/deno)
==14580==    by 0x5AC7530: deno_ast::transpiling::fold_program (in /mnt/v/scratch/deno)
==14580==    by 0x5AC5162: deno_ast::transpiling::<impl deno_ast::parsed_source::ParsedSource>::transpile (in /mnt/v/scratch/deno)
==14580==    by 0x4298618: deno::emit::Emitter::emit_parsed_source (in /mnt/v/scratch/deno)
==14580==    by 0x435F4F4: deno::module_loader::PreparedModuleLoader::load_prepared_module (in /mnt/v/scratch/deno)
==14580==    by 0x4360495: <deno::module_loader::CliModuleLoader as deno_core::modules::loaders::ModuleLoader>::load (in /mnt/v/scratch/deno)
==14580==    by 0x5E1CEDA: <deno_core::modules::recursive_load::RecursiveModuleLoad as futures_core::stream::Stream>::poll_next::{{closure}} (in /mnt/v/scratch/deno)
==14580==  Uninitialised value was created by a stack allocation
==14580==    at 0x5B9E4DE: <swc_ecma_transforms_proposal::decorator_2022_03::Decorator202203 as swc_ecma_visit::VisitMut>::visit_mut_stmts (in /mnt/v/scratch/deno)
==14580==
==14580== Use of uninitialised value of size 8
==14580==    at 0x5B884AE: swc_ecma_visit::visit_mut_member_expr (in /mnt/v/scratch/deno)
==14580==    by 0x5B9C97B: <swc_ecma_transforms_proposal::decorator_2022_03::Decorator202203 as swc_ecma_visit::VisitMut>::visit_mut_expr (in /mnt/v/scratch/deno)
==14580==    by 0x5B9E342: <swc_ecma_transforms_proposal::decorator_2022_03::Decorator202203 as swc_ecma_visit::VisitMut>::visit_mut_stmt (in /mnt/v/scratch/deno)
==14580==    by 0x5B9E600: <swc_ecma_transforms_proposal::decorator_2022_03::Decorator202203 as swc_ecma_visit::VisitMut>::visit_mut_stmts (in /mnt/v/scratch/deno)
==14580==    by 0x5B9E600: <swc_ecma_transforms_proposal::decorator_2022_03::Decorator202203 as swc_ecma_visit::VisitMut>::visit_mut_stmts (in /mnt/v/scratch/deno)
==14580==    by 0x5B9E600: <swc_ecma_transforms_proposal::decorator_2022_03::Decorator202203 as swc_ecma_visit::VisitMut>::visit_mut_stmts (in /mnt/v/scratch/deno)
==14580==    by 0x5B9D3AC: <swc_ecma_transforms_proposal::decorator_2022_03::Decorator202203 as swc_ecma_visit::VisitMut>::visit_mut_module_items (in /mnt/v/scratch/deno)
==14580==    by 0x5AC7530: deno_ast::transpiling::fold_program (in /mnt/v/scratch/deno)
==14580==    by 0x5AC5162: deno_ast::transpiling::<impl deno_ast::parsed_source::ParsedSource>::transpile (in /mnt/v/scratch/deno)
==14580==    by 0x4298618: deno::emit::Emitter::emit_parsed_source (in /mnt/v/scratch/deno)
==14580==    by 0x435F4F4: deno::module_loader::PreparedModuleLoader::load_prepared_module (in /mnt/v/scratch/deno)
==14580==    by 0x4360495: <deno::module_loader::CliModuleLoader as deno_core::modules::loaders::ModuleLoader>::load (in /mnt/v/scratch/deno)
==14580==  Uninitialised value was created by a stack allocation
==14580==    at 0x5B9E4DE: <swc_ecma_transforms_proposal::decorator_2022_03::Decorator202203 as swc_ecma_visit::VisitMut>::visit_mut_stmts (in /mnt/v/scratch/deno)
==14580==
==14580== Invalid read of size 8
==14580==    at 0x5B9C871: <swc_ecma_transforms_proposal::decorator_2022_03::Decorator202203 as swc_ecma_visit::VisitMut>::visit_mut_expr (in /mnt/v/scratch/deno)
==14580==    by 0x5B884B6: swc_ecma_visit::visit_mut_member_expr (in /mnt/v/scratch/deno)
==14580==    by 0x5B9C97B: <swc_ecma_transforms_proposal::decorator_2022_03::Decorator202203 as swc_ecma_visit::VisitMut>::visit_mut_expr (in /mnt/v/scratch/deno)
==14580==    by 0x5B884B6: swc_ecma_visit::visit_mut_member_expr (in /mnt/v/scratch/deno)
==14580==    by 0x5B9C97B: <swc_ecma_transforms_proposal::decorator_2022_03::Decorator202203 as swc_ecma_visit::VisitMut>::visit_mut_expr (in /mnt/v/scratch/deno)
==14580==    by 0x5B9E342: <swc_ecma_transforms_proposal::decorator_2022_03::Decorator202203 as swc_ecma_visit::VisitMut>::visit_mut_stmt (in /mnt/v/scratch/deno)
==14580==    by 0x5B9E600: <swc_ecma_transforms_proposal::decorator_2022_03::Decorator202203 as swc_ecma_visit::VisitMut>::visit_mut_stmts (in /mnt/v/scratch/deno)
==14580==    by 0x5B9E600: <swc_ecma_transforms_proposal::decorator_2022_03::Decorator202203 as swc_ecma_visit::VisitMut>::visit_mut_stmts (in /mnt/v/scratch/deno)
==14580==    by 0x5B9E600: <swc_ecma_transforms_proposal::decorator_2022_03::Decorator202203 as swc_ecma_visit::VisitMut>::visit_mut_stmts (in /mnt/v/scratch/deno)
==14580==    by 0x5B9D3AC: <swc_ecma_transforms_proposal::decorator_2022_03::Decorator202203 as swc_ecma_visit::VisitMut>::visit_mut_module_items (in /mnt/v/scratch/deno)
==14580==    by 0x5AC7530: deno_ast::transpiling::fold_program (in /mnt/v/scratch/deno)
==14580==    by 0x5AC5162: deno_ast::transpiling::<impl deno_ast::parsed_source::ParsedSource>::transpile (in /mnt/v/scratch/deno)
==14580==  Address 0xc038000000000000 is not stack'd, malloc'd or (recently) free'd
==14580==
==14580==
==14580== Process terminating with default action of signal 11 (SIGSEGV)
==14580==  General Protection Fault
==14580==    at 0x5B9C871: <swc_ecma_transforms_proposal::decorator_2022_03::Decorator202203 as swc_ecma_visit::VisitMut>::visit_mut_expr (in /mnt/v/scratch/deno)
==14580==    by 0x5B884B6: swc_ecma_visit::visit_mut_member_expr (in /mnt/v/scratch/deno)
==14580==    by 0x5B9C97B: <swc_ecma_transforms_proposal::decorator_2022_03::Decorator202203 as swc_ecma_visit::VisitMut>::visit_mut_expr (in /mnt/v/scratch/deno)
==14580==    by 0x5B884B6: swc_ecma_visit::visit_mut_member_expr (in /mnt/v/scratch/deno)
==14580==    by 0x5B9C97B: <swc_ecma_transforms_proposal::decorator_2022_03::Decorator202203 as swc_ecma_visit::VisitMut>::visit_mut_expr (in /mnt/v/scratch/deno)
==14580==    by 0x5B9E342: <swc_ecma_transforms_proposal::decorator_2022_03::Decorator202203 as swc_ecma_visit::VisitMut>::visit_mut_stmt (in /mnt/v/scratch/deno)
==14580==    by 0x5B9E600: <swc_ecma_transforms_proposal::decorator_2022_03::Decorator202203 as swc_ecma_visit::VisitMut>::visit_mut_stmts (in /mnt/v/scratch/deno)
==14580==    by 0x5B9E600: <swc_ecma_transforms_proposal::decorator_2022_03::Decorator202203 as swc_ecma_visit::VisitMut>::visit_mut_stmts (in /mnt/v/scratch/deno)
==14580==    by 0x5B9E600: <swc_ecma_transforms_proposal::decorator_2022_03::Decorator202203 as swc_ecma_visit::VisitMut>::visit_mut_stmts (in /mnt/v/scratch/deno)
==14580==    by 0x5B9D3AC: <swc_ecma_transforms_proposal::decorator_2022_03::Decorator202203 as swc_ecma_visit::VisitMut>::visit_mut_module_items (in /mnt/v/scratch/deno)
==14580==    by 0x5AC7530: deno_ast::transpiling::fold_program (in /mnt/v/scratch/deno)
==14580==    by 0x5AC5162: deno_ast::transpiling::<impl deno_ast::parsed_source::ParsedSource>::transpile (in /mnt/v/scratch/deno)
==14580==
==14580== HEAP SUMMARY:
==14580==     in use at exit: 11,755,712 bytes in 68,416 blocks
==14580==   total heap usage: 151,052 allocs, 82,636 frees, 36,495,627 bytes allocated
==14580==
==14580== LEAK SUMMARY:
==14580==    definitely lost: 576 bytes in 192 blocks
==14580==    indirectly lost: 0 bytes in 0 blocks
==14580==      possibly lost: 7,422,199 bytes in 54,497 blocks
==14580==    still reachable: 4,332,937 bytes in 13,727 blocks
==14580==                       of which reachable via heuristic:
==14580==                         length64           : 128,440 bytes in 289 blocks
==14580==                         newarray           : 225,360 bytes in 4,695 blocks
==14580==         suppressed: 0 bytes in 0 blocks
==14580== Rerun with --leak-check=full to see details of leaked memory
==14580==
==14580== For lists of detected and suppressed errors, rerun with: -s
==14580== ERROR SUMMARY: 9 errors from 9 contexts (suppressed: 0 from 0)
Segmentation fault

This first uninitailized value line is maybe the suspect one? (maybe the cloning of an Atom?) I wish it gave more detail.

Uninitialised value was created by a stack allocation
==14580==    at 0x5D0934A: <swc_ecma_ast::stmt::Stmt as core::clone::Clone>::clone (in /mnt/v/scratch/deno)

@kdy1
Copy link
Member Author

kdy1 commented Apr 11, 2024

[[package]]
name = "hstr"
-version = "0.2.6"
+version = "0.2.9"

[[package]]
name = "swc_atoms"
-version = "0.6.5"
+version = "0.6.6"

[[package]]
name = "swc_bundler"
-version = "0.225.9"
+version = "0.225.18"

[[package]]
name = "swc_common"
-version = "0.33.18"
+version = "0.33.22"

[[package]]
name = "swc_config"
-version = "0.1.11"
+version = "0.1.12"

[[package]]
name = "swc_ecma_ast"
-version = "0.112.4"
+version = "0.112.7"

[[package]]
name = "swc_ecma_codegen"
-version = "0.148.7"
+version = "0.148.15"

[[package]]
name = "swc_ecma_loader"
-version = "0.45.20"
+version = "0.45.25"

[[package]]
name = "swc_ecma_parser"
-version = "0.143.5"
+version = "0.143.13"

[[package]]
name = "swc_ecma_transforms_base"
-version = "0.137.10"
+version = "0.137.17"

[[package]]
name = "swc_ecma_transforms_classes"
-version = "0.126.10"
+version = "0.126.16"

[[package]]
name = "swc_ecma_transforms_optimization"
-version = "0.198.10"
+version = "0.198.19"

[[package]]
name = "swc_ecma_transforms_proposal"
-version = "0.171.10"
+version = "0.171.20"

[[package]]
name = "swc_ecma_transforms_react"
-version = "0.183.10"
+version = "0.183.18"

[[package]]
name = "swc_ecma_transforms_typescript"
-version = "0.188.10"
+version = "0.188.18"

[[package]]
name = "swc_ecma_utils"
-version = "0.127.7"
+version = "0.127.17"

[[package]]
name = "swc_ecma_visit"
-version = "0.98.4"
+version = "0.98.7"

[[package]]
name = "swc_fast_graph"
-version = "0.21.18"
+version = "0.21.20"

[[package]]
name = "swc_graph_analyzer"
-version = "0.22.20"
+version = "0.22.22"

[[package]]
name = "swc_visit"
-version = "0.5.9"
+version = "0.5.13"

[[package]]
name = "swc_visit_macros"
-version = "0.5.10"
+version = "0.5.11"
]

@mischnic
Copy link
Contributor

Not sure if this is related, but we're also seeing a segfault after upgrading swc in Parcel. But only on Linux and Windows, not macOS (might be due to different stack sizes though).

Bildschirmfoto 2024-04-11 um 11 42 10

It happens when processing a file with a very deep AST due to string concatenation: https://unpkg.com/browse/highlight.js@11.9.0/lib/languages/isbl.js

Upgrade PR: parcel-bundler/parcel#9574

@kdy1
Copy link
Member Author

kdy1 commented Apr 11, 2024

I think it would worth to try reverting some dependency version upgrades. (of swc crates)

I'll create a PR later today

@kdy1
Copy link
Member Author

kdy1 commented Apr 11, 2024

I reduced the range of commits, and I guess the cause is visitor changes in

These PRs had a noticeable impact on the compile time of turbopack, because these PRs change the way rustc instantiates generic for visitor traits. But it can also affect the way the stack space is used.

@mmastrac
Copy link

We're currently working on debugging this via ASAN and Valgrind in Deno as well, but it's been difficult to repro it outside of a full Deno binary.

@mmastrac
Copy link

mmastrac commented Apr 11, 2024

I found a bug in hstr with atom store merging and stale pointers. I am not convinced this is the underlying cause but it's possible.

dudykr/ddbase#33

@bgw
Copy link

bgw commented Apr 11, 2024

@mmastrac I've had some concerns about potential bugs in hstr merging, but it doesn't appear that swc_atom uses the merging functionality.

Potentially the alias field could be removed entirely to save 64 bits per unique string.

@kdy1
Copy link
Member Author

kdy1 commented Apr 12, 2024

AtomStore::merge is not used anywhere, and I think we can remove it with a minor bump (to 0.3)

@kdy1
Copy link
Member Author

kdy1 commented Apr 12, 2024

Can you all try #8849? You can depend on using git specifier.

[patch.crates-io]
swc_core = { git = "https://github.com/kdy1/swc.git", branch = "segfault" }

@mischnic
Copy link
Contributor

mischnic commented Apr 12, 2024

Can you all try #8849? You can depend on using git specifier.

I was about to answer "yes, that does fix it".
But as part of that, I had to run cargo update, which on it's own also solves the problem for me.

So just this version bump was enough for Parcel (together the the currently published crates):

diff --git a/Cargo.lock b/Cargo.lock
index 6795a8883..15859184b 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -681,15 +681,16 @@ dependencies = [
 
 [[package]]
 name = "hstr"
-version = "0.2.6"
+version = "0.2.10"
 source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "de90d3db62411eb62eddabe402d706ac4970f7ac8d088c05f11069cad9be9857"
+checksum = "96274be293b8877e61974a607105d09c84caebe9620b47774aa8a6b942042dd4"
 dependencies = [
+ "hashbrown 0.14.3",
  "new_debug_unreachable",
  "once_cell",
  "phf",
  "rustc-hash",
- "smallvec",
+ "triomphe",
 ]
 
 [[package]]
@@ -1940,9 +1941,9 @@ checksum = "73473c0e59e6d5812c5dfe2a064a6444949f089e20eec9a2e5506596494e4623"
 
 [[package]]
 name = "swc_atoms"
-version = "0.6.5"
+version = "0.6.6"
 source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "7d538eaaa6f085161d088a04cf0a3a5a52c5a7f2b3bd9b83f73f058b0ed357c0"
+checksum = "04d9d1941a7d24fc503efa29c53f88dd61e6a15cc371947a75cca3b48d564b5b"
 dependencies = [
  "hstr",
  "once_cell",
@@ -2740,6 +2741,16 @@ dependencies = [
  "once_cell",
 ]
 
+[[package]]
+name = "triomphe"
+version = "0.1.11"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "859eb650cfee7434994602c3a68b25d77ad9e68c8a6cd491616ef86661382eb3"
+dependencies = [
+ "serde",
+ "stable_deref_trait",
+]
+
 [[package]]
 name = "typed-arena"
 version = "2.0.2"

@mischnic
Copy link
Contributor

So just this version bump was enough for Parcel

Actually, that only fixed it on Linux.

Windows still fails with exit code 3221225725 (so stack overflow) even with #8849.

@mmastrac
Copy link

We just bumped LLVM from 16 to 17 on our CI and it appears to have fixed the crash we were seeing in Deno. It's possible this was a miscompilation or LTO bug.

I'm curious what LLVM toolchains everyone else is using. I was never able to pin down a specific bit of UB that caused this, and our Miri builds have been clean.

@bgw
Copy link

bgw commented Apr 12, 2024

@mmastrac I've been reproducing the issue reported in vercel/next.js#63924 with LLVM 18 on Debian 12 arm64 (with rust installed via rustup):

$ rustc --version --verbose
rustc 1.79.0-nightly (aa067fb98 2024-04-10)
binary: rustc
commit-hash: aa067fb984d36462548bb785da221bfaf38253f0
commit-date: 2024-04-10
host: aarch64-unknown-linux-gnu
release: 1.79.0-nightly
LLVM version: 18.1.3

I've also reproduced the issue on x86_64 Linux, as well as ARM64 Windows. The original user report was from a person using (presumably x86_64) Windows.

@kdy1 #8849 does not appear to help.

FWIW, here's the full unabbreviated output from valgrind: https://gist.github.com/bgw/b6f4a4439593efbcabbdba7f0a9f5362

I've tried every combination LLVM sanitizer I can think to try (memory, address, and thread sanitizer), and none of them catch any issues.

I was able to reproduce the issue inside rr on x86_64 Linux, but the actual segfault occurs deep inside of a macro (so the source code mapping was useless), and it was a bit beyond my skillset to figure out what was going on.

@dsherret
Copy link
Contributor

I've tried every combination LLVM sanitizer I can think to try (memory, address, and thread sanitizer), and none of them catch any issues.

Such is our life 😢

@mmastrac
Copy link

@bgw Are you able to isolate the problem from the rest of the code in your case? We have not been able to identify a specific failing case outside of the entire system.

Given our lack of Miri errors in the experiments we have run, and general difficulty in reproducing it, I'm starting to lean towards a Rust or LLVM mis-compilation (potentially during LTO) of valid code.

@mischnic
Copy link
Contributor

mischnic commented Apr 14, 2024

I think for Parcel, the current versions work "correctly" now.
The remaining Windows problem appears to be a proper stack overflow, running swc inside of a rayon thread happens to fix it for the version from 2 months ago, and then some recent change must have introduce more calls and overflowed the stack yet again. Potentially because the AST is now slightly deeper due to the assignment pattern change

So effectively #1627, but this time it fails in release mode as well and in a real world example (bundling the highlight.js npm package).

@kdy1
Copy link
Member Author

kdy1 commented Apr 15, 2024

@mmastrac next.js uses nightly-2024-04-03, and @swc/core uses nightly-2024-02-06.

It may worth to reproduce the next.js segfault using @swc/core

@kdy1
Copy link
Member Author

kdy1 commented Apr 15, 2024

I'll fix #1627 to avoid excessive stack usage

@bgw
Copy link

bgw commented Apr 15, 2024

I think I managed to narrow the crash in vercel/next.js#63924 down to a dependency on node-mysql2. That does have a massive binary expression, which does line up with what I was seeing in GDB/LLDB (I had just convinced myself that valgrind was more trustworthy), and with what @kdy1 is hypothesizing in #1627:

https://github.com/sidorares/node-mysql2/blob/63f1055c631e665179cad686afd3e4f1d5c162b2/lib/constants/ssl_profiles.js

@dsherret
Copy link
Contributor

Hmmm... we were able to reproduce it with just this code: https://deno.land/x/which@0.3.0/mod.ts?source=

@bgw
Copy link

bgw commented Apr 16, 2024

@dsherret It's very likely that the root cause of your segfault is different than mine or @mischnic's. @mischnic's issue is also related to a long string concatenation.

@kdy1
Copy link
Member Author

kdy1 commented Apr 16, 2024

It turns out that parser is fine with a very large input.

#8861

@dsherret
Copy link
Contributor

Yeah, we haven't had any issues parsing deeply nested code since the introduction of stacker.

@kdy1
Copy link
Member Author

kdy1 commented Apr 16, 2024

Can you provide the list of passes (impl Fold) used by Deno? I'll fix them first

@dsherret
Copy link
Contributor

dsherret commented Apr 16, 2024

@kdy1 sure!

// https://github.com/denoland/deno_ast/blob/c73eea7eb9aa1a5c2ccc8524fa36fb695fb129f1/src/transpiling/mod.rs#L308
let mut passes = chain!(
    resolver(unresolved_mark, top_level_mark, true),
    proposal::decorator_2022_03::decorator_2022_03(),
    proposal::explicit_resource_management::explicit_resource_management(),
    helpers::inject_helpers(top_level_mark),
    typescript::typescript(typescript::Config {
      verbatim_module_syntax: false,
      import_not_used_as_values: typescript::ImportsNotUsedAsValues::Remove,
      no_empty_export: true,
      import_export_assign_config: typescript::TsImportExportAssignConfig::Preserve,
      ts_enum_is_mutable: true,
    }, top_level_mark),
    fixer(Some(comments)),
    hygiene(),
);

@kdy1
Copy link
Member Author

kdy1 commented Apr 16, 2024

I'm almost done with the fix, but linux CI is failing with stack overflow. Maybe I need to add more similar changes, but I don't have a linux device. I'll try WSL

kdy1 added a commit that referenced this issue Apr 16, 2024
**Description:**

 - This PR introduces an in-tree testing system for Deno.
 - This PR adds `stacker` cargo-feature to `swc_ecma_utils`.

**Related issue:**

 - #1627
 - Closes #8840
@kdy1 kdy1 modified the milestones: Planned, v1.4.15 Apr 17, 2024
@dsherret
Copy link
Contributor

dsherret commented May 2, 2024

Just giving a status update on this: we upgraded to the latest swc in the latest version of Deno and haven't run into any issues. Thanks for all the help!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging a pull request may close this issue.

5 participants