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

Updating to @swc/core to 1.10.6 from 1.10.4 causes a segfault on Windows #9855

Open
eamodio opened this issue Jan 8, 2025 · 11 comments
Open
Assignees
Labels
Milestone

Comments

@eamodio
Copy link

eamodio commented Jan 8, 2025

Describe the bug

In GitLens we are using SWC via the Terser Webpack Plugin (e.g. TerserPlugin.swcMinify).

And using 1.10.4 everything works great (and has been prior), but upgrading to 1.10.6 causes the webpack build to not succeed.

Running ./node_modules/.bin/webpack --mode production --config-name extension:node under Git Bash shows a Segmentation Fault message but nothing else, and under pwsh it outputs no error.

While pnpm run bundle:extension (which runs the same webpack line above) errors with  ELIFECYCLE  Command failed with exit code 3221225477.

Input code

No response

Config

No response

Playground link (or link to the minimal reproduction)

https://github.com/gitkraken/vscode-gitlens/tree/d61feb823e52be66d3a65383a80a102cab0120fd

SWC Info output

Operating System:
Platform: win32
Arch: x64
Machine Type: x86_64
Version: Windows 11 Pro
CPU: (32 cores)
Models: AMD Ryzen 9 7950X 16-Core Processor

Binaries:
    Node: 22.12.0
    npm: N/A
    Yarn: N/A
    pnpm: N/A

Relevant Packages:
    @swc/core: 1.10.6
    @swc/helpers: N/A
    @swc/types: N/A
    typescript: 5.7.2

SWC Config:
    output: N/A
    .swcrc path: N/A

Next.js info:
    output: N/A

Expected behavior

No segfault

Actual behavior

Segfault

Version

1.10.6

Additional context

No response

@eamodio eamodio added the C-bug label Jan 8, 2025
@kdy1 kdy1 self-assigned this Jan 9, 2025
@kdy1 kdy1 added this to the Planned milestone Jan 9, 2025
@kdy1
Copy link
Member

kdy1 commented Jan 9, 2025

I did npm dist-tag add @swc/[email protected] latest for now

@kdy1
Copy link
Member

kdy1 commented Jan 9, 2025

Investigation

My device

  • Node.JS: v22.13.0 (MSRV nodejs, installed via MSI installer)
    • Result of node -e "const p = require('node:process'); console.log('Arch:', p.arch, 'Platform:', p.platform)": Arch: x64 Platform: win32
  • Shell: Powershell
  • CPU: Intel Core i7 13700F (16 cores)

I did cargo test --features concurrent and cargo test --features concurrent --release for swc_ecma_minifier on x64
Windows device, but both worked

PS C:\Users\kdy1\projects\vscode-gitlens> pnpm run bundle:extension

> [email protected] bundle:extension C:\Users\kdy1\projects\vscode-gitlens
> webpack --mode production --config-name extension:node

(node:8300) [DEP0040] DeprecationWarning: The `punycode` module is deprecated. Please use a userland alternative instead.
(Use `node --trace-deprecation ...` to show where the warning was created)
extension:node:
  asset ai.js 33.8 KiB [emitted] [minimized] (name: ai)
  asset annotations.js 15 KiB [emitted] [minimized] (name: annotations)
  asset codelens.js 11.4 KiB [emitted] [minimized] (name: codelens)
  asset gitlens.js 1.77 MiB [emitted] [minimized] (name: extension)
  asset integrations.js 145 KiB [emitted] [minimized] (name: integrations)
  asset lib-encoding.js 266 KiB [emitted] [minimized] (name: lib-encoding)
  asset telemetry.js 79.7 KiB [emitted] [minimized] (name: telemetry)
  asset webview-commitDetails.js 33.7 KiB [emitted] [minimized] (name: webview-commitDetails)
  asset webview-graph.js 77.1 KiB [emitted] [minimized] (name: webview-graph)
  asset webview-home.js 23.9 KiB [emitted] [minimized] (name: webview-home)
  asset webview-patchDetails.js 29 KiB [emitted] [minimized] (name: webview-patchDetails)
  asset webview-settings.js 5.06 KiB [emitted] [minimized] (name: webview-settings)
  asset webview-timeline.js 8.63 KiB [emitted] [minimized] (name: webview-timeline)
  extension:node compiled successfully in 24795 ms
PS C:\Users\kdy1\projects\vscode-gitlens> node -v
v22.13.0

@kdy1
Copy link
Member

kdy1 commented Jan 9, 2025

@eamodio Can you run node -e "const p = require('node:process'); console.log('Arch:', p.arch, 'Platform:', p.platform)" from the repository directory?
And how did you install the nodejs?

@eamodio
Copy link
Author

eamodio commented Jan 9, 2025

Sure, Arch: x64 Platform: win32

Via winget

@kdy1
Copy link
Member

kdy1 commented Jan 9, 2025

Oops, I didn't update @swc/core.
I did pnpm up '@swc/core@latest but latest was 1.10.4 because I pinned 🤣.

@eamodio
Copy link
Author

eamodio commented Jan 9, 2025

I saw you were using Node 22.13.0, and I just upgraded (I was running 22.12.0), but didn't change anything

@kdy1
Copy link
Member

kdy1 commented Jan 9, 2025

스크린샷 2025-01-09 143928

I managed to capture it from the debugger

@kdy1
Copy link
Member

kdy1 commented Jan 9, 2025

I made a simulation for various situation and used cargo miri to debug this issue.
My guess is that it's related to the main thread exiting before other threads, but I need to verify.

kdy1 added a commit that referenced this issue Jan 9, 2025
@kdy1
Copy link
Member

kdy1 commented Jan 10, 2025

The problem is the usage of worker threads, which is known to have very bad interference with thread locals.

webpack-contrib/terser-webpack-plugin#580 (comment)

I'll send a PR to terser-webpack-plugin.

@kdy1
Copy link
Member

kdy1 commented Jan 10, 2025

Related: Brooooooklyn/canvas#377

@kdy1
Copy link
Member

kdy1 commented Jan 10, 2025

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

Successfully merging a pull request may close this issue.

2 participants