GeezerVison is showing github.com — Sentinel object `Magazine.MAGAZINE_FREED` is possible be replaced without be restored back · Issue #14498 · netty/netty
Sentinel object Magazine.MAGAZINE_FREED is possible be replaced without be restored back #14498
Description
Expected behavior
If I understood it right, the sentinel object Magazine.MAGAZINE_FREED should not be replaced without being restored back.
Actual behavior
|
|
|
private void transferChunk(Chunk current) { |
|
if (NEXT_IN_LINE.compareAndSet(this, null, current) |
|
|| parent.offerToQueue(current)) { |
|
return; |
|
} |
|
Chunk nextChunk = NEXT_IN_LINE.get(this); |
|
if (nextChunk != null && current.remainingCapacity() > nextChunk.remainingCapacity()) { |
|
if (NEXT_IN_LINE.compareAndSet(this, nextChunk, current)) { |
|
if (nextChunk != MAGAZINE_FREED) { |
|
nextChunk.release(); |
|
} |
|
return; |
|
} |
|
} |
|
// Next-in-line is occupied AND the central queue is full. |
|
// Rare that we should get here, but we'll only do one allocation out of this chunk, then. |
|
current.release(); |
|
} |
|
|
The line:671 Chunk nextChunk = NEXT_IN_LINE.get(this); if nextChunk get value MAGAZINE_FREED, which is possible when magazines table is doing resizing, then the line:673 NEXT_IN_LINE.compareAndSet(this, nextChunk, current) will replace the MAGAZINE_FREED object by current, and without restored the MAGAZINE_FREED back.
Possible solution:
Modified line:672 to:
if (nextChunk != null && nextChunk != MAGAZINE_FREED
&& current.remainingCapacity() > nextChunk.remainingCapacity()) {
...
}
Netty version
4.1.115.Final
Activity
normanmaurer commented on Nov 25, 2024
laosijikaichele commented on Nov 25, 2024
ContributorAuthor
More actions
added 3 commits that reference this issue
on Nov 26, 2024This issue will close once commit 3d2b816 is merged into the '4.2' branch.3d2b816 This issue will close once commit 2e00270 is merged into the '4.2' branch.2e00270 This issue will close once commit 348ed8d is merged into the '4.2' branch.348ed8d
Metadata
Metadata
Development
No branches or pull requestsIssue actions