summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Black <daniel@mariadb.org>2020-11-13 12:07:05 +1100
committerDaniel Black <daniel@mariadb.org>2020-11-13 12:09:07 +1100
commit84c01f1af5c421ca4c4407343e28d5346ceee85d (patch)
tree26b88b9d47e10a0a81b73b048cc59e5844e0058a
parent984a06db2ce2b2e3c7c5028245905417f2141cd7 (diff)
downloadmariadb-git-bb-10.2-danielblack-MDEV-24131-fix-stacktrace-t-for-non-win-non-backtrace-systems.tar.gz
This occurs on non-Windows machines without a backtrace or backtrace_fd function (e.g. OpenBSD). To correct this the my_safe_print_str is moved into a non-Windows section of stacktrace.c rather than being not compiled if HAVE_STACKTRACE wasn't defined.
-rw-r--r--mysys/stacktrace.c86
1 files changed, 43 insertions, 43 deletions
diff --git a/mysys/stacktrace.c b/mysys/stacktrace.c
index 86cf272a437..5f2c5901fc6 100644
--- a/mysys/stacktrace.c
+++ b/mysys/stacktrace.c
@@ -34,49 +34,6 @@
#include <execinfo.h>
#endif
-/*
- Attempt to print a char * pointer as a string.
-
- SYNOPSIS
- Prints until 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)
-{
- const char *orig_val= val;
- if (!val)
- {
- my_safe_printf_stderr("%s", "(null)");
- return 1;
- }
-
- for (; max_len; --max_len)
- {
- if (my_write_stderr((val++), 1) != 1)
- {
- if ((errno == EFAULT) &&(val == orig_val + 1))
- {
- // We can not read the address from very beginning
- my_safe_printf_stderr("Can't access address %p", orig_val);
- }
- break;
- }
- }
- my_safe_printf_stderr("%s", "\n");
-
- return 0;
-}
-
#if defined(HAVE_PRINTSTACK)
/* Use Solaris' symbolic stack trace routine. */
@@ -386,6 +343,49 @@ void my_write_core(int sig)
#endif
}
+
+/*
+ Attempt to print a char * pointer as a string.
+
+ SYNOPSIS
+ Prints until 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)
+{
+ const char *orig_val= val;
+ if (!val)
+ {
+ my_safe_printf_stderr("%s", "(null)");
+ return 1;
+ }
+
+ for (; max_len; --max_len)
+ {
+ if (my_write_stderr((val++), 1) != 1)
+ {
+ if ((errno == EFAULT) &&(val == orig_val + 1))
+ {
+ // We can not read the address from very beginning
+ my_safe_printf_stderr("Can't access address %p", orig_val);
+ }
+ break;
+ }
+ }
+ my_safe_printf_stderr("%s", "\n");
+
+ return 0;
+}
#else /* __WIN__*/
#ifdef _MSC_VER