False error: a local declared inside try is "not found" at a call in finally
Maintainer antworten meist innerhalb von 2 Tagen
Dieses Issue hat noch niemand übernommen.
Bewertung
- Schwierigkeit
- 4/5
- Geschätzter Aufwand
- 3-5 Tage
- Anfängerfreundlichkeit
- 20/100
Rechercherichtung
Start by reproducing the report: save the Repro class from the issue and run LiquidJava on it to see the Not Found Error at input.close() in the finally. The cause is that the state of input recorded at the end of the try still mentions the block-local length, which is out of scope when the finally checks close(). Done means the repro passes verification and the change does not break the existing tests.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Beschreibung
With the Barista BufferedInputStream spec (read() returns _ >= -1; read(byte[], int, int) refines its length):
import java.io.*;
public class Repro {
static int load(InputStream raw, boolean known) throws IOException {
BufferedInputStream input = new BufferedInputStream(raw);
try {
int cost = 0;
if (known) {
int length = input.read();
if (length >= 0) {
byte[] nonce = new byte[length];
input.read(nonce, 0, length);
}
}
return cost;
} finally {
input.close();
}
}
}
On main 1c6807be (and 321a7321):
Not Found Error: Variable 'length' could not be found
input.close(); (in the finally)
length is a block-local of the try; the state of input recorded in the try (after read(nonce, 0, length)) mentions it, and when the finally checks close() against that state, length is out of scope. Expected: Correct! Passed Verification. (out-of-scope locals should be eliminated or kept as fresh variables when the state flows into the finally / after the block).
Found in a real-code example (secrets-for-android FileUtils, a length-prefixed read in try/finally). Since #366 the example's earlier workaround (guarding with a block instead of an early return) no longer avoids it.
- Vorherrschende Sprache
- Java
- Sterne
- 69
- Forks
- 36
- Ø Merge
- 2 T. 1 Std.
- Gemergte PRs (30 T.)
- 35
Entwicklungsumgebung
- Kein Dockerfile und keine Docker-Compose-Datei
- Hat eine Pull-Request-Vorlage
- Beitragsleitfaden lesen
Erste Schritte
- Lesen Sie das ganze Issue und danach den Beitragsleitfaden des Projekts.
- Schreiben Sie ins Issue, dass Sie es übernehmen — das erspart doppelte Arbeit.
- Forken Sie das Repository und arbeiten Sie in einem Branch.
- Öffnen Sie einen Pull Request, der die Issue-Nummer nennt.
Mehr aus liquid-java/liquidjava
-
bug
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 82/100
liquid-java/liquidjava#395 ·
Maintainer antworten meist innerhalb von 2 Tagen
-
Verifier crashes on a comparison or other binary operator whose operand types cannot be resolved (classes not on the classpath)Evtl. vergeben @CatarinaGamboa hat das vor 3 Tagen übernommen. Offenbug
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 72/100
liquid-java/liquidjava#388 ·
Maintainer antworten meist innerhalb von 2 Tagen
-
enhancement
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 65/100
liquid-java/liquidjava#373 ·
Maintainer antworten meist innerhalb von 2 Tagen
-
Soundness: a local variable with a constant's name shadows the constant (Format.JPG read as local JPG)Evtl. vergeben @CatarinaGamboa hat das vor 3 Tagen übernommen. Offenbug
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 78/100
liquid-java/liquidjava#321 ·
Maintainer antworten meist innerhalb von 2 Tagen
-
bug
Schwierigkeit 4/5 3-5 Tage Anfängerfreundlichkeit 40/100
liquid-java/liquidjava#405 ·
Maintainer antworten meist innerhalb von 2 Tagen
Alle Issues in liquid-java/liquidjava
Ähnliche Issues
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 68/100
apache/rocketmq-dashboard#6872 ·
Maintainer antworten meist innerhalb von 3 Tagen
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 68/100
ADORSYS-GIS/token-status-link#168 ·
Maintainer antworten meist innerhalb von 2 Tagen
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 68/100
ADORSYS-GIS/keycloak-oid4vp-plugin#232 ·
Maintainer antworten meist innerhalb von 2 Tagen
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 72/100
Maintainer antworten meist innerhalb von 2 Tagen
-
documentation
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 62/100
devops-thiago/ThrillhouseBot#1132 ·
Maintainer antworten meist innerhalb von 1 Tag