Verifier crashes on a `for` loop whose body is an empty statement (`for (...) ;`)
维护者通常 2 天内回复
还没有人认领这个 Issue。
评估
调研方向
崩溃位于 src/main/java/liquidjava/processor/refinement_checker/RefinementTypeChecker.java 中的 visitCtFor,其中一个 lambda 在大约第 628 行对 CtFor.getBody() 调用了 getElements;同一路径在大约第 658 行经过 visitLoop。先阅读那里如何消费循环体,然后运行 issue 中的复现示例,它的循环体为空 ;。当该复现示例输出 Correct! Passed Verification.,并且现有的循环测试仍然通过时,即完成。
由索引模型根据 Issue 内容生成。
描述
Impact: verification stops with an internal error on any for loop whose body is an empty statement (;).
Description
for (...; ...; ...) ; has no body block: CtFor.getBody() is null, and RefinementTypeChecker.visitCtFor calls getElements on it (RefinementTypeChecker.java:628). Nothing in the loop needs a refinement, so an empty body could be checked as an empty block.
Minimal reproducer
public class Repro {
static int total(int[] counts) {
int total = 0;
for (int i = 0; i < counts.length; total += counts[i], i++)
;
return total;
}
}
Expected
Correct! Passed Verification.
Actual
Exception in thread "main" java.lang.RuntimeException:
Error while checking CtMethodImpl
on total(int[] counts) {
at Repro.java:2
with
Error while checking CtBlockImpl
on {
at Repro.java:2
with
Error while checking CtForImpl
on for (int i = 0; i < counts.length; total += counts[i], i++)
at Repro.java:4
with Cannot invoke "spoon.reflect.code.CtStatement.getElements(spoon.reflect.visitor.Filter)" because the return value of "spoon.reflect.code.CtFor.getBody()" is null
...
Caused by: java.lang.NullPointerException: Cannot invoke "spoon.reflect.code.CtStatement.getElements(spoon.reflect.visitor.Filter)" because the return value of "spoon.reflect.code.CtFor.getBody()" is null
at liquidjava.processor.refinement_checker.RefinementTypeChecker.lambda$visitCtFor$4(RefinementTypeChecker.java:628)
at liquidjava.processor.refinement_checker.RefinementTypeChecker.visitLoop(RefinementTypeChecker.java:658)
at liquidjava.processor.refinement_checker.RefinementTypeChecker.visitCtFor(RefinementTypeChecker.java:623)
Reproduced on main at ad055b49 (liquidjava-verifier 0.0.35).
Real-world file that hits it
for (int i = 0; i < updateCount.length; cnt += updateCount[i], i++) ;— tejeswarp/tungsten-replicator (file)
Context
Found while running LiquidJava on the original repository files of 53 real-world typestate and refinement bugs (the files our study exercises were simplified from). Each file is verified on its own, as a user would verify one file of a project, so the project's other classes and its dependencies are not on the classpath.
- 主要语言
- Java
- 星标
- 67
- 派生
- 36
- 平均合并
- 2 天 2 小时
- 30 天内合并 PR
- 34
环境准备
- 没有 Dockerfile 或 Docker Compose 文件
- 有 Pull Request 模板
- 阅读贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
liquid-java/liquidjava 的其他 Issue
-
Verifier crashes on a comparison or other binary operator whose operand types cannot be resolved (classes not on the classpath)可能已有人在做 @CatarinaGamboa 今天认领。 未关闭bug
难度 2/5 1-3 小时 新手友好度 72/100
liquid-java/liquidjava#388 ·
维护者通常 2 天内回复
-
enhancement
难度 2/5 1-3 小时 新手友好度 65/100
liquid-java/liquidjava#373 ·
维护者通常 2 天内回复
-
Soundness: a local variable with a constant's name shadows the constant (Format.JPG read as local JPG)可能已有人在做 @CatarinaGamboa 今天认领。 未关闭bug
难度 2/5 1-3 小时 新手友好度 78/100
liquid-java/liquidjava#321 ·
维护者通常 2 天内回复
-
bug
难度 4/5 3-5 天 新手友好度 40/100
liquid-java/liquidjava#405 ·
维护者通常 2 天内回复
-
bug
难度 3/5 半天 新手友好度 55/100
liquid-java/liquidjava#404 ·
维护者通常 2 天内回复
查看 liquid-java/liquidjava 的全部 Issue
相似的 Issue
-
:ml/Transform >bug Team:ML
难度 2/5 半天 新手友好度 64/100
elastic/elasticsearch#161960 · 2 条评论 · 1 个 reaction ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 62/100
维护者通常 4 天内回复
-
难度 2/5 1-3 小时 新手友好度 68/100
objectionary/lints#1556 ·
维护者通常 3 天内回复
-
难度 2/5 1-3 小时 新手友好度 65/100
wildfly/wildfly-launcher#99 ·
-
难度 2/5 1-3 小时 新手友好度 65/100
apache/rocketmq#11427 · 2 条评论 ·
维护者通常 1 天内回复