-
-
Notifications
You must be signed in to change notification settings - Fork 16.3k
Sentinel object Magazine.MAGAZINE_FREED is possible be replaced without be restored back #14498
Copy link
Copy link
Closed
Milestone
Description
Expected behavior
If I understood it right, the sentinel object Magazine.MAGAZINE_FREED should not be replaced without being restored back.
Actual behavior
netty/buffer/src/main/java/io/netty/buffer/AdaptivePoolingAllocator.java
Lines 665 to 684 in afa465a
| 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
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels