parcel-bundler / watcher

👀 A native C++ Node module for querying and subscribing to filesystem events
MIT License
656 stars 45 forks source link

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

Closed rogerweb closed 1 month ago

rogerweb commented 6 months ago

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.

sakurai-youhei commented 5 months ago

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

azasypkin commented 5 months ago

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
jas7457 commented 5 months ago

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 commented 5 months ago

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 commented 5 months ago

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

Ikuni17 commented 4 months ago

Upgrading Node from 20.12.2 to 20.13.1 fixed this for me.

benmccann commented 4 months ago

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

lbxa commented 3 months ago

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

devongovett commented 3 months ago

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.

IlCallo commented 1 month ago

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

mtsmfm commented 1 month ago

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 commented 1 month ago

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

Amplifiyer commented 1 month ago

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

mtsmfm commented 1 month ago

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