antgroup / antgroup/YASA-Engine

pkg 二进制在大中型 Java 项目上因 Node 18.5.0 V8 bug 崩溃

Open
#143 0 comments 0 reactions 1 assignee View on GitHub

@AntJiuFo is already working on this.

Since Jul 17, 2026.

Dominant language
TypeScript
Stars
323
Forks
40
PR merge metrics
No merged PRs in 30d

Description

环境信息
  • YASA 版本:v0.3.1(最新 release 二进制)
  • 操作系统:Ubuntu 22.04 LTS
  • 项目规模:100+ Java 文件(Spring Boot 应用)
复现步骤
./yasa-engine-linux-x64 \
  --sourcePath /path/to/100-plus-java-files-project \
  --language java \
  --checkerIds taint_flow_java_input \
  --ruleConfigFile resource/example-rule-config/rule_config_java.json \
  --maindirPrefix /path/to/100-plus-java-files-project

崩溃发生在 startAnalyze 阶段(parseCode 正常完成后)。

崩溃日志
#
# Fatal error in , line 0
# Fatal JavaScript invalid size error 169220804
#
#
#
#FailureMessage Object: 0x7fffd67a31f0
 1: 0xa73bd1  [./yasa-engine-linux-x64]
 2: 0xebf5e9 V8_Fatal(char const*, ...) [./yasa-engine-linux-x64]
 3: 0x137cba8  [./yasa-engine-linux-x64]
 4: 0x153d7cf  [./yasa-engine-linux-x64]
 5: 0x154283a  [./yasa-engine-linux-x64]
 6: 0x1762f14 v8::internal::Runtime_GrowArrayElements(int, unsigned long*, v8::internal::Isolate*) [./yasa-engine-linux-x64]
 7: 0x1bb6239  [./yasa-engine-linux-x64]
Trace/breakpoint trap
根因分析

Release 二进制内嵌的 Node 版本为 18.5.0(2022 年 7 月发布),已通过以下命令确认:

$ strings ./yasa-engine-linux-x64 | grep -E "^v[0-9]+\.[0-9]+\.[0-9]+$" | head -5
v18.5.0

Node 18.5.0 搭载的 V8 引擎(v10.2)存在一个数组扩容 bug(Runtime_GrowArrayElements)。在大中型 Java 项目中,YASA 的 TypeResolver 构建类型层次或 Call Graph 遍历时,会触发异常的数组扩容请求(尝试分配约 1.69 亿个元素),直接导致 V8 崩溃。

同份代码用 Node 22 运行正常
node --max-old-space-size=13312 dist/main.js \
  --sourcePath /path/to/100-plus-java-files-project \
  --language java \
  --checkerIds taint_flow_java_input \
  --ruleConfigFile resource/example-rule-config/rule_config_java.json \
  --maindirPrefix /path/to/100-plus-java-files-project

# 输出:
# [YASA] Execution completed
# Total-findings: N

同一份 dist/ 代码,用 Node 22 直接运行完全正常,说明问题出在 pkg 内嵌的 Node 版本,而非 YASA 引擎代码。

建议
  1. 文档说明:在 README 或 Release 页面增加提示:

    大中型项目推荐直接用 Node ≥ 20 运行,避免 pkg 内嵌 Node 18 的 V8 崩溃问题:
    node --max-old-space-size=8192 dist/main.js --sourcePath ...

用户侧临时解决方案

在修复前,用 Node ≥ 20 直接运行:

node --max-old-space-size=13312 dist/main.js \
  --sourcePath /path/to/project \
  --language java \
  --checkerIds taint_flow_java_input \
  --ruleConfigFile resource/example-rule-config/rule_config_java.json \
  --maindirPrefix /path/to/project

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.