Soundness: try/catch is checked as if the catch block always runs
Mantenedores costumam responder em até 1 dia
Ninguém assumiu esta issue ainda.
Avaliação
- Dificuldade
- 4/5
- Tempo estimado
- 3-5 dias
- Facilidade para iniciantes
- 50/100
Direção de pesquisa
Locate where the verifier visits try/catch statements (search the visitor/checker for the try-statement case) and compare it with how if/else merges branch states at the join point — the issue says try/catch is currently sequenced instead of merged. Work out how both branches (normal exit from try, entry into catch at an arbitrary point) should be joined, and how the state after the join relates to the state on entry. Done means both reproducers in the issue report errors, the swapped-value case reports correctly, and existing verification tests still pass; add the reproducers as regression tests.
Escrita pelo modelo de indexação a partir do texto da issue.
Descrição
Impact: a real bug passes verification (false negative).
Description
The verifier checks try and catch blocks one after the other, so after a try/catch a variable keeps whatever the catch block last assigned. The path where the try finishes normally is lost. An if/else instead merges both branches after the join, and try/catch should be merged the same way.
Also, an exception can be thrown at any point in the try. The catch block should therefore not assume the try ran to completion, or that it never ran at all.
Minimal reproducer
import liquidjava.specification.ExternalRefinementsFor;
import liquidjava.specification.StateRefinement;
import liquidjava.specification.StateSet;
@ExternalRefinementsFor("java.lang.Throwable")
@StateSet({"withThrowable", "noThrowable"})
interface ThrowableRefinements {
@StateRefinement(to = "noThrowable(this)")
void Throwable(String message);
@StateRefinement(to = "withThrowable(this)")
void Throwable(String message, Throwable cause);
@StateRefinement(from = "noThrowable(this)", to = "withThrowable(this)")
Throwable initCause(Throwable cause);
}
public class Repro {
static void load() throws Exception { throw new Exception("x"); }
static void m() {
Throwable t = new Throwable("start");
try {
load();
t = new Throwable("try", new RuntimeException()); // withThrowable
} catch (Exception e) {
t = new Throwable("catch"); // noThrowable
}
t.initCause(new RuntimeException()); // not reported, but t is withThrowable if load() returns
}
}
Expected: a State Refinement Error on t.initCause(...), because t may be withThrowable.
Actual: Correct! Passed Verification.
Same bug with value refinements
static void m() {
int y = 0;
try {
load();
y = -5;
} catch (Exception e) {
y = 7;
}
@Refinement("_ > 0")
int z = y; // not reported, but y == -5 if load() returns
}
Actual: Correct! Passed Verification. If the values are swapped (5 in the try, -5 in the catch), the error is reported, but as z == -5 is not a subtype of z > 0: only the catch path is considered.
Found while reviewing #362 (catch parameters, #333).
- Linguagem predominante
- Java
- Estrelas
- 67
- Forks
- 36
- Merge médio
- 2d 3h
- PRs com merge (30d)
- 29
Preparar o ambiente
- Sem Dockerfile nem arquivo Docker Compose
- Tem um modelo de pull request
- Ler o guia de contribuição
Primeiros passos
- Leia a issue inteira e depois o guia de contribuição do projeto.
- Comente na issue dizendo que vai assumir — evita que duas pessoas façam o mesmo trabalho.
- Faça um fork do repositório e trabalhe em uma branch.
- Abra um pull request que referencie o número da issue.
Mais de liquid-java/liquidjava
-
enhancement
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 65/100
liquid-java/liquidjava#373 ·
Mantenedores costumam responder em até 1 dia
-
bug
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 78/100
liquid-java/liquidjava#321 ·
Mantenedores costumam responder em até 1 dia
-
enhancement
Dificuldade 5/5 Mais de uma semana Facilidade para iniciantes 25/100
liquid-java/liquidjava#381 ·
Mantenedores costumam responder em até 1 dia
-
enhancement future latte
Dificuldade 5/5 Mais de uma semana Facilidade para iniciantes 35/100
liquid-java/liquidjava#380 ·
Mantenedores costumam responder em até 1 dia
-
An external spec cannot refine methods its class inheritsTalvez já em andamento @CatarinaGamboa assumiu há 1 dia. Abertabug
Dificuldade 4/5 3-5 dias Facilidade para iniciantes 48/100
liquid-java/liquidjava#379 ·
Mantenedores costumam responder em até 1 dia
Todas as issues de liquid-java/liquidjava
Issues semelhantes
-
[BUG] 订单:会员凭订单号即可取消其他会员的待付款订单(取消接口不校验订单归属)Talvez já em andamento @dadiyang assumiu hoje. Aberta
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 70/100
macrozheng/mall#1016 ·
-
[Bug] The producer summary counts an unreported client version as a second version and warns about a version mixTalvez já em andamento Um pull request vinculado a esta issue está aberto ou já foi mesclado. Aberta
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 74/100
apache/rocketmq-dashboard#6110 ·
Mantenedores costumam responder em até 4 dias
-
Python 3.15 supportTalvez já em andamento @amnesiaof assumiu hoje. AbertaL: python L: python:uv
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 72/100
dependabot/dependabot-core#16524 · 1 comentário ·
Mantenedores costumam responder em até 1 dia
-
`Processing lsp` never exits and leaves orphaned processesTalvez já em andamento @overcast302 assumiu hoje. Abertabug
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 72/100
processing/processing4#1578 · 1 comentário ·
-
bug needs triage
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 72/100
PlayersCommittee/gemp-swccg-public#1174 ·
Mantenedores costumam responder em até 2 dias