-
Notifications
You must be signed in to change notification settings - Fork 38
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
Segfault on InotifyBackend::handleSubscription #49
Comments
Thanks for the report. One thing you could try would be to use a debug build to get a more accurate backtrace. You could do this by cloning the repo locally and running |
Sorry I provided a coredump thinking you could use it, but now I realise it's not really possible. I'll try to get a coredump with a debug build and extract meaningful information from it, like full stack state, local variables, and precise line numbers, and I'll come back to you then but it might take some time since I don't know when the next crash will happen:( |
I have a coredump for the debug build now. I looked a bit with vscode inside it and found the segfault to be there: watcher/src/linux/InotifyBackend.cc Line 151 in 52a2dd2
The reason is that the watcher mIgnore property is corrupted. But also much more interesting is that the mDir is also corrupted, at this point in the code it is equal to m\xa5z:\xf8U .
I guess at some point the watcher data has been corrupted, but I have no clue yet on why it happened. If you want more detail or have any idea on where to look I'm all ears! |
@devongovett Some more insight. Just to add some context, the way I use this library is having multiple subscriptions to multiple directories. When I start my application, I start watching these directories with one subscription for each:
So basically, what I do is this somewhere in my code: const subscriptions = await Promise.all(
directories.map(
(directory) => watcher.subscribe(directory, (err, events) => processFn(directory, err, events)
)
); Then later my code will produce some artifacts, and when everything is done I want to save a snapshot of the filesystem. So it looks like that: const processFn = async (directory, err, events) => {
// Do some stuff
await processEventsAsync(events);
// Save a snapshot
watcher.writeSnapshot(
directory,
someFilePathThatDontInterfereWithWatchingInAnyWay
)
} So first remark here, I know that what I do differs with what you do with parcel (v2) since in parcel there is two assumptions: I have my reasons to save a With this context in mind, what pops in my eyes now in the screenshot is that:
Looking at the code it means that either Line 183 in 52a2dd2
There are many places where this code can be called but not that much. Given the context, the place that I find interesting is this one: Line 55 in 52a2dd2
Indeed, recall that the segfault is on this line: watcher/src/linux/InotifyBackend.cc Line 151 in 52a2dd2
So it means that we are currently processing some input events has part of the process of watching. But like the coredump tells us, it seems the watcher instance is corrupted, ie. maybe at this point the C++ object has been destroyed because of an unref calls, which will trigger this line: Line 187 in 52a2dd2
So maybe this segfault is really a race condition between a subscription beeing active, and calls to If this is the case, the reason why my code crash from time to time is that I am violating condition (A2), which can lead to this segfault. What do you think ? EDIT: another coredump today, same problem with also a corrupted watcher. Also I realized that having the |
🔦 Context
Hi,
I am using
@parcel/watcher
as part of one of my personal project, and I noticed that my program crash sometime without any error message from node.After some investigation it appears that @parcel/watcher is
segfaulting
on this line:watcher/src/linux/InotifyBackend.cc
Line 143 in 52a2dd2
😯 Description
I can't reproduce the issue, and sometime I don't have it for a few days. So what I did is I added an extensive logging to my app so I can get a hint.
One hour ago , I got the crash again so this time I looked at my logs and found this:
So now that I know I have a
SEGFAULT
at15:10:51
, I looked at my core dumps (I run on Linux):Then I looked at the stack trace:
Unfortunately, I am not able to reproduce the issue and most of the time my program don't crash, I am not even able to tell you if there is a pattern or whatever.
One thing I can tell you is that I am using multiple calls to
subscribe
to watch different directories in the same time, so maybe this segfault is triggered by one of the watcher when some file is updated.:watcher/index.js
Line 30 in 52a2dd2
On the other hand, I can provide you a complete core dump here so you can use
gdb
or whatever to have more info on this segfault.🌍 Your Environment
The text was updated successfully, but these errors were encountered: