• Davi Arnaut's avatar
    Bug#51817: incorrect assumption: thd->query at 0x2ab2a8360360 is an invalid pointer · 90b8410d
    Davi Arnaut authored
    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.
    90b8410d
mysqltest.cc 256 KB