Page 165 - 《软件学报》2026年第7期
P. 165

2850                                                       软件学报  2026  年第  37  卷第  7  期


                 excessive  mutation  cost,  and  large  information  scale.  To  this  end,  EXPECT,  a  fault  localization  technique  based  on  exception  trigger
                 information,  has  been  proposed  recently  to  monitor  the  execution  state  of  program  failure  via  the  program’s  built-in  exception  handling
                 statements  (Try-catch  blocks),  achieving  fault  localization  effectiveness  that  surpasses  the  aforementioned  mainstream  techniques  at  a  lower
                 cost.  The  premise  of  EXPECT  is  that  the  faulty  program  must  contain  enough  exception  handling  statements.  However,  in  the  real  open-
                 source  environments,  many  software  programs  do  not  have  a  good  exception  handling  mechanism,  which  causes  their  codes  to  contain
                 only  very  sparse  or  even  no  exception  handling  statements,  thus  directly  affecting  the  basis  on  which  EXPECT  runs.  To  this  end,  a
                 software  fault  localization  method  based  on  exception  checkpoint  injection,  INSPECT  (inserted  checkpoint-based  fault  localization),  is
                 proposed.  By  automatically  injecting  temporary  exception  handling  statements  into  the  faulty  program  as  checkpoints  for  the  internal  state
                 during  running,  and  designing  a  more  sophisticated  method  for  program  statements’  risk  value  calculation,  the  application  scope  of
                 EXPECT  is  extended  to  more  general  programs  that  do  not  contain  exception  handling  statements.  The  application  scenario  of  exception
                 trigger  information  as  an  efficient  source  of  data  for  fault  localization  is  extended  to  achieve  generalization  improvement.  Experimental
                 results  show  that  INSPECT  obtains  better  fault  localization  effectiveness  than  the  current  state-of-the-art  technique  with  improvements  of
                 95.25%, 55.92%, and 16.65% (simulated faults) as well as 93.39%, 57.54%, and 13.92% (real-world faults) in the best, average, and worst
                 EXAM metrics respectively, and 311.47% (simulated faults) and 283.31% (real-world faults) in the MRR metric.
                 Key words:  software fault localization; exception handling mechanism; checkpoint injection; software quality assurance
                    软件作为一种人类制品, 不可避免地会含有缺陷, 在软件系统越来越多地作为基础设施融入社会发展各个领
                 域的背景下, 软件缺陷造成的危害往往十分严重. 例如, 网络安全公司                   CrowdStrike 于  2024  年  7  月发布的一次软件
                                                                                                       [1]
                 更新存在缺陷, 导致全球范围内         Windows 系统出现中断, 银行、机场、医院等大量要害部门的业务因此受到影响 .
                 此外, 权威机构    Synopsys 所发布的一份报告显示, 2022      年全年美国经济因软件质量问题损失了至少                2.41  万亿美
                 元, 超过了全球    170  个国家的  GDP, 而这一数字在     2020  年还是  1.31  万亿美元  [2] . 当软件发生故障时, 对导致故障
                 的底层代码缺陷根因进行及时、准确地定位, 对于后续对其进一步处理十分重要                          [3−5] .
                    近几十年来, 软件缺陷定位技术作为软件质量保障特别是软件调试任务中的重要一环, 受到了国内外学者的
                 广泛关注   [6−10] . 软件缺陷定位的基本流程是, 以软件系统表层的执行失效 (症状) 为入口, 通过深入分析程序运行时
                 的内部状态, 找到应该为表层失效负责的底层代码级缺陷根因 (症结). 当前, 基于频谱的缺陷定位 (spectrum-based
                 fault localization, SBFL) 和基于突变的缺陷定位 (mutation-based fault localization, MBFL) 是两种最为主流的技术.
                 SBFL  首先根据测试用例实际输出与预期输出是否相符, 将所有测试用例分为通过和失败两种, 然后记录测试用
                 例执行过程中对程序的覆盖信息, 为那些被更多失败测试用例、更少通过测试用例覆盖的程序实体 (文件、函数、
                 语句等) 赋予更高的含缺陷风险值          [11−13] ; MBFL  对程序语句进行随机突变, 并比对突变前后的测试结果, 认为在含
                 有缺陷的语句上进行突变更可能使失败测试用例变为通过, 为那些被更多从失败转为通过测试用例覆盖的突变语
                 句赋予更高的风险值       [14−16] . 近年来, 一项基于程序语义的缺陷定位技术         SmartFL  被提出  [17] , 其核心是对程序语义
                 信息、静态分析信息与动态执行跟踪信息进行综合建模, 已被证实为当前最先进的缺陷定位技术. 尽管                                  SBFL  和
                 MBFL  技术已被证实取得了良好的缺陷定位效果, 它们均将覆盖信息作为对程序内部状态进行分析的源数据, 具
                 有信息过于宽泛、针对性不强的弱点. 此外, 这两项技术还具有各自分别的短板. 具体而言, SBFL                           技术仅依靠覆
                 盖信息对程序实体进行表达, 使得真正含有缺陷的程序实体和与其具有相同覆盖信息的其他程序实体将被赋予同
                 样的风险值 (即风险值捆绑问题, 亦称为           Tie 问题). 该问题十分常见, 已被先前许多研究指出在很大程度上威胁着
                 SBFL  技术的有效性    [18−20] . MBFL  技术通过突变对程序源码进行修改, 在修改后需要重复进行编译和测试执行过
                 程, 具有很高的时间和计算成本. 而当大量程序语句均被覆盖时, SmartFL                  仍可能面临语义信息规模过大的问题.
                                                                       [21]
                 为解决上述挑战, 前期提出了基于异常触发流的缺陷定位技术                   EXPECT , 将程序中自带的异常处理语句           (Try-catch
                 块) 作为监测程序运行内部状态的“检查点”, 分别在失败执行和通过执行下记录                         Try-catch  块上的异常触发情况,
                 将该对信息中暴露出分歧         (如其中一次执行在该检查点捕获异常而另一次未捕获) 的首个检查点作为“分歧点”, 为
                 分歧点和其前序最近一个检查点之间的程序语句进行风险值投票, 最终定位到缺陷语句.
                    尽管  EXPECT  方法的缺陷定位有效性大幅超过了现有最优缺陷定位技术                    SmartFL, 其高度依赖于错误程序自
                 身所带的异常处理语句. 然而, 在真实的开源环境中, 大量软件程序因为工期紧张、仅重视功能实现等原因, 并没
   160   161   162   163   164   165   166   167   168   169   170