mariadb/mysys
Hugo Wen 3b64244070 Handle meaningless addr2line results and increase timeout
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.
2023-04-01 10:07:42 +03:00
..
array.c
base64.c
ChangeLog
charset-def.c
charset.c
checksum.c
CMakeLists.txt
errors.c
file_logger.c
get_password.c
guess_malloc_library.c
hash.c
lf_alloc-pin.c
lf_dynarray.c
lf_hash.c
list.c
ma_dyncol.c
mf_arr_appstr.c
mf_cache.c
mf_dirname.c
mf_fn_ext.c
mf_format.c
mf_getdate.c
mf_iocache.c
mf_iocache2.c
mf_keycache.c
mf_keycaches.c
mf_loadpath.c
mf_pack.c
mf_path.c
mf_qsort.c
mf_qsort2.c
mf_radix.c
mf_same.c
mf_sort.c
mf_soundex.c
mf_tempdir.c
mf_tempfile.c
mf_unixpath.c
mf_wcomp.c
mulalloc.c
my_access.c
my_addr_resolve.c
my_alarm.c
my_alloc.c
my_atomic_writes.c
my_basename.c
my_bit.c
my_bitmap.c
my_chmod.c
my_chsize.c
my_compare.c
my_compress.c
my_conio.c
my_context.c
my_copy.c
my_cpu.c
my_create.c
my_default.c
my_delete.c
my_div.c
my_dlerror.c
my_error.c
my_file.c
my_fopen.c
my_fstream.c
my_gethwaddr.c
my_getncpus.c
my_getopt.c
my_getpagesize.c
my_getsystime.c
my_getwd.c
my_init.c
my_largepage.c
my_lib.c
my_libwrap.c
my_likely.c
my_lock.c
my_lockmem.c
my_malloc.c
my_memmem.c
my_mess.c
my_minidump.cc
my_mkdir.c
my_mmap.c
my_new.cc
my_once.c
my_open.c
my_port.c
my_pread.c
my_pthread.c
my_quick.c
my_rdtsc.c
my_read.c
my_redel.c
my_rename.c
my_rnd.c
my_safehash.c
my_safehash.h
my_seek.c
my_setuser.c
my_sleep.c
my_static.c
my_static.h
my_symlink.c
my_symlink2.c
my_sync.c
my_thr_init.c
my_uuid.c
my_win_popen.cc
my_wincond.c
my_winerr.c
my_winfile.c
my_winthread.c
my_write.c
mysys_priv.h
psi_noop.c
ptr_cmp.c
queues.c
safemalloc.c
stacktrace.c
string.c
test_charset.c
test_dir.c
test_thr_mutex.c
test_xml.c
testhash.c
thr_alarm.c
thr_lock.c
thr_mutex.c
thr_rwlock.c
thr_timer.c
tree.c
typelib.c
waiting_threads.c
wqueue.c