NonAtomicVolatileUpdate misses volatile increments and decrements with parenthesized operands
Los mantenedores suelen responder en 1 día
Nadie ha tomado este issue todavía.
Evaluación
- Dificultad
- 2/5
- Tiempo estimado
- 1-3 horas
- Aptitud para principiantes
- 76/100
- Tipo de issue
- Error
- Claridad
- Bien especificado
- Estado de actividad
- Activo
- Stack tecnológico
- java
- Área
- testing-qa
Línea de trabajo
Empieza con la comprobación NonAtomicVolatileUpdate e inspecciona cómo reconoce los operandos de incremento y decremento. El issue señala ASTHelpers.stripParentheses como una posible forma de manejar operandos entre paréntesis. Añade cobertura para incrementos y decrementos entre paréntesis de campos volátiles int y long, y confirma que ambas formas producen cuatro hallazgos.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
Error Prone version
Error Prone 2.49.0 (javac 21.0.8, --source/--target 21)
Affected checks
NonAtomicVolatileUpdate
Description
Adding redundant parentheses around the operand of an increment or decrement causes NonAtomicVolatileUpdate to miss non-atomic updates of volatile fields. For example, (x)++ performs the same read-modify-write as x++, but only the latter is reported. The same issue occurs with decrement operations and with both int and long fields in the reproducer.
Per JLS §15.8.5, parentheses around an expression do not change its value, type, or constant-expression status. The two forms should therefore produce the same findings.
I verified the following pair on Error Prone 2.49.0:
| Check | Rewrite | BEFORE | AFTER | Effect |
|---|---|---|---|---|
NonAtomicVolatileUpdate |
x++ → (x)++ (also y++, x--, and y--) |
4 | 0 | false negative |
The matcher appears to inspect the increment/decrement operand without looking through ParenthesizedTree. A possible fix is to unwrap the operand before matching it, for example with ASTHelpers.stripParentheses.
Reproducers
NonAtomicVolatileUpdate — (x)++ is missed
(x)++ is the same non-atomic read-modify-write of a volatile field as x++.
// BEFORE — 4 findings
public class Vol {
volatile int x;
volatile long y;
void bad() { x++; y++; x--; y--; }
}
// AFTER — 0 findings
public class Vol {
volatile int x;
volatile long y;
void bad() { (x)++; (y)++; (x)--; (y)--; }
}
Expected behavior
Both versions should produce 4 NonAtomicVolatileUpdate findings, one for each increment or decrement of a volatile field. Redundant parentheses do not make these updates atomic.
Actual behavior
The BEFORE version produces 4 findings. The AFTER version produces 0 findings, missing all four non-atomic volatile updates after their operands are parenthesized.
- Lenguaje dominante
- Java
- Estrellas
- 7.3k
- Forks
- 827
- Merge medio
- 21 h 35 min
- PR fusionados (30 d)
- 60
Preparar el entorno
- Sin Dockerfile ni archivo de Docker Compose
- Sin plantilla de pull request
- Leer la guía de contribución
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Más de google/error-prone
-
ASTHelpers.getSymbol returns null for a parenthesized expression, while javac's TreeInfo.symbol returns the symbol insidePosiblemente ocupada @vlsi la tomó hace 7 días. Abierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 72/100
google/error-prone#6223 ·
Los mantenedores suelen responder en 1 día
-
InlineTrivialConstant misses an empty-string constant with a parenthesized initializerPosiblemente ocupada @Youssef-Khogaly la tomó hace 8 días. Abierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 72/100
google/error-prone#6217 · 1 comentario ·
Los mantenedores suelen responder en 1 día
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 72/100
google/error-prone#6216 ·
Los mantenedores suelen responder en 1 día
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 74/100
google/error-prone#6215 ·
Los mantenedores suelen responder en 1 día
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 76/100
google/error-prone#6213 ·
Los mantenedores suelen responder en 1 día
Todos los issues de google/error-prone
Issues similares
-
priority: p2 type: bug
Dificultad 2/5 1-3 horas Aptitud para principiantes 68/100
googleapis/java-genai#1372 ·
Los mantenedores suelen responder en 1 día
-
GeoSeries scale and skew tests fail with pytest 9.2.0Posiblemente ocupada @jiayuasu la tomó hoy. Abierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 82/100
Los mantenedores suelen responder en 1 día
-
Preventions: a dose saved without a unit reopens blank, and an unchanged save then erases itAbiertopriority: medium Review effort [1-5]: 3 status: needs-triage type: bug
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
carlos-emr/carlos#5431 ·
Los mantenedores suelen responder en 1 día
-
Integration tests: jetty:run fails with WELD-001408 for CountryJpaServicePosiblemente ocupada @viniciusmachak la tomó hoy. Abierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 66/100
primefaces/primefaces#15431 ·
Los mantenedores suelen responder en 1 día
-
test(multi-tenancy): assert cross-tenant vulnerability reads are refused in the CWE isolation testAbierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 72/100
OpenAEV-Platform/openaev#8792 ·
Los mantenedores suelen responder en 2 días