Details
Description
when printing various strings from a SIGSEGV handler, stacktrace.c uses various tricks to make sure the pointer to a string is valid and can be resolved.
It particular it reads /proc/self/task/%d/mem map and checks the pointer against the __bss_start address. Getting this __bss_start is a very fragile piece of code and it breaks linking on various linux versions depending on what libraries are linked and what compiler/binutil version is used.
But this is all completely unnecessary, because the string is directly printed using kernel syscall write() — and kernel validates all user space pointers anyway. We should remove all pointer checks and just let the kernel vet them as it always does.
Note that on other OSes stacktrace.c does not validate any pointers (neither via proc map nor against __bss_start). User space pointer validation is Linux-only and completely redundant.
The trick is not to resolve the pointer before write(). In particular, at least one function does isprint(*c) — this should be removed. It doesn't add much, the crash information is printed to a log, not to a terminal, so we don't have to filter out control codes.
Attachments
Issue Links
- is caused by
-
MDEV-15961 Fix stacktraces under FreeBSD
- Closed
- is duplicated by
-
MDEV-23496 Fix build issue for MariaDB-10.5 on Debian 9
- Closed