Skip to content

Soot frontend crashes on large projects due to missing optional dependencies on library classes #217

Description

@wuerror

📝 Overall Description

我尝试基于tai-e 0.5.2创建一个静态分析工具,在实际使用的时候发现在扫描中大型项目时,构建world非常容易失败,即便我设置了-ap(allow_phantom_refs=true)。

🎯 Expected Behavior

我预期是可以完成world构建,进行分析

🐛 Current Behavior

经典的报错如下:
java.lang.RuntimeException: Failed to apply jb to
<com.zaxxer.hikari.metrics.dropwizard.CodaHaleMetricsTracker: void (...)>

Caused by: This operation requires resolving level HIERARCHY
but com.codahale.metrics.Gauge is at resolving level DANGLING

at soot.FastHierarchy.canStoreClass(FastHierarchy.java:384)
at soot.jimple.toolkits.typing.fast.TypeResolver.insertCasts(TypeResolver.java:369)
at soot.jimple.toolkits.typing.fast.TypeAssigner.internalTransform(TypeAssigner.java:129)
at soot.asm.AsmMethodSource.getBody(AsmMethodSource.java:2279)
at soot.SootMethod.retrieveActiveBody(SootMethod.java:447)
at soot.jimple.toolkits.annotation.LineNumberAdder.internalTransform(LineNumberAdder.java:63)
at soot.PackManager.runPacksNormally(PackManager.java:496)
at pascal.taie.frontend.soot.SootWorldBuilder.runSoot(SootWorldBuilder.java:253)

ai分析:
分析

HikariCP 包含一个 Dropwizard Metrics 适配器类,引用了 com.codahale.metrics.Gauge。这是可选依赖,大多数项目不会引入 metrics-core。

Soot 的 PackManager.runPacksNormally() 对所有 application class 执行 jb pack,LineNumberAdder 遍历所有方法调用 retrieveActiveBody(),触发 TypeAssigner →
FastHierarchy.canStoreClass(),要求引用类至少达到 HIERARCHY 解析级别。但 phantom class 只有 DANGLING 级别。

即使设置了 -ap(allow_phantom_refs=true),FastHierarchy 的类型检查仍然不尊重这个设置,直接抛异常。

这不是个例——真实企业项目中大量库存在可选依赖(HikariCP→Metrics、Spring→AspectJ weaver、MyBatis→Ehcache 等),只要 classpath 上有任何一个库引用了不存在的类,整个 World
构建就失败。

Tai-e 侧的限制

SootWorldBuilder.initSoot() 中排除列表硬编码为 List.of("jdk.", "apple.laf."),且未调用 set_no_bodies_for_excluded(true)。initSoot() 和 runSoot() 均为 private
static,下游无法通过继承注入配置。

目前只能通过反射调用这两个 private 方法,在中间注入 Soot 排除选项来 workaround,非常脆弱。

🔄 Reproducible Example

No response

⚙️ Tai-e Arguments

javaVersion: 17
prependJVM: true # -pp
allowPhantom: true # -ap
worldBuilderClass: pascal.taie.frontend.soot.SootWorldBuilder
analyses:
pta: "cs:ci;only-app:true;taint-config:/taint-config.yml;implicit-entries:true"

classpath 规模

appClassPath: 231 entries # --app-class-path(业务 JAR)
classPath: 296 entries # --class-path(库 JAR)

共计 527 个 JAR/目录

📜 Tai-e Log

Writing log to D:\collect_code\xxx-crm\app-server\alljar.jbytescanner\tai-e.log

ℹ️ Additional Information

No response

Activity

  1. jjppp commented on Mar 1, 2026

    @jjppp
    Member

    Thanks for writing this issue in Chinese, it makes it very easy for a few of us developers to read. However, Tai-e is a project with an international focus, and we aim to keep our community discussions in as widely accessible a language as possible, which is English. This helps us share our open-source progress with interested individuals from all over the world. Kindly consider using English for communication in the future. We appreciate your understanding. Thank you.


    We're working on integrating the new frontend to Tai-e to address issues due to Soot (#206), please stay tuned.

  2. changed the title [-]Soot 前端在大型项目上因库类缺失可选依赖而崩溃,World 构建完全失败[/-] [+]Soot frontend crashes on large projects due to missing optional dependencies on library classes[/+] on Mar 1, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions