summaryrefslogtreecommitdiff
path: root/mysys
Commit message (Collapse)AuthorAgeFilesLines
* Added detection of memory overwrite with multi_mallocbb-10.5-montyMonty2023-02-272-0/+31
| | | | | | | | | | | | | | | | | | | | | | | This patch also fixes some bugs detected by valgrind after this patch: - Not enough copy_func elements was allocated by Create_tmp_table() which causes an memory overwrite in Create_tmp_table::add_fields() I added an ASSERT() to be able to detect this also without valgrind. The bug was that TMP_TABLE_PARAM::copy_fields was not correctly set when calling create_tmp_table(). - Aria::empty_bits is not allocated if there is no varchar/char/blob fields in the table. Fixed code to take this into account. This cannot cause any issues as this is just a memory access into other Aria memory and the content of the memory would not be used. - Aria::last_key_buff was not allocated big enough. This may have caused issues with rtrees and ma_extra(HA_EXTRA_REMEMBER_POS) as they would use the same memory area. - Aria and MyISAM didn't take extended key parts into account, which caused problems when copying rec_per_key from engine to sql level. - Mark asan builds with 'asan' in version strihng to detect these in not_valgrind_build.inc. This is needed to not have main.sp-no-valgrind fail with asan.
* Merge 10.4 into 10.5Marko Mäkelä2023-02-101-0/+2
|\
| * MDEV-30556 UPPER() returns an empty string for U+0251 in Unicode-5.2.0+ ↵Alexander Barkov2023-02-031-0/+2
| | | | | | | | collations for utf8
* | MDEV-30572: my_large_malloc will only retry on ENOMEMDaniel Black2023-02-071-1/+1
| | | | | | | | | | Correct error in to only say "continuing to smaller size" if it really is.
* | Fix synopses in mysys APIsAlexander Kuleshov2023-01-064-3/+7
| | | | | | | | | | | | Since 7c58e97 the PSI_memory_key was added to some routines in the mysys/. This commit fixes synopses of functions that were updated with the PSI_memory_key parameter.
* | Merge 10.4 into 10.5Marko Mäkelä2022-12-134-103/+176
|\ \ | |/
| * 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.
* | | OS detection logic in my_gethwaddr.c is backwardsDominik Hassler2022-11-131-1/+1
| | |
* | | Merge 10.4 into 10.5Marko Mäkelä2022-11-082-2/+8
|\ \ \ | |/ /
| * | 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
| | |
* | | Fix building my_gethwaddr() on OpenBSD - part for 10.5 and newerBrad Smith2022-10-271-1/+1
| | |
* | | Merge 10.4 into 10.5Marko Mäkelä2022-10-252-2/+0
|\ \ \ | |/ /
| * | 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.
* | | Merge 10.4 into 10.5Marko Mäkelä2022-09-261-3/+3
|\ \ \ | |/ /
| * | 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
* | | MDEV-29418 linux uuid implementation returning non-hwaddr based suffixDaniel Black2022-08-311-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | Because of a define error the wrong value was being returned. Regression in MDEV-28243 Fixes: 607f9874679c3e4ef7edcd2c9d80120051af73cc
* | | my_getopt --help for "bit" optionsSergei Golubchik2022-08-021-1/+2
| | | | | | | | | | | | print "Defaults to on" not only for GET_BOOL, but also for GET_BIT
* | | Merge branch 'merge-perfschema-5.7' into 10.5Oleksandr Byelkin2022-08-021-10/+29
| | |
* | | Merge 10.4 into 10.5Marko Mäkelä2022-07-271-7/+6
|\ \ \ | |/ /
| * | 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.4 into 10.5Marko Mäkelä2022-06-271-1/+1
|\ \ \ | |/ /
| * | 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>
* | | MDEV-28243: AIX missing my_gethwaddr implementationDaniel Black2022-06-081-5/+14
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | and failing spider partition test. With some small datatype changes to the Linux/Solaris my_gethwaddr implementation the hardware address of AIX can be returned. This is an important aspect in Spider (and UUID). Spider test change reviewed by Nayuta Yanagisawa. my_gethwaddr review by Monty in #2081
* | | Cleanup: Remove IF_VALGRINDMarko Mäkelä2022-04-251-25/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The purpose of the compress() wrapper my_compress_buffer() was twofold: silence Valgrind warnings about uninitialized memory access before zlib 1.2.4, and have PERFORMANCE_SCHEMA instrumentation of some zlib related memory allocation. Because of PERFORMANCE_SCHEMA, we cannot trivially replace my_compress_buffer() with compress(). az_open(): Remove a crc32() call. Any CRC of the empty string is 0.
* | | Merge 10.4 into 10.5Marko Mäkelä2022-03-291-3/+6
|\ \ \ | |/ /
| * | 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
* | | | MDEV-24841: More workaroundsMarko Mäkelä2022-03-141-0/+7
| | | | | | | | | | | | | | | | | | | | | | | | For some reason, the tests of the MemorySanitizer build on 10.5 failed with both clang 13 and clang 14 with SIGSEGV. On 10.6 where it worked better, some more places to work around were identified.
* | | | MDEV-24841 Build error with MSAN use-of-uninitialized-value in comp_errMarko Mäkelä2022-03-142-7/+13
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The MemorySanitizer implementation in clang includes some built-in instrumentation (interceptors) for GNU libc. In GNU libc 2.33, the interface to the stat() family of functions was changed. Until the MemorySanitizer interceptors are adjusted, any MSAN code builds will act as if that the stat() family of functions failed to initialize the struct stat. A fix was applied in https://reviews.llvm.org/rG4e1a6c07052b466a2a1cd0c3ff150e4e89a6d87a but it fails to cover the 64-bit variants of the calls. For now, let us work around the MemorySanitizer bug by defining and using the macro MSAN_STAT_WORKAROUND().
* | | | Remove unused header from crc32c.ccLike Ma2022-02-241-1/+0
| | | |
* | | | Fixes some compiler issues on AIX (Monty2022-02-082-2/+3
| | | |
* | | | Fixed my_addr_resolve (cherry picked from 10.6)Monty2022-02-081-5/+17
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | When a server is compiled with -fPIE, my_addr_resolve needs to subtract the info.dli_fbase from symbol addresses in memory for addr2line to recognize them. When a server is compiled without -fPIE, my_addr_resolve should not do it. Unfortunately not all compilers define __PIE__ when -fPIE was used (e.g. older gcc doesn't), so we have to resort to run-time detection.
* | | | MDEV-27088: Server crash on ARM (WMM architecture) due to missing barriers ↵Martin Beck2021-11-302-7/+12
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | in lf-hash (10.5) 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.4 into 10.5Marko Mäkelä2021-10-281-2/+2
|\ \ \ \ | |/ / /
| * | | 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.4 into 10.5Marko Mäkelä2021-10-211-0/+4
|\ \ \ \ | |/ / /