GeezerVisonThe World Wide Web, restored to 800 pixels of glory. | |
| Home|About|Gaming cabinet|Archives|How it works|Starter sites | |
GeezerVison is showing github.com — Grow KQueueEventArray correctly in realloc (#18102) by chrisvest · Pull Request #18248 · netty/netty Conversation
Member
Motivation:
Modification:
Result:
(cherry picked from commit 454fecb)
Sorry, something went wrong. Uh oh!
There was an error while loading. Please reload this page. All reactionsMotivation: `KQueueEventArray.realloc(...)` copies the old content with `memory.position(0).limit(size)`, but `size` is the number of kevents and not a number of bytes, so only the first `size` bytes (the first `size / sizeof(kevent)` events) survive and the rest of the pending changes are lost. It also never updates `capacity` after allocating the bigger buffer, so the `size == capacity` check in `evSet(...)` never fires again. Once more than `capacity` changes are added in one event loop iteration, `evSet(...)` writes past the end of the direct buffer and corrupts native memory. The same stale `capacity` is passed to `kevent(...)` for the event list, so growing that list had no effect. Modification: - Copy `size * sizeof(kevent)` bytes and use a duplicate of the old buffer so its position and limit are not modified. - Update `capacity` after the new buffer was installed. - Add `KQueueEventArrayTest`, which adds more events than the initial capacity and verifies that all of them are kept. Without the fix the test JVM crashes. Result: `KQueueEventArray` keeps all events and its capacity when it grows, and no longer writes outside of its memory. (cherry picked from commit 454fecb)
|
There was an error while loading. Please reload this page.
✅ All tests passed ✅🏷️ Commit: c0012f8 Learn more about TestLens at testlens.app/docs. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
Successfully merging this pull request may close these issues.
There was an error while loading. Please reload this page.