diff options
author | Nirbhay Choubey <nirbhay@mariadb.com> | 2016-08-24 19:30:32 -0400 |
---|---|---|
committer | Nirbhay Choubey <nirbhay@mariadb.com> | 2016-08-24 19:30:32 -0400 |
commit | c309e99ff9b48c1736ff468e72153048c4b56561 (patch) | |
tree | 1fb9e8831597007bcfa9e7ea2b2aadb717b962cd /mysys | |
parent | 8b09db8bfb81f1e7695cfcfa6ce2bec45247171f (diff) | |
parent | 5bbe929d706e26cb3f9b291da6009526a17b1545 (diff) | |
download | mariadb-git-c309e99ff9b48c1736ff468e72153048c4b56561.tar.gz |
Merge branch '10.0' into 10.0-galera
Diffstat (limited to 'mysys')
-rw-r--r-- | mysys/my_context.c | 17 | ||||
-rw-r--r-- | mysys/my_error.c | 2 | ||||
-rw-r--r-- | mysys/stacktrace.c | 30 |
3 files changed, 34 insertions, 15 deletions
diff --git a/mysys/my_context.c b/mysys/my_context.c index e4ca4143baf..017cebdc110 100644 --- a/mysys/my_context.c +++ b/mysys/my_context.c @@ -696,30 +696,27 @@ my_context_destroy(struct my_context *c) int my_context_spawn(struct my_context *c, void (*f)(void *), void *d) { - void *current_fiber; c->user_func= f; c->user_arg= d; + return my_context_continue(c); +} + +int +my_context_continue(struct my_context *c) +{ /* This seems to be a common trick to run ConvertThreadToFiber() only on the first occurence in a thread, in a way that works on multiple Windows versions. */ - current_fiber= GetCurrentFiber(); + void *current_fiber= GetCurrentFiber(); if (current_fiber == NULL || current_fiber == (void *)0x1e00) current_fiber= ConvertThreadToFiber(c); c->app_fiber= current_fiber; DBUG_SWAP_CODE_STATE(&c->dbug_state); SwitchToFiber(c->lib_fiber); DBUG_SWAP_CODE_STATE(&c->dbug_state); - return c->return_value; -} -int -my_context_continue(struct my_context *c) -{ - DBUG_SWAP_CODE_STATE(&c->dbug_state); - SwitchToFiber(c->lib_fiber); - DBUG_SWAP_CODE_STATE(&c->dbug_state); return c->return_value; } diff --git a/mysys/my_error.c b/mysys/my_error.c index 5d16091e0be..44d112bc049 100644 --- a/mysys/my_error.c +++ b/mysys/my_error.c @@ -217,7 +217,7 @@ void my_message(uint error, const char *str, register myf MyFlags) @retval != 0 Error */ -int my_error_register(const char** (*get_errmsgs) (), uint first, uint last) +int my_error_register(const char** (*get_errmsgs) (void), uint first, uint last) { struct my_err_head *meh_p; struct my_err_head **search_meh_pp; diff --git a/mysys/stacktrace.c b/mysys/stacktrace.c index 613911e4495..746b99d6112 100644 --- a/mysys/stacktrace.c +++ b/mysys/stacktrace.c @@ -129,13 +129,32 @@ static int safe_print_str(const char *addr, int max_len) #endif -void my_safe_print_str(const char* val, int max_len) +/* + Attempt to print a char * pointer as a string. + + SYNOPSIS + Prints either until the end of string ('\0'), or max_len characters have + been printed. + + RETURN VALUE + 0 Pointer was within the heap address space. + The string was printed fully, or until the end of the heap address space. + 1 Pointer is outside the heap address space. Printed as invalid. + + NOTE + On some systems, we can have valid pointers outside the heap address space. + This is through the use of mmap inside malloc calls. When this function + returns 1, it does not mean 100% that the pointer is corrupted. +*/ + +int my_safe_print_str(const char* val, int max_len) { char *heap_end; #ifdef __linux__ + // Try and make use of /proc filesystem to safely print memory contents. if (!safe_print_str(val, max_len)) - return; + return 0; #endif heap_end= (char*) sbrk(0); @@ -143,12 +162,14 @@ void my_safe_print_str(const char* val, int max_len) if (!PTR_SANE(val)) { my_safe_printf_stderr("%s", "is an invalid pointer"); - return; + return 1; } for (; max_len && PTR_SANE(val) && *val; --max_len) my_write_stderr((val++), 1); my_safe_printf_stderr("%s", "\n"); + + return 0; } #if defined(HAVE_PRINTSTACK) @@ -728,7 +749,7 @@ void my_write_core(int unused) } -void my_safe_print_str(const char *val, int len) +int my_safe_print_str(const char *val, int len) { __try { @@ -738,6 +759,7 @@ void my_safe_print_str(const char *val, int len) { my_safe_printf_stderr("%s", "is an invalid string pointer"); } + return 0; } #endif /*__WIN__*/ |