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

inotify: fix panic on Remove() #650

Merged
merged 1 commit into from
Oct 28, 2024
Merged

inotify: fix panic on Remove() #650

merged 1 commit into from
Oct 28, 2024

Conversation

arp242
Copy link
Member

@arp242 arp242 commented Oct 28, 2024

It would do:

events := read_events_from_kernel()
for _, e := range events {
	watch := read_our_state(e)
	do_stuff_with(watch)
}

However, between read_events_from_kernel() and read_our_state() the internal state could have been removed with Watcher.Remove() in another goroutine, so it would return nil.

In many cases it already did "if watch != nil && [..]" to deal with this, but not everywhere. Do an "early continue" instead.

Fixes #616


Ideally what it should do is block any Remove() for all of the above code, so it always operates on a consistent state. But that's not so easy to do in a quick fix, and I don't really have the time to spend on this at the moment (and it seems no one else has either).

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
It would do:

	events := read_events_from_kernel()
	for _, e := range events {
		watch := read_our_state(e)
		do_stuff_with(watch)
	}

However, between read_events_from_kernel() and read_our_state() the
internal state could have been removed with Watcher.Remove() in another
goroutine, so it would return nil.

In many cases it already did "if watch != nil && [..]" to deal with
this, but not everywhere. Do an "early continue" instead.

Fixes #616

---

Ideally what it should do is block any Remove() for all of the above
code, so it always operates on a consistent state. But that's not so
easy to do in a quick fix, and I don't really have the time to spend on
this at the moment (and it seems no one else has either).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

panic in v1.7.0
1 participant