apache / apache/arrow-java

Calling `retain` on a closed ArrowBuf revives it, into an undefined state

Abierto
#906 8 comentarios 0 reacciones 0 asignados Ver en GitHub
Type: bug
Lenguaje dominante
Java
Estrellas
94
Forks
152
Merge medio
3 d 16 h
PR fusionados (30 d)
11

Descripción

### 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

Guía de contribución

Abrir la guía de contribución

Línea de trabajo

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.

Escrito por el modelo de indexación a partir del texto del issue.

Evaluación

Stack tecnológico
java
Área
backend
Tipo de issue
Error
Dificultad
3/5
Tiempo estimado
1-2 días
Estado de actividad
Estancado
Claridad
Bien especificado
Aptitud para principiantes
52/100

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.