On Distribution Shift in Learning-based Bug Detectors

04/21/2022
by   Jingxuan He, et al.
0

Deep learning has recently achieved initial success in program analysis tasks such as bug detection. Lacking real bugs, most existing works construct training and test data by injecting synthetic bugs into correct programs. Despite achieving high test accuracy (e.g., 90 are found to be surprisingly unusable in practice, i.e., <10 used to scan real software repositories. In this work, we argue that this massive performance difference is caused by a distribution shift, i.e., a fundamental mismatch between the real bug distribution and the synthetic bug distribution used to train and evaluate the detectors. To address this key challenge, we propose to train a bug detector in two phases, first on a synthetic bug distribution to adapt the model to the bug detection domain, and then on a real bug distribution to drive the model towards the real distribution. During these two phases, we leverage a multi-task hierarchy, focal loss, and contrastive learning to further boost performance. We evaluate our approach extensively on three widely studied bug types, for which we construct new datasets carefully designed to capture the real bug distribution. The results demonstrate that our approach is practically effective and successfully mitigates the distribution shift: our learned detectors are highly performant on both our test set and the latest version of open source repositories. Our code, datasets, and models are publicly available at https://github.com/eth-sri/learning-real-bug-detector.

READ FULL TEXT

page 1

page 2

page 3

page 4

research
09/18/2022

Infrared: A Meta Bug Detector

The recent breakthroughs in deep learning methods have sparked a wave of...
research
04/30/2018

DeepBugs: A Learning Approach to Name-based Bug Detection

Natural language elements in source code, e.g., the names of variables a...
research
06/01/2019

Neural Bug Finding: A Study of Opportunities and Challenges

Static analysis is one of the most widely adopted techniques to find sof...
research
05/27/2023

WELL: Applying Bug Detectors to Bug Localization via Weakly Supervised Learning

Bug localization, which is used to help programmers identify the locatio...
research
07/14/2021

DeepMutants: Training neural bug detectors with contextual mutations

Learning-based bug detectors promise to find bugs in large code bases by...
research
09/12/2023

PreciseBugCollector: Extensible, Executable and Precise Bug-fix Collection

Bug datasets are vital for enabling deep learning techniques to address ...
research
05/18/2020

Learning Semantic Program Embeddings with Graph Interval Neural Network

Learning distributed representations of source code has been a challengi...

Please sign up or login with your details

Forgot password? Click here to reset