summaryrefslogtreecommitdiff
path: root/mysys
Commit message (Collapse)AuthorAgeFilesLines
* Handle meaningless addr2line results and increase timeoutHugo Wen2023-04-011-3/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | MariaDB server prints the stack information if a crash happens. It traverses the stack frames in function `print_with_addr_resolve`. For *EACH* frame, it tries to parse the file name and line number of the frame using `addr2line`, or prints `backtrace_symbols_fd` if `addr2line` fails. 1. Logic in `addr_resolve` function uses addr2line to get the file name and line numbers. It has a timeout of 500ms to wait for the response from addr2line. However, that's not enough on small instances especially if the debug information is in a separate file or compressed. Increase the timeout to 5 seconds to support some edge cases, as experiments showed addr2line may take 2-3 seconds on some frames. 2. While parsing a frame inside of a shared library using `addr2line`, the file name and line numbers could be `??`, empty or `0` if the debug info is not loaded. It's easy to reproduce when glibc-debuginfo is not installed. Instead of printing a meaningless frame like: :0(__GI___poll)[0x1505e9197639] ... ??:0(__libc_start_main)[0x7ffff6c8913a] We want to print the frame information using `backtrace_symbols_fd`, with the shared library name and a hexadecimal offset. Stacktrace example on a real instance with this commit: /lib64/libc.so.6(__poll+0x49)[0x145cbf71a639] ... /lib64/libc.so.6(__libc_start_main+0xea)[0x7f4d0034d13a] `addr_resolve` has considered the case of meaningless combination of file name and line number returned by `addr2line`. e.g. `??:?` However, conditions like `:0` and `??:0` are not handled. So now the function will rollback to `backtrace_symbols_fd` in above cases. All new code of the whole pull request, including one or several files that are either new files or modified ones, are contributed under the BSD-new license. I am contributing on behalf of my employer Amazon Web Services, Inc.
* Minimize unsafe C functions usageChristian Gonzalez2023-03-084-9/+13
| | | | | | | | | | | | | | | Replace calls to `sprintf` and `strcpy` by the safer options `snprintf` and `safe_strcpy` in the following directories: - libmysqld - mysys - sql-common - strings All new code of the whole pull request, including one or several files that are either new files or modified ones, are contributed under the BSD-new license. I am contributing on behalf of my employer Amazon Web Services, Inc.
* MDEV-30556 UPPER() returns an empty string for U+0251 in Unicode-5.2.0+ ↵Alexander Barkov2023-02-031-0/+2
| | | | collations for utf8
* Merge 10.3 into 10.4Marko Mäkelä2022-12-134-103/+176
|\
| * MDEV-30162 Fix occasional "Permission denied" on Windows caused by buggy 3rd ↵Vladislav Vaintroub2022-12-074-103/+176
| | | | | | | | | | | | | | party Add retry logic for CreateFile, DeleteFile, or MoveFile when GetLastError() is ERROR_SHARING_VIOLATION.
* | Merge 10.3 into 10.4Marko Mäkelä2022-11-082-2/+8
|\ \ | |/
| * MDEV-29951 server hang in crash handlerVladislav Vaintroub2022-11-051-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | When trying to output stacktrace, and addr2line is not installed, the child process forked by start_addr2line_fork() will fail to do exec(), and finish with exit(1). There is a problem with exit() though - it runs exit handlers, and for the forked copy of crashing process, it is a bad idea. In 10.5+ code for example, exit handlers include tpool::task_group static destructors, and it will hang infinitely waiting for completion of the outstanding tasks. The fix is to use _exit() instead, which skips the execution of exit handlers
| * Fix building my_gethwaddr() on OpenBSDBrad Smith2022-10-271-1/+7
| |
* | Merge 10.3 into 10.4Marko Mäkelä2022-10-253-3/+0
|\ \ | |/
| * MDEV-15795 Stack exceeded if pthread_attr_setstacksize(&thr_attr,8196) succeedsSergei Golubchik2022-10-223-3/+0
| | | | | | | | | | | | | | | | | | on Linux this pthread_attr_setstacksize() fails with EINVAL "The stack size is less than PTHREAD_STACK_MIN (16384) bytes". But on FreeBSD it succeeds and causes a crash later, as 8196 is too little. Let's keep the stack at its default size in the timer thread.
* | MDEV-29613 Improve WITH_DBUG_TRACE=OFFMarko Mäkelä2022-09-231-3/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | In commit 28325b08633372cc343dfcbc41fe252020cf6e6e a compile-time option was introduced to disable the macros DBUG_ENTER and DBUG_RETURN or DBUG_VOID_RETURN. The parameter name WITH_DBUG_TRACE would hint that it also covers DBUG_PRINT statements. Let us do that: WITH_DBUG_TRACE=OFF shall disable DBUG_PRINT() as well. A few InnoDB recovery tests used to check that some output from DBUG_PRINT("ib_log", ...) is present. We can live without those checks. Reviewed by: Vladislav Vaintroub
* | Merge branch '10.3' into 10.4Oleksandr Byelkin2022-07-271-7/+6
|\ \ | |/
| * MDEV-28746 Wrong error code ER_BAD_DB_ERROR for long filenamesVladislav Vaintroub2022-07-071-7/+6
| | | | | | | | Add check for path length if CreateFile fails with ERROR_PATH_NOT_FOUND.
* | Merge 10.3 into 10.4Marko Mäkelä2022-06-271-1/+1
|\ \ | |/
| * MDEV-22590 SIGSEGV in flush_all_key_blocks when changing key_buffer_size / ↵Oleksandr Byelkin2022-06-241-1/+1
| | | | | | | | | | | | | | | | ASAN: heap-use-after-free in flush_all_key_blocks Take into account that in preparation of a simple key cache for resizing no disk blocks might be assigned to it. Reviewer: IgorBabaev <igor@mariadb.com>
* | Merge 10.3 into 10.4Marko Mäkelä2022-03-291-3/+6
|\ \ | |/
| * MDEV-28178 Windows : sporadic ER_ERROR_ON_RENAME .. (errno: 13 "Permission ↵Vladislav Vaintroub2022-03-281-3/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | denied") On affected machine, the error happens sporadically in innodb.instant_alter_limit. Procmon shows SetRenameInformationFile failing with ERROR_ACCESS_DENIED. In this case, the destination file was previously opened rsp oplocked by Windows defender antivirus. The fix is to retry MoveFileEx on ERROR_ACCESS_DENIED.
| * Merge branch 10.2 into 10.3Julius Goryavsky2021-12-231-2/+24
| |\
| | * MDEV-23175: my_timer_milliseconds clock_gettime for multiple platfomrsbb-10.2-MDEV-23175-backportDaniel Black2021-12-221-2/+24
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Small postfix to MDEV-23175 to ensure faster option on FreeBSD and compatibility to Solaris that isn't high resolution. ftime is left as a backup in case an implementation doesn't contain any of these clocks. FreeBSD $ ./unittest/mysys/my_rdtsc-t 1..11 # ----- Routine --------------- # myt.cycles.routine : 5 # myt.nanoseconds.routine : 11 # myt.microseconds.routine : 13 # myt.milliseconds.routine : 11 # myt.ticks.routine : 17 # ----- Frequency ------------- # myt.cycles.frequency : 3610295566 # myt.nanoseconds.frequency : 1000000000 # myt.microseconds.frequency : 1000000 # myt.milliseconds.frequency : 899 # myt.ticks.frequency : 136 # ----- Resolution ------------ # myt.cycles.resolution : 1 # myt.nanoseconds.resolution : 1 # myt.microseconds.resolution : 1 # myt.milliseconds.resolution : 7 # myt.ticks.resolution : 1 # ----- Overhead -------------- # myt.cycles.overhead : 26 # myt.nanoseconds.overhead : 19140 # myt.microseconds.overhead : 19036 # myt.milliseconds.overhead : 578 # myt.ticks.overhead : 21544 ok 1 - my_timer_init() did not crash ok 2 - The cycle timer is strictly increasing ok 3 - The cycle timer is implemented ok 4 - The nanosecond timer is increasing ok 5 - The nanosecond timer is implemented ok 6 - The microsecond timer is increasing ok 7 - The microsecond timer is implemented ok 8 - The millisecond timer is increasing ok 9 - The millisecond timer is implemented ok 10 - The tick timer is increasing ok 11 - The tick timer is implemented
* | | MDEV-23175: my_timer_milliseconds clock_gettime for multiple platfomrsbb-10.4-MDEV-23175-backportDaniel Black2021-12-221-2/+24
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Small postfix to MDEV-23175 to ensure faster option on FreeBSD and compatibility to Solaris that isn't high resolution. ftime is left as a backup in case an implementation doesn't contain any of these clocks. FreeBSD $ ./unittest/mysys/my_rdtsc-t 1..11 # ----- Routine --------------- # myt.cycles.routine : 5 # myt.nanoseconds.routine : 11 # myt.microseconds.routine : 13 # myt.milliseconds.routine : 11 # myt.ticks.routine : 17 # ----- Frequency ------------- # myt.cycles.frequency : 3610295566 # myt.nanoseconds.frequency : 1000000000 # myt.microseconds.frequency : 1000000 # myt.milliseconds.frequency : 899 # myt.ticks.frequency : 136 # ----- Resolution ------------ # myt.cycles.resolution : 1 # myt.nanoseconds.resolution : 1 # myt.microseconds.resolution : 1 # myt.milliseconds.resolution : 7 # myt.ticks.resolution : 1 # ----- Overhead -------------- # myt.cycles.overhead : 26 # myt.nanoseconds.overhead : 19140 # myt.microseconds.overhead : 19036 # myt.milliseconds.overhead : 578 # myt.ticks.overhead : 21544 ok 1 - my_timer_init() did not crash ok 2 - The cycle timer is strictly increasing ok 3 - The cycle timer is implemented ok 4 - The nanosecond timer is increasing ok 5 - The nanosecond timer is implemented ok 6 - The microsecond timer is increasing ok 7 - The microsecond timer is implemented ok 8 - The millisecond timer is increasing ok 9 - The millisecond timer is implemented ok 10 - The tick timer is increasing ok 11 - The tick timer is implemented
* | | Merge branch '10.3' into 10.4Sergei Golubchik2021-12-072-5/+9
|\ \ \ | |/ /
| * | Merge branch '10.2' into 10.3Sergei Golubchik2021-12-062-5/+9
| |\ \ | | |/
| | * MDEV-27088: Server crash on ARM (WMM architecture) due to missing barriers ↵Martin Beck2021-11-302-5/+9
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | in lf-hash MariaDB server crashes on ARM (weak memory model architecture) while concurrently executing l_find to load node->key and add_to_purgatory to store node->key = NULL. l_find then uses key (which is NULL), to pass it to a comparison function. The specific problem is the out-of-order execution that happens on a weak memory model architecture. Two essential reorderings are possible, which need to be prevented. a) As l_find has no barriers in place between the optimistic read of the key field lf_hash.cc#L117 and the verification of link lf_hash.cc#L124, the processor can reorder the load to happen after the while-loop. In that case, a concurrent thread executing add_to_purgatory on the same node can be scheduled to store NULL at the key field lf_alloc-pin.c#L253 before key is loaded in l_find. b) A node is marked as deleted by a CAS in l_delete lf_hash.cc#L247 and taken off the list with an upfollowing CAS lf_hash.cc#L252. Only if both CAS succeed, the key field is written to by add_to_purgatory. However, due to a missing barrier, the relaxed store of key lf_alloc-pin.c#L253 can be moved ahead of the two CAS operations, which makes the value of the local purgatory list stored by add_to_purgatory visible to all threads operating on the list. As the node is not marked as deleted yet, the same error occurs in l_find. This change three accesses to be atomic. * optimistic read of key in l_find lf_hash.cc#L117 * read of link for verification lf_hash.cc#L124 * write of key in add_to_purgatory lf_alloc-pin.c#L253 Reviewers: Sergei Vojtovich, Sergei Golubchik Fixes: MDEV-23510 / d30c1331a18d875e553f3fcf544997e4f33fb943
* | | Merge 10.3 into 10.4Marko Mäkelä2021-10-281-2/+2
|\ \ \ | |/ /
| * | Merge 10.2 into 10.3Marko Mäkelä2021-10-281-2/+2
| |\ \ | | |/
| | * Safemalloc typo fix found by clang.Oleksandr Byelkin2021-10-261-2/+2
| | |
* | | Merge 10.3 into 10.4Marko Mäkelä2021-10-211-0/+4
|\ \ \ | |/ /
| * | Link with libatomic to enable C11 atomics supportVicențiu Ciorbaru2021-10-191-0/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Some architectures (mips) require libatomic to support proper atomic operations. Check first if support is available without linking, otherwise use the library. Contributors: James Cowgill <jcowgill@debian.org> Jessica Clarke <jrtc27@debian.org> Vicențiu Ciorbaru <vicentiu@mariadb.org>
* | | Merge 10.3 into 10.4Marko Mäkelä2021-10-131-0/+7
|\ \ \ | |/ /
| * | Merge 10.2 into 10.3Marko Mäkelä2021-10-131-0/+7
| |\ \ | | |/
| | * Xcode compatibility updateSergei Krivonos2021-10-121-0/+7
| | |
* | | Merge branch '10.3' into 10.4Vladislav Vaintroub2021-09-242-1/+117
|\ \ \ | |/ /
| * | MDEV-11499 mysqltest, Windows : improve diagnostics if server fails to shutdownVladislav Vaintroub2021-09-242-2/+117
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Create minidump when server fails to shutdown. If process is being debugged, cause a debug break. Moves some code which is part of safe_kill into mysys, as both safe_kill, and mysqltest produce minidumps on different timeouts. Small cleanup in wait_until_dead() - replace inefficient loop with a single wait.
* | | MDEV-26601: mysys - O_TMPFILE ^ O_CREATDaniel Black2021-09-141-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | Thanks to Fabian Vogt for noticing the mutual exclusions of these open flags on tmpfs caused by mariadb opening it incorrectly. As such we clear the O_CREAT flag while opening it as O_TMPFILE.
* | | Merge 10.3 into 10.4Marko Mäkelä2021-08-311-3/+3
|\ \ \ | |/ /
| * | Merge 10.2 into 10.3Marko Mäkelä2021-08-311-3/+3
| |\ \ | | |/
| | * Fix GCC 11 -Wmaybe-uninitialized for PLUGIN_PERFSCHEMAMarko Mäkelä2021-08-301-3/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | init_mutex_v1_t: Stop lying that the mutex parameter is const. GCC 11.2.0 assumes that it is and could complain about any mysql_mutex_t being uninitialized even after mysql_mutex_init() as long as PLUGIN_PERFSCHEMA is enabled. init_rwlock_v1_t, init_cond_v1_t: Remove untruthful const qualifiers. Note: init_socket_v1_t is expecting that the socket fd has already been created before PSI_SOCKET_CALL(init_socket), and therefore that parameter really is being treated as a pointer to const.
* | | Merge branch '10.3' into 10.4Oleksandr Byelkin2021-07-311-1/+1
|\ \ \ | |/ /
| * | Merge 10.2 into 10.3Marko Mäkelä2021-07-271-1/+1
| |\ \ | | |/
| | * fix clang build: check alignment the other wayEugene Kosov2021-07-261-1/+1
| | |
* | | Merge 10.3 into 10.4Marko Mäkelä2021-06-211-2/+1
|\ \ \ | |/ /
| * | Merge 10.2 into 10.3Marko Mäkelä2021-06-211-2/+1
| |\ \ | | |/
| | * fix clang buildEugene Kosov2021-06-151-2/+1
| | | | | | | | | | | | a new warning -Wunused-but-set-variable was introduced recently to clang
* | | Merge branch bb-10.3-release into bb-10.4-releaseNikita Malyavin2021-05-051-6/+27
|\ \ \ | |/ /
| * | Merge branch bb-10.2-release into bb-10.3-releaseNikita Malyavin2021-05-041-6/+27
| |\ \ | | |/
| | * MDEV-25584 Implement posix semantics file deletion for Windows 10Vladislav Vaintroub2021-05-031-6/+27
| | |
* | | MDEV-22227 Assertion `state_ == s_exec' failed in ↵bb-10.4-MDEV-22227mkaruza2021-04-281-127/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | wsrep::client_state::start_transaction Removed redundant code for BF abort transaction in `thr_lock.cc`. TOI operations will ignore provided lock_wait_timeout and use `LONG_TIMEOUT` until operation is finished. Reviewed-by: Jan Lindström <jan.lindstrom@mariadb.com>
* | | Merge 10.3 into 10.4Marko Mäkelä2021-04-211-1/+1
|\ \ \ | |/ /
| * | Merge 10.2 into 10.3Marko Mäkelä2021-04-211-1/+1
| |\ \ | | |/
| | * MDEV-15064: IO_CACHE mysys read_pos, not libmaria rc_posbb-10.2-danielblack-MDEV-15064-IO_CACHE-read_posRainer Orth2021-04-171-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | It seems some overly tolerant compilers (gcc) allow the structure of IO_CACHE that is defined differently in libmaria to have members equalivance to the iocache in mysys. More strict Solaris compilers recognise that rc_pos really isn't a structure member and won't compile.