![]() |
MySQL 26.10.0
Source Code Documentation
|
#include "sql/check_stack.h"#include "my_config.h"#include <assert.h>#include <stdio.h>#include <algorithm>#include <atomic>#include <new>#include "my_compiler.h"#include "my_dbug.h"#include "my_inttypes.h"#include "my_sys.h"#include "mysql_com.h"#include "mysqld_error.h"#include "sql/current_thd.h"#include "sql/derror.h"#include "sql/sql_class.h"Namespaces | |
| namespace | anonymous_namespace{check_stack.cc} |
Functions | |
| static NO_INLINE int | stack_direction_f (const char *a) |
| Determine whether the stack grows upward or downward. More... | |
| NO_INLINE int | initialize_stack_direction () |
| long | anonymous_namespace{check_stack.cc}::used_stack (const char *a_ptr, const char *b_ptr) |
| bool | check_stack_overrun (const THD *thd, long margin, unsigned char *buf) |
| Check stack for a overrun. More... | |
Variables | |
| int | anonymous_namespace{check_stack.cc}::stack_direction = 0 |
| static int(* | ptr_f )(const char *) = stack_direction_f |
| static std::atomic< long > | max_stack_used |
| bool check_stack_overrun | ( | const THD * | thd, |
| long | margin, | ||
| unsigned char * | buf | ||
| ) |
Check stack for a overrun.
| thd | Thread handler. |
| margin | Minimal acceptable unused space in the stack. |
| buf | See a note below. |
| NO_INLINE int initialize_stack_direction | ( | ) |
|
static |
Determine whether the stack grows upward or downward.
The function is deliberately not inlined, so a belongs to its caller's frame while b_marker belongs to this frame. In ordinary builds, resolve_stack_pointer() returns those local markers unchanged and their relative addresses reveal the stack-growth direction.
In ASan builds, local variables may be allocated on ASan's fake stack. resolve_stack_pointer() therefore replaces both markers with physical frame addresses before comparing them. This keeps stack-direction detection in the same address space as later stack-overrun checks.
| a | Stack marker from initialize_stack_direction(). |
|
static |
|
static |