Uploaded image for project: 'MariaDB Server'
  1. MariaDB Server
  2. MDEV-23491

__bss_start breaks compilation of various platforms

    XMLWordPrintable

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

          Activity

            People

              sanja Oleksandr Byelkin
              serg Sergei Golubchik
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Git Integration

                  Error rendering 'com.xiplink.jira.git.jira_git_plugin:git-issue-webpanel'. Please contact your Jira administrators.