Machine Learning Runtime Error Detection in Source Code

Resolve Bottlenecks,
Find Innovative Solutions
Generate 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

VSEngineering Contradiction Analysis

1Measurement precision

If machine learning models are used to detect runtime errors, then detection capability is improved, but device complexity increases

Engineering Contradiction:
Improvedetection capabilityVSAvoidmodel complexity
Core Design Contradiction:
Measurement precisionVSDevice complexity

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.

Inventive Principle:
Principle #1Segmentation

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.

Inventive Principle:
Principle #24Intermediary (Mediator)

2Measurement precision

If comprehensive code analysis is performed to detect all runtime errors, then detection accuracy is improved, but processing time increases

Engineering Contradiction:
Improvedetection accuracyVSAvoidprocessing time
Core Design Contradiction:
Measurement precisionVSLoss of time

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.

Inventive Principle:
Principle #16Partial or excessive action

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.

Inventive Principle:
Principle #10Preliminary action

Data Source

PatentEP4111302B1Detection of runtime errors using machine learning
Publication Date: 2024.12.04 MICROSOFT TECHNOLOGY LICENSING LLC
  • EP4111302B1 patent drawingFigure 1A~1B
  • EP4111302B1 patent drawingFigure 2
  • EP4111302B1 patent drawingFigure 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.