Embedded Stack Overflow Prevention via Pre-calculated Usage Limits

Resolve Bottlenecks,
Find Innovative Solutions
Generate Solutions

Solution Overview

Problem

Embedded systems face challenges in preventing stack overflow due to limited memory resources and dynamic changes in system components, where existing techniques either require offline analysis or incur run-time overhead.

Innovation Solution

A method that reads the maximum stack usage of functions from a kernel and selectively processes operations based on the available stack size, preventing additional interrupts or device driver calls when stack overflow is imminent, and dynamically allocates or loads threads and device drivers based on calculated stack requirements.

Engineering Contradictions & Design Principles

VSEngineering Contradiction Analysis

1Reliability

If static analysis technique is used to predict stack usage offline, then run-time overhead is eliminated, but the technique cannot be applied to systems with dynamically changed components

Engineering Contradiction:
Improvestack overflow preventionVSAvoidapplicability to dynamic systems
Core Design Contradiction:
ReliabilityVSAdaptability or versatility

Solution Approach 1:

The patent pre-calculates and stores maximum stack usage values for all functions in a lookup table during system initialization or compilation. This preliminary action allows the system to quickly retrieve pre-computed stack requirements without performing complex analysis at runtime, enabling both efficient stack management and adaptability to dynamic component changes.

Inventive Principle:
Principle #10Preliminary action

Solution Approach 2:

The patent implements dynamic stack usage tracking by maintaining a stack usage counter that is updated whenever functions are called or return. This dynamic approach allows the system to adapt to changing execution patterns and component states while still preventing stack overflow through real-time monitoring against pre-determined limits.

Inventive Principle:
Principle #15Dynamics

2Reliability

If run-time check technique is used to continuously check stack overflow, then stack overflow can be prevented in dynamic systems, but run-time overhead occurs

Engineering Contradiction:
Improvestack overflow preventionVSAvoidrun-time overhead
Core Design Contradiction:
ReliabilityVSLoss of time

Solution Approach 1:

The patent performs stack usage analysis and determines maximum stack requirements during compilation or initialization, storing these values in advance. This preliminary computation eliminates the need for complex runtime analysis, reducing runtime overhead to simple counter updates and comparisons while maintaining reliable stack overflow prevention.

Inventive Principle:
Principle #10Preliminary action

Solution Approach 2:

The patent uses a simple stack usage counter that can be quickly incremented and decremented, rather than maintaining complex data structures or performing expensive analysis at runtime. This lightweight approach provides continuous monitoring with minimal performance impact.

Inventive Principle:
Principle #27Cheap short-living objects (Disposable)

3Reliability

If predetermined stack allocation is used without dynamic adjustment, then stack overflow is prevented, but memory resources are not efficiently utilized

Engineering Contradiction:
Improvestack overflow preventionVSAvoidmemory resource efficiency
Core Design Contradiction:
ReliabilityVSQuantity of substance

Solution Approach 1:

The patent implements dynamic stack allocation by adjusting the stack usage counter based on actual function calls and returns. The system allocates stack memory dynamically according to real-time needs while ensuring the total usage never exceeds pre-determined safe limits, thus preventing overflow while maximizing memory utilization efficiency.

Inventive Principle:
Principle #15Dynamics

Solution Approach 2:

The patent changes the stack allocation parameters dynamically by modifying the usable stack size based on current system state and pre-calculated requirements. This allows the system to adapt stack allocation to actual needs while maintaining safety margins, optimizing both reliability and resource efficiency.

Inventive Principle:
Principle #35Parameter changes

Data Source

PatentUS9280500B2Method and apparatus for preventing stack overflow in embedded system
Publication Date: 2016.03.08 SAMSUNG ELECTRONICS CO LTD
  • US9280500B2 patent drawing
  • US9280500B2 patent drawing
  • US9280500B2 patent drawing

AI summary

Provided is a method and apparatus for preventing a stack overflow in an embedded system. The method of preventing a stack overflow includes: reading a maximum stack usage of at least one function for executing a requested operation from maximum stack usages of functions provided from a kernel, which are stored in advance; and processing the requested operation on the basis of the read maximum stack usage of the at least one function and a size of a usable region in a stack for the requested operation. Accordingly, the stack overflow can be prevented without generating a run-time overhead.