summaryrefslogtreecommitdiff
path: root/dbug
Commit message (Collapse)AuthorAgeFilesLines
* Minimize unsafe C functions usage - replace strcat() and strcpy() (and ↵Mikhail Chalov2023-01-201-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | strncat() and strncpy()) with custom safe_strcat() and safe_strcpy() functions The MariaDB code base uses strcat() and strcpy() in several places. These are known to have memory safety issues and their usage is discouraged. Common security scanners like Flawfinder flags them. In MariaDB we should start using modern and safer variants on these functions. This is similar to memory issues fixes in 19af1890b56c6c147c296479bb6a4ad00fa59dbb and 9de9f105b5cb88249acc39af73d32af337d6fd5f but now replace use of strcat() and strcpy() with safer options strncat() and strncpy(). However, add '\0' forcefully to make sure the result string is correct since for these two functions it is not guaranteed what new string will be null-terminated. Example: size_t dest_len = sizeof(g->Message); strncpy(g->Message, "Null json tree", dest_len); strncat(g->Message, ":", sizeof(g->Message) - strlen(g->Message)); size_t wrote_sz = strlen(g->Message); size_t cur_len = wrote_sz >= dest_len ? dest_len - 1 : wrote_sz; g->Message[cur_len] = '\0'; 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 -- Reviewer and co-author Vicențiu Ciorbaru <vicentiu@mariadb.org> -- Reviewer additions: * The initial function implementation was flawed. Replaced with a simpler and also correct version. * Simplified code by making use of snprintf instead of chaining strcat. * Simplified code by removing dynamic string construction in the first place and using static strings if possible. See connect storage engine changes.
* Fix typos in the codebase.fluesvamp2022-08-092-3/+3
|
* Fix clang-15 -Wdeprecated-non-prototypeMarko Mäkelä2022-07-011-3/+1
| | | | | K&R style function definitions are deprecated in all versions of C and not supported in C2x.
* Fixed crashing when using DBUG_PUSH_EMPTYMonty2022-06-061-3/+2
| | | | | | | DBUG_PUSH_EMPTY is used by thr_mutex.cc. If there are 4G of DBUG_PUSH_EMPTY calls, then DBUG_POP_EMPTY will cause a crash when DBUGCloseFile() will try to free an object that was never allocated.
* Merge 10.2 into 10.3Marko Mäkelä2021-05-241-1/+1
|\
| * cmake: fewer Build-Depends in SRPMSergei Golubchik2021-05-221-1/+1
| | | | | | | | don't require tar/gtar, git, getconf, groff/nroff, and ruby.
* | Merge 10.2 into 10.3Marko Mäkelä2020-07-023-4/+4
|\ \ | |/
| * Merge 10.1 into 10.2bb-10.2-mergeMarko Mäkelä2020-07-013-4/+4
| |\
| | * MDEV-22950 followupVladislav Vaintroub2020-06-251-1/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | Deadlock in DbugParse, on Linux. In 10.1, DBUG recursive mutex was improperly implemented. CODE_STATE::locked counter was never updated. Copy the code around LockMutex/UnlockMutex from 10.2
| | * mtr: use env for perlDaniel Black2020-06-232-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | On FreeBSD, perl isn't in /usr/bin, its in /usr/local/bin or elsewhere in the path. Like storage/{maria/unittest/,}ma_test_* , we use /usr/bin/env to find perl and run it.
| | * MDEV-22950 : fix race condition in dbugVladislav Vaintroub2020-06-201-2/+2
| | | | | | | | | | | | FreeState() zeros init_settings.out_file, which another thread can be using
* | | Merge branch '10.2' into 10.3Oleksandr Byelkin2020-05-041-0/+4
|\ \ \ | |/ /
| * | add WITH_DBUG_TRACE CMake variableEugene Kosov2020-04-291-0/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This is a way do disable DBUG_ENTER()/DBUG_EXIT() stuff which is needed to dbug trace. Those who doesn't need it may avoid tests slowdown with -DWITH_DBUG_TRACE=OFF dbug/tests.c: add define which is neede always in this test innodb.log_file_name_debug.test: do not depend on DBUG trace stuff in test Benchmark results: each test eats less CPU and you can have more parallel jobs in MTR. patched: ./mtr -mem -par=8 -suite=innodb 185.34s user 86.85s system 133% cpu 3:23.27 total ./mtr -mem -par=8 -suite=main 80.96s user 36.01s system 182% cpu 1:04.07 total main.select [ pass ] 1660 main.select [ pass ] 1513 main.select [ pass ] 1543 main.select [ pass ] 1660 main.select [ pass ] 1521 main.select [ pass ] 1511 main.select [ pass ] 1508 main.select [ pass ] 1520 main.select [ pass ] 1514 main.select [ pass ] 1522 vanilla: ./mtr -mem -par=8 -suite=innodb 203.61s user 92.16s system 140% cpu 3:30.16 total ./mtr -mem -par=8 -suite=main 94.11s user 35.51s system 206% cpu 1:02.69 total main.select [ pass ] 2032 main.select [ pass ] 2017 main.select [ pass ] 2040 main.select [ pass ] 2183 main.select [ pass ] 2253 main.select [ pass ] 2075 main.select [ pass ] 2109 main.select [ pass ] 2080 main.select [ pass ] 2098 main.select [ pass ] 2114
* | | Merge 10.2 into 10.3Marko Mäkelä2019-12-121-2/+5
|\ \ \ | |/ /
| * | MDEV-21223 innodb_fts.sync_ddl fails in buildbot, server crashed in que_thr_stepEugene Kosov2019-12-101-2/+5
| | | | | | | | | | | | | | | | | | | | | FreeState(): replace pointer to freed memory with NULL. This actually fixes a crash which is use-after-free as reported by ASAN DbugParse(): unconditionally lock mutex because we're touching shared init_settings.keywords
* | | Merge branch '10.2' into 10.3Oleksandr Byelkin2019-12-041-79/+67
|\ \ \ | |/ /
| * | Merge branch '10.1' into 10.2Oleksandr Byelkin2019-12-031-79/+67
| |\ \ | | |/
| | * try to fix data races in DBUGEugene Kosov2019-11-281-2/+40
| | | | | | | | | | | | | | | init_settings.keywords and it's pointee are shared data. Protect them with mutex too.
| | * cleanup DBUGEugene Kosov2019-11-211-39/+28
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | DbugParse(): removed mutex lock/unlock which should protect file writes only. And no file writes happen in this function. DbugFlush(): move mutex_unlock out of this method because fflush() doesn't need any locking. Slow stuff like mutex lock/unlock and accessing errno (TLS) is moved to a more narrow scope.
* | | Merge branch '10.2' into 10.3Oleksandr Byelkin2019-10-311-3/+0
|\ \ \ | |/ /
| * | Merge branch '10.1' into 10.2Oleksandr Byelkin2019-10-301-3/+0
| |\ \ | | |/
| | * remove unused struct membersEugene Kosov2019-10-291-3/+0
| | |
* | | MDEV-20525: Fix the -std=c90 buildsMarko Mäkelä2019-09-131-1/+1
| | |
* | | MDEV-20525 rocksdb debug compilation fails on Windows due to unresolved ↵Marko Mäkelä2019-09-131-0/+10
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | my_assert variable MYSQL_PLUGIN_IMPORT did not work correctly for the RocksDB helper library rocksdb_aux_lib, because that library was not compiled with -DMYSQL_DYNAMIC_PLUGIN. Fix DBUG such that it does not depend on exported data, only on functions (which do not need MYSQL_PLUGIN_IMPORT decoration) Use a "getter" function _db_my_assert() instead of DLL-exported variable. Also, reduce object code duplication by moving more of the DBUG_ASSERT logic inside the _db_my_assert() function, and add unlikely() and ATTRIBUTE_COLD hints to ensure that the 'assertion failed' code will be separated from the main control flow logic. Thus, the compiler can move the unlikely() code to the end of the compiled function, reachable via a forward conditional branch, which the processor's branch predictor could assume 'not taken'.
* | | Merge 10.2 into 10.3Marko Mäkelä2019-05-142-2/+2
|\ \ \ | |/ /
| * | Merge 10.1 into 10.2Marko Mäkelä2019-05-132-2/+2
| |\ \ | | |/
| | * Merge branch '5.5' into 10.1Vicențiu Ciorbaru2019-05-112-2/+2
| | |\
| | | * Update FSF AddressVicențiu Ciorbaru2019-05-112-2/+2
| | | | | | | | | | | | | | | | * Update wrong zip-code
* | | | Merge 10.2 into 10.3Marko Mäkelä2019-03-081-0/+8
|\ \ \ \ | |/ / /
| * | | Merge 10.1 into 10.2Marko Mäkelä2019-03-071-0/+8
| |\ \ \ | | |/ / | | | | | | | | | | | | | | | | Rewrite the MDEV-13818 fix to prevent heap-use-after-free. Add a test case for MDEV-18272.
| | * | disable LeakSanitizer for unit.dbug testSergei Golubchik2019-03-061-0/+8
| | | |
| * | | Make debug multi thread safeMonty2017-10-261-25/+86
| | | | | | | | | | | | | | | | | | | | | | | | | | | | Fixes crashes in InList when calling _db_set_init (part of SET debug_dbug in the test suite) from another thread. Patch backported from 10.3
* | | | Misc. typosluz.paz2018-04-051-2/+2
| | | | | | | | | | | | | | | | Found via `codespell -i 3 -w --skip="./debian/po" -I ../mariadb-server-word-whitelist.txt ./cmake/ ./debian/ ./Docs/ ./include/ ./man/ ./plugin/ ./strings/`
* | | | Re-enable 'S' for --debug (sf_sanity checking for each call)Monty2017-12-221-3/+13
| | | | | | | | | | | | | | | | - Fixed also a wrong comment and a wrong argument to printf
* | | | Merge bb-10.2-ext into 10.3Marko Mäkelä2017-10-041-2/+2
|\ \ \ \ | |/ / /
| * | | MDEV-13844 : Fix Windows warnings. Fix DBUG_PRINT.Vladislav Vaintroub2017-09-281-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | - Fix win64 pointer truncation warnings (usually coming from misusing 0x%lx and long cast in DBUG) - Also fix printf-format warnings Make the above mentioned warnings fatal. - fix pthread_join on Windows to set return value.
* | | | Make debug multi thread safeMonty2017-09-081-25/+87
| | | | | | | | | | | | | | | | | | | | Fixes crashes in InList when calling _db_set_init (part of SET debug_dbug in the test suite) from another thread.
* | | | Added DBUG_ASSERT_AS_PRINTF compile flagMonty2017-08-241-1/+20
|/ / / | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | If compiling a non DBUG binary with -DDBUG_ASSERT_AS_PRINTF asserts will be changed to printf + stack trace (of stack trace are enabled). - Changed #ifndef DBUG_OFF to #ifdef DBUG_ASSERT_EXISTS for those DBUG_OFF that was just used to enable assert - Assert checking that could greatly impact performance where changed to DBUG_ASSERT_SLOW which is not affected by DBUG_ASSERT_AS_PRINTF - Added one extra option to my_print_stacktrace() to get more silent in case of stack trace printing as part of assert.
* | | Merge branch '10.1' into 10.2Sergei Golubchik2017-03-301-1/+1
|\ \ \ | |/ /
| * | MDEV-11752 Unsafe strmov - function definition in include/m_string.hSergei Golubchik2017-03-101-1/+1
| | | | | | | | | | | | | | | assert that strmov() cannot be used on overlapping strings. (because strpcpy cannot)
* | | Fix many -Wconversion warnings.Marko Mäkelä2017-03-071-12/+12
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Define my_thread_id as an unsigned type, to avoid mismatch with ulonglong. Change some parameters to this type. Use size_t in a few more places. Declare many flag constants as unsigned to avoid sign mismatch when shifting bits or applying the unary ~ operator. When applying the unary ~ operator to enum constants, explictly cast the result to an unsigned type, because enum constants can be treated as signed. In InnoDB, change the source code line number parameters from ulint to unsigned type. Also, make some InnoDB functions return a narrower type (unsigned or uint32_t instead of ulint; bool instead of ibool).
* | | MDEV-11611 fix Ninja buildSergei Golubchik2017-01-291-2/+2
| | | | | | | | | | | | ninja doesn't like when a dummy target name matches a generated file name
* | | MDEV-11713 Optimize DBUG_PRINT and introduce DBUG_LOGMarko Mäkelä2017-01-051-18/+17
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | MariaDB Server is unnecessarily evaluating the arguments of DBUG_PRINT() macros when the label is not defined. The macro DBUG_LOG() for C++ operator<< output which was added for InnoDB diagnostics in MySQL 5.7 is missing from MariaDB. Unlike the MySQL 5.7 implementation, MariaDB will avoid allocating and initializing the output string when the label is not defined. Introduce DBUG_OUT("crypt") and DBUG_OUT("checksum") for some InnoDB diagnostics, replacing some use of ib::info().
* | | Add C/C as a submodule in libmariadb/Sergei Golubchik2016-09-121-2/+2
|/ / | | | | | | | | | | also * fix includes * rename cmake macros and targets to avoid name clashes
* | dbug: correct trace for DBUG_RETURN(func()); -- gcc onlySergei Golubchik2015-11-161-3/+7
| | | | | | | | | | | | | | | | | | | | | | when func1 calls func2 from DBUG_RETURN, dbug shows the trace as | > func1 | < func1 | > func2 | < func2 because DBUG_LEAVE happens before func2(). Change that to invoke DBUG_LEAVE when the local variable goes out of scope. This uses gcc specific __attribute__((cleanup)).
* | MDEV-6410 Cross-compile fixesSergei Golubchik2014-07-081-7/+9
|\ \ | | | | | | | | | https://code.launchpad.net/~chewi/maria/mysql-fix-bug61340/+merge/217351
| * | MySQL Bug #61340: Use CMake EXPORT feature to aid cross-compiling.James Le Cuirot2014-04-271-7/+9
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This technique is documented at: http://www.cmake.org/Wiki/CMake_Cross_Compiling#Using_executables_in_the_build_created_during_the_build Basic steps are: # mkdir native cross # cd native # cmake /path/to/maria # make IMPORT_EXECUTABLES # cd ../cross # cmake -DCMAKE_TOOLCHAIN_FILE=foo -DIMPORT_EXECUTABLES=/path/to/native/import_executables.cmake /path/to/maria # make
* | | 5.5.38 mergeSergei Golubchik2014-06-061-0/+2
|\ \ \ | |/ / |/| / | |/
| * cmake: mark AIO_LIBRARY, EVENT_LIBRARY, GROFF, NROFF as advanced;Sergei Golubchik2014-06-031-0/+2
| | | | | | | | use -ggdb3 if supported
* | 5.5 mergeSergei Golubchik2014-03-261-0/+1
|\ \ | |/