| 7352 | __attribute__((optimize("-O0"))) |
| 7353 | #endif |
| 7354 | check_stack_overrun(THD *thd, long margin, uchar *buf __attribute__((unused))) |
| 7355 | { |
| 7356 | #ifndef __SANITIZE_ADDRESS__ |
| 7357 | long stack_used; |
| 7358 | DBUG_ASSERT(thd == current_thd); |
| 7359 | DBUG_ASSERT(thd->thread_stack); |
| 7360 | if ((stack_used= available_stack_size(thd->thread_stack, |
| 7361 | my_get_stack_pointer(&stack_used))) >= |
| 7362 | (long) (my_thread_stack_size - margin)) |
| 7363 | { |
| 7364 | thd->is_fatal_error= 1; |
| 7365 | /* |
| 7366 | Do not use stack for the message buffer to ensure correct |
| 7367 | behaviour in cases we have close to no stack left. |
| 7368 | */ |
| 7369 | char* ebuff= new char[MYSQL_ERRMSG_SIZE]; |
| 7370 | if (ebuff) { |
| 7371 | my_snprintf(ebuff, MYSQL_ERRMSG_SIZE, ER_THD(thd, ER_STACK_OVERRUN_NEED_MORE), |
| 7372 | stack_used, my_thread_stack_size, margin); |
| 7373 | my_message(ER_STACK_OVERRUN_NEED_MORE, ebuff, MYF(ME_FATAL)); |
| 7374 | delete [] ebuff; |
| 7375 | } |
| 7376 | return 1; |
| 7377 | } |
| 7378 | #ifndef DBUG_OFF |
| 7379 | max_stack_used= MY_MAX(max_stack_used, stack_used); |
| 7380 | #endif |
| 7381 | #endif /* __SANITIZE_ADDRESS__ */ |
| 7382 | return 0; |
| 7383 | } |
| 7384 | |
| 7385 | |
| 7386 | #define MY_YACC_INIT 1000 // Start with big alloc |