Registered user since Thu 10 Mar 2022
Contributions
View general profile
Registered user since Thu 10 Mar 2022
Contributions
Developers use exceptions guarded by conditions to abort the execution when a program reaches an unexpected state. However, sometimes the condition and the raised exception do not imply the same stopping reason, in which case, we call them inconsistent if-condition-raise statements. The inconsistency can originate from a mistake in the condition or the message of the exception. This paper presents IICR-Finder, a deep learning-based approach to detect inconsistent if-condition-raise statements. The approach reasons both about the logic of the condition and the natural language of the exception message and raises a warning in case of an inconsistency. We present six techniques to automatically generate large numbers of inconsistent statements for training. Moreover, we implement two neural models, based on binary classification and triplet loss, to learn inconsistency detection. We apply the approach to 210K if-condition-raise statements extracted from 42 million lines of Python code. It achieves a precision of 72% at a recall of 60% on a dataset of past bug fixes. Running IICR-Finder on open-source projects reveals 30 previously unknown bugs, ten of which we reported, with eight confirmed by the developers.