ESBMC
Efficient SMT-based Context-Bounded Model Checker
Loading...
Searching...
No Matches
stack_budget_guardt< Tag > Class Template Reference

Bound the stack a recursive tree walk may consume, so a pathologically deep expression or type yields a diagnostic instead of SIGSEGV (esbmc/esbmc#5048). More...

#include <stack_budget.h>

Public Member Functions

 stack_budget_guardt ()
 ~stack_budget_guardt ()
 stack_budget_guardt (const stack_budget_guardt &)=delete
stack_budget_guardt & operator= (const stack_budget_guardt &)=delete
std::ptrdiff_t bytes_used () const
 Stack consumed since the outermost level.
bool exceeded (std::ptrdiff_t budget) const

Detailed Description

template<class Tag>
class stack_budget_guardt< Tag >

Bound the stack a recursive tree walk may consume, so a pathologically deep expression or type yields a diagnostic instead of SIGSEGV (esbmc/esbmc#5048).

Counts bytes, not frames: a frame count tuned on one build is wrong on another – a Debug frame is several times an optimised one – whereas a byte budget holds whatever the frame costs.

Declare one instance at the top of the recursive function, then ask exceeded(). Reporting is left to the caller so the accounting can be exercised by a test without taking the process down with it.

Tag gives each walk its own base pointer and depth, so nested walks of different kinds do not measure each other. State is thread-local: several threads may be walking at once, on stacks that are nowhere near each other.

Constructor & Destructor Documentation

◆ stack_budget_guardt() [1/2]

template<class Tag>
stack_budget_guardt< Tag >::stack_budget_guardt ( )
inline

◆ ~stack_budget_guardt()

template<class Tag>
stack_budget_guardt< Tag >::~stack_budget_guardt ( )
inline

◆ stack_budget_guardt() [2/2]

template<class Tag>
stack_budget_guardt< Tag >::stack_budget_guardt ( const stack_budget_guardt< Tag > & )
delete

Member Function Documentation

◆ bytes_used()

template<class Tag>
std::ptrdiff_t stack_budget_guardt< Tag >::bytes_used ( ) const
inline

Stack consumed since the outermost level.

Zero at that level itself.

◆ exceeded()

template<class Tag>
bool stack_budget_guardt< Tag >::exceeded ( std::ptrdiff_t budget) const
inline

◆ operator=()

template<class Tag>
stack_budget_guardt & stack_budget_guardt< Tag >::operator= ( const stack_budget_guardt< Tag > & )
delete

The documentation for this class was generated from the following file: