Memory leaks remain prevalent in real-world C/C++ software. Static analyzers such as CodeQL provide scalable program analysis but frequently miss such bugs because they cannot recognize project-specific custom memory-management functions and lack path-sensitive control-flow modeling. We present MemHint, a neuro-symbolic pipeline that addresses both limitations by combining LLMs' semantic understanding of code with Z3-based symbolic reasoning. MemHint parses the target codebase and applies an LLM to classify each function as a memory allocator, deallocator, or neither, producing function summaries that record which argument or return value carries memory ownership, extending the analyzer's built-in knowledge beyond standard primitives such as malloc and free. A Z3-based validation step checks each summary against the function's control-flow graph, discarding those whose claimed memory operation is unreachable on any feasible path. The validated summaries are injected into CodeQL and Infer via their respective extension mechanisms. Z3 path feasibility filtering then eliminates warnings on infeasible paths, and a final LLM-based validation step confirms whether each remaining warning is a genuine bug. On eight real-world C/C++ projects totaling over 3.6M lines of code, MemHint detects 54 unique memory leaks (53 confirmed/fixed) at approximately $1.7 per detected bug, compared to 19 by vanilla CodeQL and 3 by vanilla Infer.


翻译:内存泄漏在现实世界的 C/C++ 软件中仍然普遍存在。像 CodeQL 这样的静态分析器提供了可扩展的程序分析能力,但由于无法识别项目特定的自定义内存管理函数且缺乏路径敏感的控制流建模,经常遗漏此类缺陷。我们提出 MemHint,一种神经符号流水线,通过结合 LLM 对代码的语义理解与基于 Z3 的符号推理来解决这两个局限性。MemHint 解析目标代码库,并应用 LLM 将每个函数分类为内存分配器、释放器或两者都不是,生成记录哪个参数或返回值携带内存所有权的函数摘要,从而将分析器的内置知识扩展到标准原语(如 malloc 和 free)之外。基于 Z3 的验证步骤对照函数的控制流图检查每个摘要,丢弃那些声称的内存操作在任何可行路径上都不可达的摘要。已验证的摘要通过各自的扩展机制注入到 CodeQL 和 Infer 中。然后,Z3 路径可行性过滤消除了不可行路径上的告警,最后一步基于 LLM 的验证确认每个剩余告警是否为真正的缺陷。在八个现实世界 C/C++ 项目(总计超过 360 万行代码)上,MemHint 检测出 54 个独特的内存泄漏(53 个已确认/修复),每个检测到的缺陷成本约为 1.7 美元,而未修改的 CodeQL 和 Infer 分别只能检测出 19 个和 3 个。

0
下载
关闭预览

相关内容

《基于动态图神经网络的恶意软件检测》
专知会员服务
16+阅读 · 1月28日
《利用 ChatGPT 实现高效事实核查》
专知会员服务
48+阅读 · 2023年10月25日
KnowledGPT:基于知识库的检索和存储访问增强大型语言模型
《分布式多智能体强化学习的编码》加州大学等
专知会员服务
56+阅读 · 2022年11月2日
Xsser 一款自动检测XSS漏洞工具
黑白之道
14+阅读 · 2019年8月26日
深度学习中Attention Mechanism详细介绍:原理、分类及应用
深度学习与NLP
10+阅读 · 2019年2月18日
NLP-Progress记录NLP最新数据集、论文和代码: 助你紧跟NLP前沿
中国人工智能学会
12+阅读 · 2018年11月15日
国家自然科学基金
6+阅读 · 2017年12月31日
国家自然科学基金
0+阅读 · 2015年12月31日
国家自然科学基金
0+阅读 · 2015年12月31日
国家自然科学基金
0+阅读 · 2015年12月31日
国家自然科学基金
0+阅读 · 2015年12月31日
国家自然科学基金
0+阅读 · 2015年12月31日
国家自然科学基金
1+阅读 · 2014年12月31日
国家自然科学基金
0+阅读 · 2014年12月31日
VIP会员
最新内容
从燃煤战舰到算法战争:水面指挥的永恒要求
专知会员服务
0+阅读 · 21分钟前
《通过小型无人机系统将情报能力“作战化”》
消耗优势:美军的“精确规模化”概念
专知会员服务
8+阅读 · 6月15日
相关VIP内容
《基于动态图神经网络的恶意软件检测》
专知会员服务
16+阅读 · 1月28日
《利用 ChatGPT 实现高效事实核查》
专知会员服务
48+阅读 · 2023年10月25日
KnowledGPT:基于知识库的检索和存储访问增强大型语言模型
《分布式多智能体强化学习的编码》加州大学等
专知会员服务
56+阅读 · 2022年11月2日
相关基金
国家自然科学基金
6+阅读 · 2017年12月31日
国家自然科学基金
0+阅读 · 2015年12月31日
国家自然科学基金
0+阅读 · 2015年12月31日
国家自然科学基金
0+阅读 · 2015年12月31日
国家自然科学基金
0+阅读 · 2015年12月31日
国家自然科学基金
0+阅读 · 2015年12月31日
国家自然科学基金
1+阅读 · 2014年12月31日
国家自然科学基金
0+阅读 · 2014年12月31日
Top
微信扫码咨询专知VIP会员