Machine Learning Runtime Error Detection in Source Code
Find Innovative SolutionsGenerate Solutions
Solution Overview
Problem
Runtime errors in software programs, such as conditionally uninitialized variables and arithmetic overflows, are difficult to detect before program execution, leading to potential program failures and security vulnerabilities, especially in languages like C/C++ that do not enforce variable initialization or check for arithmetic overflows, making them hard to notice and fix during testing.
Innovation Solution
The use of machine learning models, specifically random forest classifiers, trained on code snippets with and without runtime errors to predict the probability of these errors by extracting features from syntax-type trees, enabling detection before program execution.
Engineering Contradictions & Design Principles
Engineering Contradiction Analysis
1Measurement precision
If machine learning models are used to detect runtime errors, then detection capability is improved, but device complexity increases
Solution Approach 1:
The patent segments the runtime error detection problem into distinct error types (conditionally uninitialized variable, arithmetic overflow) and creates specialized machine learning models for each type. This segmentation allows each model to focus on specific patterns, improving detection precision while managing complexity through modular design.
Solution Approach 2:
The patent introduces syntax-type trees as an intermediary representation between source code and machine learning models. These trees transform complex code structures into standardized formats with extracted features, serving as a mediator that simplifies the input for ML models and improves detection capability without directly increasing model complexity.
2Measurement precision
If comprehensive code analysis is performed to detect all runtime errors, then detection accuracy is improved, but processing time increases
Solution Approach 1:
The patent applies partial action by focusing analysis on specific high-risk error types rather than attempting to detect all possible runtime errors. By concentrating computational resources on conditionally uninitialized variables and arithmetic overflows through specialized models, the system achieves high detection accuracy for critical errors while limiting processing time.
Solution Approach 2:
The patent performs preliminary analysis by generating syntax-type trees and extracting features before applying machine learning models. This preprocessing step organizes code information in advance, enabling faster and more accurate detection during the actual analysis phase, thus improving accuracy without proportionally increasing total processing time.
Data Source
Figure 1A~1B
Figure 2
Figure 3
AI summary
Runtime errors in a source code program are detected in advance of execution by machine learning models. Features representing a context of a runtime error are extracted from source code programs to train a machine learning model, such as a random forest classifier, to predict the likelihood that a code snippet has a particular type of runtime error. The features are extracted from a syntax-type tree representation of each method in a program. A model is generated for distinct runtime errors, such as arithmetic overflow, and conditionally uninitialized variables.