Parallel Runtime Inline Counter for Stack Overflow Prevention

Resolve Bottlenecks,
Find Innovative Solutions
Generate Solutions

Solution Overview

Problem

In computer systems that enable concurrent execution of processes, detecting and preventing stack overflows becomes complex, particularly due to the increased risk of stack overflow and performance impact, as the system struggles to manage memory effectively during inline task execution.

Innovation Solution

A parallel execution runtime environment maintains an inline counter for each thread to prevent stack overflow by checking the stack pointer and memory boundaries, ensuring that tasks are executed inline only if there is no risk of overflow, and executing tasks on a different thread if the risk remains.

Engineering Contradictions & Design Principles

VSEngineering Contradiction Analysis

1Productivity

If concurrent execution of tasks is enabled, then productivity is improved, but stack overflow risk increases

Engineering Contradiction:
Improveconcurrent execution capabilityVSAvoidstack overflow risk
Core Design Contradiction:
ProductivityVSReliability

Solution Approach 1:

The runtime performs preliminary actions by maintaining an inline counter for each thread that tracks the depth of nested inline task executions. Before allowing a task to execute inline, the runtime checks whether the current inline depth exceeds a predetermined threshold, and if so, performs additional stack pointer checks. This preliminary monitoring and threshold comparison prevents stack overflow before it occurs, enabling concurrent execution while maintaining reliability.

Inventive Principle:
Principle #10Preliminary action

2Productivity

If inline task execution is performed, then productivity is improved, but detection complexity of stack overflow increases

Engineering Contradiction:
Improvetask execution efficiencyVSAvoidstack overflow detection complexity
Core Design Contradiction:
ProductivityVSDifficulty of detecting and measuring

Solution Approach 1:

The runtime introduces an intermediary mechanism in the form of an inline counter for each thread, which serves as a mediator between the concurrent task execution and the stack overflow detection. This counter simplifies the detection process by providing a straightforward threshold-based check (comparing inline depth against a predetermined threshold) rather than complex real-time stack analysis. The intermediary counter makes stack overflow detection manageable even during concurrent execution.

Inventive Principle:
Principle #24Intermediary (Mediator)

Solution Approach 2:

The runtime implements feedback by continuously monitoring the inline counter for each thread and using this information to determine whether additional stack pointer checks are necessary. When the inline counter reaches or exceeds the predetermined threshold, the feedback mechanism triggers enhanced detection procedures. This feedback loop enables the system to adapt its detection complexity dynamically, maintaining high productivity while managing detection complexity through intelligent threshold-based decisions.

Inventive Principle:
Principle #23Feedback

3Reliability

If stack overflow prevention checks are performed, then reliability is improved, but performance impact increases

Engineering Contradiction:
Improvestack overflow preventionVSAvoidexecution performance
Core Design Contradiction:
ReliabilityVSProductivity

Solution Approach 1:

The runtime applies partial action by performing stack overflow prevention checks selectively rather than continuously. It uses a two-stage approach: first checking the inline counter against a predetermined threshold (which is a lightweight operation), and only if the threshold is exceeded does it proceed to more expensive stack pointer and memory boundary checks. This partial action strategy maintains reliability by providing comprehensive protection when needed while minimizing performance impact by avoiding unnecessary checks during normal operation.

Inventive Principle:
Principle #16Partial or excessive action

Data Source

PatentUS9928105B2Stack overflow prevention in parallel execution runtime
Publication Date: 2018.03.27 MICROSOFT TECHNOLOGY LICENSING LLC
  • US9928105B2 patent drawing
  • US9928105B2 patent drawing
  • US9928105B2 patent drawing

AI summary

A parallel execution runtime prevents stack overflow by maintaining an inline counter for each thread executing tasks of a process. Each time that the runtime determines that inline execution of a task is desired on a thread, the runtime determines whether the inline counter for the corresponding thread indicates that stack overflow may occur. If not, the runtime increments the inline counter for the thread and allows the task to be executed inline. If the inline counter indicates a risk of stack overflow, then the runtime performs additional one or more checks using a previous stack pointer of the stack (i.e., a lowest known safe watermark), the current stack pointer, and memory boundaries of the stack. If the risk of stack overflow remains after all checks have been performed, the runtime prevents inline execution of the task.