Stack Overflow Detection Using Dedicated Registers

Resolve Bottlenecks,
Find Innovative Solutions
Generate Solutions

Solution Overview

Problem

Existing methods for detecting stack overflows are either costly in terms of execution time, require complex hardware, or fail to provide complete protection against overflow errors, especially in programming environments like ADA where stack sizing is challenging.

Innovation Solution

A method using dedicated registers to store and compare stack pointer values, generating an exception when the stack pointer exceeds or falls below permitted limits, implemented in both hardware and software to detect overflows promptly and assist in stack sizing.

Engineering Contradictions & Design Principles

VSEngineering Contradiction Analysis

1Reliability

If MMU is used to create guard space around stack memory, then stack overflow protection is provided, but hardware complexity and programming constraints increase

Engineering Contradiction:
Improvestack overflow protectionVSAvoidhardware complexity
Core Design Contradiction:
ReliabilityVSDevice complexity

Solution Approach 1:

The patent introduces a dedicated stack pointer register that acts as an intermediary between the stack memory and the comparison logic. This register stores the current stack pointer value and automatically compares it with pre-defined minimum and maximum limits, providing overflow protection without requiring complex MMU hardware. The intermediary register simplifies the hardware architecture while maintaining reliable detection of stack boundary violations.

Inventive Principle:
Principle #24Intermediary (Mediator)

2Reliability

If stack overflow detection is performed after function prologue, then complete protection against overflow risks is achieved, but execution time increases

Engineering Contradiction:
Improveoverflow protection completenessVSAvoidexecution time
Core Design Contradiction:
ReliabilityVSLoss of time

Solution Approach 1:

The patent implements continuous stack overflow detection by comparing the stack pointer value with predefined limits after every stack operation. Rather than performing detection only at specific checkpoints (such as after function prologue), the comparison mechanism operates continuously, ensuring that overflow conditions are detected immediately when they occur. This eliminates the need for costly periodic checks while maintaining complete protection coverage throughout program execution.

Inventive Principle:
Principle #20Continuity of useful action

3Speed

If dedicated registers are used to store and compare stack pointer values, then detection speed increases, but device complexity increases

Engineering Contradiction:
Improvedetection speedVSAvoiddevice complexity
Core Design Contradiction:
SpeedVSDevice complexity

Solution Approach 1:

The patent designs the dedicated stack pointer register to serve multiple functions: it stores the current stack pointer value, enables comparison with minimum and maximum limits, and generates overflow detection signals. By making this register multi-functional, the patent achieves fast detection speed without proportionally increasing device complexity. The same hardware structure supports both normal stack operations and overflow detection, maximizing resource utilization while minimizing additional hardware requirements.

Inventive Principle:
Principle #6Universality (Multi-functionality)

Data Source

PatentUS9513911B2Method of detecting stack overflows and processor for implementing such a method
Publication Date: 2016.12.06 THALES SA
  • US9513911B2 patent drawing
  • US9513911B2 patent drawing
  • US9513911B2 patent drawing

AI summary

A method of detecting stack overflows includes the following steps: storing in at least one dedicated register at least one data item chosen from: a data item (SPHaut) indicating a maximum permitted value for a stack pointer, and a data item (SPBas) indicating a minimum permitted value for said stack pointer; effecting a comparison between a current value (SP) or past value (SPMin, SPMax) of said stack pointer and said data item or each of said data items; and generating a stack overflow exception if said comparison indicates that said current or past value of said stack pointer is greater than said maximum permitted value or less than said minimum permitted value. A processor for implementing such a method is also provided.