-
Notifications
You must be signed in to change notification settings - Fork 166
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix eventfd logic and prevent multiple registrations
Commit 8874895 introduced a regression that manifests as a SIGSEGV. The reason for that is that the patch introduced Source reuse, in order to implement read coalescing. Calls to take_result() were transformed into result(), leaving the original Result in place for other consumers to peek. This is all fine for user-visible Sources, but our eventfd manipulation is a bit more intricate, and relied on the presence or absence of a Result to decide whether or not to install a new eventfd. As a result of the change, every time the reactor is invoked after the eventfd fired for the first time, a new eventfd source is registered, which is wrong. But what makes this problem really nasty is the fact that the kernel already knows about the previous address. When we register a new Source, we also add a new buffer. The kernel, though, will write to the previous buffer which was already freed when we installed the new one. Aside from fixing the issue, this patch also does the following: - adds more comments about eventfd, so people can more easily follow what's going on - adds an assert on fill_sqe's read. I can't imagine anyone outside of eventfd having a legitimate excuse to reuse a Source like this. - Adds a new buffer type, special for Eventfd. Not only this is good defensively, because even upon multiple registration the kernel would keep writing always to the same location, it also saves an allocation. Fixes #396 (cherry picked from commit 72b626f)
- Loading branch information
Glauber Costa
committed
Aug 12, 2021
1 parent
ab745cd
commit e6c129e
Showing
3 changed files
with
41 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters