fix safemalloc to compile w/o libbfd.
CMakeLists.txt:
NOT_FOR_DISTRIBUTION option
cmake/readline.cmake:
simplify libedit/readline detection.
never use bundled libedit.
use system readline v6 only if NOT_FOR_DISTRIBUTION=1
configure.cmake:
use libbfd only if NOT_FOR_DISTRIBUTION=1
include/my_stacktrace.h:
link with libbfd even w/o safemalloc.
The problem is that the logic which checks if a pointer is
valid relies on a poor heuristic based on the start and end
addresses of the data segment and heap.
Apart from miscalculating the heap bounds, this approach also
suffers from the fact that memory can come from places other
than the heap. See Bug#58528 for a more detailed explanation.
On Linux, the solution is to access the process's memory
through /proc/self/task/<tid>/mem, which allows for retrieving
the contents of pages within the virtual address space of
the calling process. If a address range is not mapped, a
input/output error is returned.
client/mysqltest.cc:
Use new interface to my_safe_print_str.
include/my_stacktrace.h:
Drop name from my_safe_print_str.
mysys/stacktrace.c:
Access the process's memory through a file descriptor and
dump the contents of the memory range. The file descriptor
offset is equivalent to a offset into the address space.
Do not print the name of the variable associated with the
address. It can be better accomplished at a higher level.
sql/mysqld.cc:
Put the variable dumping information within its own newline block.
Use symbolic names which better convey information to the user.
Another problem is that the backtrace facility wasn't being
enabled for non-Linux targets even if the target OS has the
backtrace functions. Also, the stacktrace functions inside
mysqltest were being used without proper checks for their
presence in the build.
client/mysqltest.c:
Only use stacktrace functions if they are available.
configure.in:
Check if the compiler defines __bss_start
include/my_stacktrace.h:
Enable stacktrace if system has backtrace functions.
mysys/stacktrace.c:
Use backtrace functions if the system supports it.
sql/mysqld.cc:
Only use stacktrace functions if they are available.
The problem was that when a embedded linked version of mysqltest
crashed there was no way to obtain a stack trace if no core file
is available. Another problem is that the embedded version of
libmysql was not behaving (crash) the same as the non-embedded with
respect to sending commands to a explicitly closed connection.
The solution is to generate a mysqltest's stack trace on crash
and to enable "reconnect" if the connection handle was explicitly
closed so the behavior matches the non-embedded one.
client/CMakeLists.txt:
Link mysys to mysqltest.
client/Makefile.am:
Link mysys to mysqltest.
client/mysqltest.c:
Add fatal signal handling with backtracing for Unix and Windows.
configure.in:
Add check for weak symbols support and remove a spurious word.
include/Makefile.am:
Add new header with prototype for stack tracing functions.
include/my_stacktrace.h:
Add new header with prototype for stack tracing functions.
libmysqld/CMakeLists.txt:
stack tracing is now part of mysys.
libmysqld/Makefile.am:
stack tracing is now part of mysys.
libmysqld/lib_sql.cc:
Re-connect if connection was explicitly closed. This is
done to match the behavior of the non-embeded libmysql.
mysql-test/t/sql_low_priority_updates_func.test:
Test expects parallelism between queries that cannot be
guaranteed under embedded.
mysys/CMakeLists.txt:
Add stacktrace to mysys.
mysys/Makefile.am:
Add stacktrace to mysys.
mysys/stacktrace.c:
Move stacktrace to mysys and add weak symbol for the
C++ name de-mangling function so that it can later be
overridden in C++ code. Also add my_ prefix to exported
functions.
sql/CMakeLists.txt:
stacktrace was moved to mysys.
sql/Makefile.am:
stacktrace was moved to mysys.
sql/mysqld.cc:
Add my_ prefix to mysys functions.