watcher icon indicating copy to clipboard operation
watcher copied to clipboard

Segmentation fault using wildcard in ignore option on Node.js v20.12.x (LTS)

Open rogerweb opened this issue 1 year ago • 9 comments

Using * in the ignore option is causing a Segmentation fault when running on Node.js v20.12.x onwards.

const watcher = require("@parcel/watcher")

watcher.subscribe(
    process.cwd(),
    (err, events) => {
        console.log(events)
    },
    { ignore: ["*.bkp"] }
)

It works on Node.js v20.11.1 but not in v20.12.1.

If you negate the expression using ! like in

{ ignore: ["!*.txt"] }

then you get another error:

free(): invalid pointer
Aborted

These apply to @parcel/watcher version 2.4.1 on Linux 5.10.0-28-amd64 #1 SMP Debian 5.10.209-2 (2024-01-31) x86_64 GNU/Linux.

rogerweb avatar Apr 08 '24 21:04 rogerweb

I seem to hit the same issue.

I work around it by replacing node_modules/@parcel/watcher-linux-x64-glibc/watcher.node (2.4.1) with locally built prebuilds/linux-x64/node.napi.glibc.node from the master branch (2.4.1) like this.

$ git clone https://github.com/parcel-bundler/watcher.git .
$ npm install prebuildify node-gyp-build
$ yarn prebuild
$ ls -l prebuilds/linux-x64/node.napi.glibc.node

My env:

$ uname -a
Linux ecf49bcced4d 5.15.133.1-microsoft-standard-WSL2 #1 SMP Thu Oct 5 21:02:42 UTC 2023 x86_64 GNU/Linux
$ cat /etc/debian_version
12.5

vvv ADDED vvv

  • node --version is v20.12.1 and ldd --version is ldd (Debian GLIBC 2.36-9+deb12u4) 2.36 in my environment.
  • Running yarn rebuild in node_modules/@parcel/watcher with @parcel/[email protected] also seems to work around the issue. This finding is based on information from one of my colleagues.

sakurai-youhei avatar Apr 10 '24 08:04 sakurai-youhei

I and quite a few of my colleagues are experiencing these segfaults as well. We had to resort to a workaround from https://github.com/parcel-bundler/watcher/issues/170#issuecomment-2046882889

@parcel/watcher version 2.4.1
---
$ uname -a
Linux azarch 6.8.4-arch1-1 #1 SMP PREEMPT_DYNAMIC Fri, 05 Apr 2024 00:14:23 +0000 x86_64 GNU/Linux

$ ldd --version
ldd (GNU libc) 2.39

$ node --version
v20.12.1

azasypkin avatar Apr 10 '24 10:04 azasypkin

I'm hitting this issue as well, and it is blocking our ability to upgrade our node version to fix the Node CVE that was reported. It would be great if there was a fix made for this issue.

jas7457 avatar Apr 17 '24 20:04 jas7457

Hey @yamadapc any update on this? Unfortunately this issue makes it so we can't update our node version due to our graphql-codegen (which uses parcel watcher) breaking.

jas7457 avatar Apr 25 '24 12:04 jas7457

@yamadapc , this should be reproducible on this codesandbox. Thanks for the minimal way to reproduce it, @rogerweb.

jas7457 avatar May 07 '24 11:05 jas7457

Upgrading Node from 20.12.2 to 20.13.1 fixed this for me.

Ikuni17 avatar May 14 '24 19:05 Ikuni17

Upgrading Node from 20.12.2 to 20.13.1 fixed this for me.

It potentially could be https://github.com/nodejs/node/pull/52349 included in 20.13.0

benmccann avatar May 20 '24 23:05 benmccann

Upgrading to 20.13 also worked for me. Issues like this remind why its important to keep node on the most active devel version.

lbxa avatar Jun 10 '24 02:06 lbxa

If anyone is still seeing this, please test @parcel/watcher v2.4.2-alpha.0, which includes https://github.com/parcel-bundler/watcher/pull/177 to fix some use after free issues and see if it helps.

devongovett avatar Jun 13 '24 06:06 devongovett

Upgrading Node to latest (20.16 in my case) fixed the issue

IlCallo avatar Aug 10 '24 10:08 IlCallo

I have the same symptom with Node 22.

Here's the example repo to reproduce.

https://github.com/mtsmfm/parcel-watcher-segv

Shall I file another issue?

mtsmfm avatar Aug 26 '24 11:08 mtsmfm

It happens with v2.4.2-alpha.0 as well

mtsmfm avatar Aug 26 '24 11:08 mtsmfm

running into the same issue with latest node22. @mtsmfm can you create a new issue with your example repo?

Amplifiyer avatar Aug 26 '24 15:08 Amplifiyer

Created https://github.com/parcel-bundler/watcher/issues/184

mtsmfm avatar Aug 26 '24 15:08 mtsmfm