Commit bfba2bce authored by Marko Mäkelä's avatar Marko Mäkelä

Merge 10.1 into 10.2

parents 309302a3 ece0b062
......@@ -9062,10 +9062,6 @@ static void init_signal_handling(void)
struct sigaction sa;
DBUG_ENTER("init_signal_handling");
#ifdef HAVE_STACKTRACE
my_init_stacktrace();
#endif
sa.sa_flags = SA_RESETHAND | SA_NODEFER;
sigemptyset(&sa.sa_mask);
sigprocmask(SIG_SETMASK, &sa.sa_mask, NULL);
......
......@@ -43,7 +43,6 @@
C_MODE_START
#if defined(HAVE_STACKTRACE) || defined(HAVE_BACKTRACE)
void my_init_stacktrace();
void my_print_stacktrace(uchar* stack_bottom, ulong thread_stack);
int my_safe_print_str(const char* val, int max_len);
void my_write_core(int sig);
......@@ -53,8 +52,6 @@ char *my_demangle(const char *mangled_name, int *status);
#ifdef __WIN__
void my_set_exception_pointers(EXCEPTION_POINTERS *ep);
#endif /* __WIN__ */
#else
#define my_init_stacktrace() do { } while(0)
#endif /* ! (defined(HAVE_STACKTRACE) || defined(HAVE_BACKTRACE)) */
#ifndef _WIN32
......
......@@ -15,6 +15,7 @@ TRUNCATE TABLE time_zone;
TRUNCATE TABLE time_zone_name;
TRUNCATE TABLE time_zone_transition;
TRUNCATE TABLE time_zone_transition_type;
START TRANSACTION;
INSERT INTO time_zone (Use_leap_seconds) VALUES ('N');
SET @time_zone_id= LAST_INSERT_ID();
INSERT INTO time_zone_name (Name, Time_zone_id) VALUES ('GMT', @time_zone_id);
......@@ -32,6 +33,7 @@ INSERT INTO time_zone_transition_type (Time_zone_id, Transition_type_id, Offset,
Warning: Unable to load 'MYSQLTEST_VARDIR/zoneinfo/posix/garbage' as time zone. Skipping it.
Warning: Unable to load 'MYSQLTEST_VARDIR/zoneinfo/posix/ignored.tab' as time zone. Skipping it.
Warning: Skipping directory 'MYSQLTEST_VARDIR/zoneinfo/posix/posix': to avoid infinite symlink recursion.
COMMIT;
ALTER TABLE time_zone_transition ORDER BY Time_zone_id, Transition_time;
ALTER TABLE time_zone_transition_type ORDER BY Time_zone_id, Transition_type_id;
\d |
......@@ -57,6 +59,7 @@ TRUNCATE TABLE time_zone;
TRUNCATE TABLE time_zone_name;
TRUNCATE TABLE time_zone_transition;
TRUNCATE TABLE time_zone_transition_type;
START TRANSACTION;
INSERT INTO time_zone (Use_leap_seconds) VALUES ('N');
SET @time_zone_id= LAST_INSERT_ID();
INSERT INTO time_zone_name (Name, Time_zone_id) VALUES ('GMT', @time_zone_id);
......@@ -71,6 +74,7 @@ INSERT INTO time_zone_transition_type (Time_zone_id, Transition_type_id, Offset,
(@time_zone_id, 0, 0, 0, 'GMT')
;
Warning: Unable to load 'MYSQLTEST_VARDIR/zoneinfo/posix/garbage' as time zone. Skipping it.
COMMIT;
ALTER TABLE time_zone_transition ORDER BY Time_zone_id, Transition_time;
ALTER TABLE time_zone_transition_type ORDER BY Time_zone_id, Transition_type_id;
\d |
......@@ -160,6 +164,8 @@ TRUNCATE TABLE time_zone;
TRUNCATE TABLE time_zone_name;
TRUNCATE TABLE time_zone_transition;
TRUNCATE TABLE time_zone_transition_type;
START TRANSACTION;
COMMIT;
ALTER TABLE time_zone_transition ORDER BY Time_zone_id, Transition_time;
ALTER TABLE time_zone_transition_type ORDER BY Time_zone_id, Transition_type_id;
\d |
......
......@@ -15,6 +15,7 @@ TRUNCATE TABLE time_zone;
TRUNCATE TABLE time_zone_name;
TRUNCATE TABLE time_zone_transition;
TRUNCATE TABLE time_zone_transition_type;
START TRANSACTION;
INSERT INTO time_zone (Use_leap_seconds) VALUES ('N');
SET @time_zone_id= LAST_INSERT_ID();
INSERT INTO time_zone_name (Name, Time_zone_id) VALUES ('GMT', @time_zone_id);
......@@ -32,6 +33,7 @@ INSERT INTO time_zone_transition_type (Time_zone_id, Transition_type_id, Offset,
Warning: Unable to load 'MYSQLTEST_VARDIR/zoneinfo/posix/garbage' as time zone. Skipping it.
Warning: Unable to load 'MYSQLTEST_VARDIR/zoneinfo/posix/ignored.tab' as time zone. Skipping it.
Warning: Skipping directory 'MYSQLTEST_VARDIR/zoneinfo/posix/posix': to avoid infinite symlink recursion.
COMMIT;
ALTER TABLE time_zone_transition ORDER BY Time_zone_id, Transition_time;
ALTER TABLE time_zone_transition_type ORDER BY Time_zone_id, Transition_type_id;
\d |
......@@ -57,6 +59,7 @@ TRUNCATE TABLE time_zone;
TRUNCATE TABLE time_zone_name;
TRUNCATE TABLE time_zone_transition;
TRUNCATE TABLE time_zone_transition_type;
START TRANSACTION;
INSERT INTO time_zone (Use_leap_seconds) VALUES ('N');
SET @time_zone_id= LAST_INSERT_ID();
INSERT INTO time_zone_name (Name, Time_zone_id) VALUES ('GMT', @time_zone_id);
......@@ -71,6 +74,7 @@ INSERT INTO time_zone_transition_type (Time_zone_id, Transition_type_id, Offset,
(@time_zone_id, 0, 0, 0, 'GMT')
;
Warning: Unable to load 'MYSQLTEST_VARDIR/zoneinfo/posix/garbage' as time zone. Skipping it.
COMMIT;
ALTER TABLE time_zone_transition ORDER BY Time_zone_id, Transition_time;
ALTER TABLE time_zone_transition_type ORDER BY Time_zone_id, Transition_type_id;
\d |
......
......@@ -9,6 +9,7 @@ TRUNCATE TABLE time_zone;
TRUNCATE TABLE time_zone_name;
TRUNCATE TABLE time_zone_transition;
TRUNCATE TABLE time_zone_transition_type;
START TRANSACTION;
INSERT INTO time_zone (Use_leap_seconds) VALUES ('N');
SET @time_zone_id= LAST_INSERT_ID();
INSERT INTO time_zone_name (Name, Time_zone_id) VALUES ('GMT', @time_zone_id);
......@@ -26,6 +27,7 @@ INSERT INTO time_zone_transition_type (Time_zone_id, Transition_type_id, Offset,
Warning: Unable to load 'MYSQLTEST_VARDIR/zoneinfo/posix/garbage' as time zone. Skipping it.
Warning: Unable to load 'MYSQLTEST_VARDIR/zoneinfo/posix/ignored.tab' as time zone. Skipping it.
Warning: Skipping directory 'MYSQLTEST_VARDIR/zoneinfo/posix/posix': to avoid infinite symlink recursion.
COMMIT;
ALTER TABLE time_zone_transition ORDER BY Time_zone_id, Transition_time;
ALTER TABLE time_zone_transition_type ORDER BY Time_zone_id, Transition_type_id;
# Silent run
......@@ -36,6 +38,7 @@ TRUNCATE TABLE time_zone;
TRUNCATE TABLE time_zone_name;
TRUNCATE TABLE time_zone_transition;
TRUNCATE TABLE time_zone_transition_type;
START TRANSACTION;
INSERT INTO time_zone (Use_leap_seconds) VALUES ('N');
SET @time_zone_id= LAST_INSERT_ID();
INSERT INTO time_zone_name (Name, Time_zone_id) VALUES ('GMT', @time_zone_id);
......@@ -50,6 +53,7 @@ INSERT INTO time_zone_transition_type (Time_zone_id, Transition_type_id, Offset,
(@time_zone_id, 0, 0, 0, 'GMT')
;
Warning: Unable to load 'MYSQLTEST_VARDIR/zoneinfo/posix/garbage' as time zone. Skipping it.
COMMIT;
ALTER TABLE time_zone_transition ORDER BY Time_zone_id, Transition_time;
ALTER TABLE time_zone_transition_type ORDER BY Time_zone_id, Transition_type_id;
#
......
......@@ -34,108 +34,11 @@
#include <execinfo.h>
#endif
#ifdef __linux__
#define PTR_SANE(p) ((p) && (char*)(p) >= heap_start && (char*)(p) <= heap_end)
static char *heap_start;
char *__bss_start;
#else
#define PTR_SANE(p) (p)
#endif /* __linux */
void my_init_stacktrace()
{
#ifdef __linux__
heap_start = (char*) &__bss_start;
#endif /* __linux */
}
#ifdef __linux__
static void print_buffer(char *buffer, size_t count)
{
const char s[]= " ";
for (; count && *buffer; --count)
{
my_write_stderr(isprint(*buffer) ? buffer : s, 1);
++buffer;
}
}
/**
Access the pages of this process through /proc/self/task/<tid>/mem
in order to safely print the contents of a memory address range.
@param addr The address at the start of the memory region.
@param max_len The length of the memory region.
@return Zero on success.
*/
static int safe_print_str(const char *addr, int max_len)
{
int fd;
pid_t tid;
off_t offset;
ssize_t nbytes= 0;
size_t total, count;
char buf[256];
tid= (pid_t) syscall(SYS_gettid);
sprintf(buf, "/proc/self/task/%d/mem", tid);
if ((fd= open(buf, O_RDONLY)) < 0)
return -1;
/* Ensure that off_t can hold a pointer. */
compile_time_assert(sizeof(off_t) >= sizeof(intptr));
total= max_len;
offset= (intptr) addr;
/* Read up to the maximum number of bytes. */
while (total)
{
count= MY_MIN(sizeof(buf), total);
if ((nbytes= pread(fd, buf, count, offset)) < 0)
{
/* Just in case... */
if (errno == EINTR)
continue;
else
break;
}
/* Advance offset into memory. */
total-= nbytes;
offset+= nbytes;
addr+= nbytes;
/* Output the printable characters. */
print_buffer(buf, nbytes);
/* Break if less than requested... */
if ((count - nbytes))
break;
}
if (nbytes == -1)
my_safe_printf_stderr("Can't read from address %p", addr);
close(fd);
return 0;
}
#endif
/*
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.
Prints until max_len characters have been printed.
RETURN VALUE
0 Pointer was within the heap address space.
......@@ -150,24 +53,25 @@ static int safe_print_str(const char *addr, int max_len)
int my_safe_print_str(const char* val, int max_len)
{
#ifdef __linux__
char *heap_end;
// Try and make use of /proc filesystem to safely print memory contents.
if (!safe_print_str(val, max_len))
return 0;
heap_end= (char*) sbrk(0);
#endif
if (!PTR_SANE(val))
const char *orig_val= val;
if (!val)
{
my_safe_printf_stderr("%s", "is an invalid pointer");
my_safe_printf_stderr("%s", "(null)");
return 1;
}
for (; max_len && PTR_SANE(val) && *val; --max_len)
my_write_stderr((val++), 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;
......@@ -507,11 +411,6 @@ static EXCEPTION_POINTERS *exception_ptrs;
#define MODULE64_SIZE_WINXP 576
#define STACKWALK_MAX_FRAMES 64
void my_init_stacktrace()
{
}
void my_set_exception_pointers(EXCEPTION_POINTERS *ep)
{
exception_ptrs = ep;
......
......@@ -23,6 +23,7 @@ numa_interleave=0
wsrep_on=0
dry_run=0
defaults_group_suffix=
ignore_unknown=1
# Initial logging status: error log is not open, and not using syslog
logging=init
......@@ -389,11 +390,22 @@ parse_arguments() {
--help) usage ;;
--ignore-unknown) ignore_unknown=1 ;;
--no-ignore-unknown|--not-ignore-unknown) ignore_unknown=0 ;;
*)
if test $ignore_unknown -eq 0
then
case "$unrecognized_handling" in
collect) append_arg_to_args "$arg" ;;
complain) log_error "unknown option '$arg'" ;;
complain) log_error "unknown option '$arg'"
esac
else
case "$arg" in
"--loose-"*) append_arg_to_args "$arg" ;;
*) append_arg_to_args "--loose-$arg"
esac
fi
esac
done
}
......
......@@ -3357,7 +3357,6 @@ void init_signals(void)
sigemptyset(&sa.sa_mask);
sigprocmask(SIG_SETMASK,&sa.sa_mask,NULL);
my_init_stacktrace();
#if defined(__amiga__)
sa.sa_handler=(void(*)())handle_fatal_signal;
#else
......
......@@ -2747,9 +2747,11 @@ main(int argc, char **argv)
printf("TRUNCATE TABLE time_zone_name;\n");
printf("TRUNCATE TABLE time_zone_transition;\n");
printf("TRUNCATE TABLE time_zone_transition_type;\n");
printf("START TRANSACTION;\n");
if (scan_tz_dir(root_name_end, 0, opt_verbose))
{
printf("ROLLBACK;\n");
fflush(stdout);
fprintf(stderr,
"There were fatal errors during processing "
......@@ -2757,6 +2759,7 @@ main(int argc, char **argv)
return 1;
}
printf("COMMIT;\n");
printf("ALTER TABLE time_zone_transition "
"ORDER BY Time_zone_id, Transition_time;\n");
printf("ALTER TABLE time_zone_transition_type "
......
......@@ -15,7 +15,7 @@
MY_ADD_TESTS(bitmap base64 my_atomic my_rdtsc lf my_malloc my_getopt dynstring
byte_order
queues LINK_LIBRARIES mysys)
queues stacktrace LINK_LIBRARIES mysys)
MY_ADD_TESTS(my_vsnprintf LINK_LIBRARIES strings mysys)
MY_ADD_TESTS(aes LINK_LIBRARIES mysys mysys_ssl)
ADD_DEFINITIONS(${SSL_DEFINES})
......
/* Copyright (c) 2020, MariaDB Corporation.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; version 2 of the License.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335 USA */
#include <my_global.h>
#include <my_sys.h>
#include <stdio.h>
#include <my_stacktrace.h>
#include <tap.h>
char b_bss[10];
void test_my_safe_print_str()
{
char b_stack[10];
char *b_heap= strdup("LEGAL");
memcpy(b_stack, "LEGAL", 6);
memcpy(b_bss, "LEGAL", 6);
#ifndef __SANITIZE_ADDRESS__
fprintf(stderr, "\n===== stack =====\n");
my_safe_print_str(b_stack, 65535);
fprintf(stderr, "\n===== heap =====\n");
my_safe_print_str(b_heap, 65535);
fprintf(stderr, "\n===== BSS =====\n");
my_safe_print_str(b_bss, 65535);
fprintf(stderr, "\n===== data =====\n");
my_safe_print_str("LEGAL", 65535);
fprintf(stderr, "\n===== Above is a junk, but it is expected. =====\n");
#endif /*__SANITIZE_ADDRESS__*/
fprintf(stderr, "\n===== Nornal length test =====\n");
my_safe_print_str("LEGAL", 5);
fprintf(stderr, "\n===== NULL =====\n");
my_safe_print_str(0, 5);
#ifndef __SANITIZE_ADDRESS__
fprintf(stderr, "\n===== (const char*) 1 =====\n");
my_safe_print_str((const char*)1, 5);
#endif /*__SANITIZE_ADDRESS__*/
free(b_heap);
ok(1, "test_my_safe_print_str");
}
int main(int argc __attribute__((unused)), char **argv)
{
MY_INIT(argv[0]);
plan(1);
test_my_safe_print_str();
my_end(0);
return exit_status();
}
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment