Calling `retain` on a closed ArrowBuf revives it, into an undefined state
- Langage dominant
- Java
- Étoiles
- 94
- Forks
- 152
- Merge moyen
- 3 j 16 h
- PR mergées (30 j)
- 11
Description
### Describe the bug, including details regarding any error messages, version, and platform.
```kotlin
@Test
fun testArrowBufRetainBug() {
RootAllocator().use { al ->
val buf = al.buffer(10)
buf.close()
// correctly throws
assertThrows { buf.referenceManager.retain() }
assertEquals(0, buf.refCnt()) // nope, it's 1
// doesn't throw, ref-count is 1 - so the caller assumes they've successfully taken a reference
// but the underlying memory has already been reclaimed and re-used
assertThrows { buf.referenceManager.retain() }
}
}
```
Caused by the `getAndAdd` in `BufferLedger.retain(int)` - this is what leaves the ref-count positive, so on the next call, this doesn't fail.
Some kind of compareAndSet instead, perhaps?
Cheers,
James
Guide de contribution
Ouvrir le guide de contribution
Piste de recherche
Start at BufferLedger.retain(int), where the issue identifies getAndAdd as the source of the incorrect positive reference count. Run the provided testArrowBufRetainBug reproduction and verify that closing the buffer leaves refCnt() at 0 and that subsequent retain() calls still throw IllegalArgumentException.
Rédigé par le modèle d'indexation à partir du texte de l'issue.
Évaluation
- Stack technique
- java
- Domaine
- backend
- Type d'issue
- Bug
- Difficulté
- 3/5
- Temps estimé
- 1-2 jours
- Activité
- À l'abandon
- Clarté
- Clairement spécifiée
- Accessibilité débutants
- 52/100