Bug 1254306 - memstomp provides an incomplete backtrace despite debuginfo packages installed on the system
memstomp provides an incomplete backtrace despite debuginfo packages installe...
Status: NEW
Product: Red Hat Enterprise Linux 7
Classification: Red Hat
Component: memstomp (Show other bugs)
7.2
Unspecified Linux
low Severity low
: rc
: ---
Assigned To: Jeff Law
qe-baseos-tools
:
Depends On:
Blocks:
  Show dependency treegraph
 
Reported: 2015-08-17 12:33 EDT by Miroslav Franc
Modified: 2017-08-02 02:55 EDT (History)
2 users (show)

See Also:
Fixed In Version:
Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of:
Environment:
Last Closed:
Type: Bug
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---


Attachments (Terms of Use)

  None (edit)
Description Miroslav Franc 2015-08-17 12:33:56 EDT
The core issue seems to be that memstomp expects debuginfo in /usr/lib64/debug and not /usr/lib/debug.

Not sure whether this is fault of memstomp or binutils or something else.


Version-Release number of selected component (if applicable):
# rpm -q memstomp memstomp-debuginfo glibc glibc-debuginfo
memstomp-0.1.4-11.el7.x86_64
memstomp-0.1.4-11.el7.i686
memstomp-debuginfo-0.1.4-11.el7.x86_64
memstomp-debuginfo-0.1.4-11.el7.i686
glibc-2.17-103.el7.x86_64
glibc-2.17-103.el7.i686
glibc-debuginfo-2.17-103.el7.x86_64
glibc-debuginfo-2.17-103.el7.i686

You can observe the same thing with devtoolset memstomp as well.


Details:

1. There is a file called w.c:
---
#define __NO_STRING_INLINES
#include <string.h>

char d[] = "ABC";

int
main (void)
{
  strcat (d, d);
  return 0;
}
---

2. Let's compile it.
# gcc -rdynamic -g -fno-builtin w.c -o w


3. Let's get a backtrace.
# LD_PRELOAD=libmemstomp.so:libmemstomp-backtrace-symbols.so ./w
memstomp: 0.1.4 successfully initialized for process w (pid 22542).


strcat(dest=0x601037, src=0x601034, bytes=4) overlap for w(22542)
        ??:0    strcpy()
        ??:0    strcpy()
        ??:0    strcat()
        w.c:10  main()
        ??:0    __libc_start_main()
        ??:0    _start()


Obviously glibc and memstomp parts are missing debugging information despite debuginfo packages installed on the system.


4. Closer look: (truncated)

# strace -etrace=open -ELD_PRELOAD=libmemstomp.so:libmemstomp-backtrace-symbols.so ./w

open("/lib64/.debug/libmemstomp.so.debug", O_RDONLY) = -1 ENOENT (No such file or directory)
open("/usr/lib64/debug/usr/lib64/libmemstomp.so.debug", O_RDONLY) = -1 ENOENT (No such file or directory)

open("/lib64/.debug/libc-2.17.so.debug", O_RDONLY) = -1 ENOENT (No such file or directory)
open("/usr/lib64/debug/usr/lib64/libc-2.17.so.debug", O_RDONLY) = -1 ENOENT (No such file or directory)

# rpm -ql memstomp-debuginfo | grep libmemstomp.so.debug
/usr/lib/debug/usr/lib64/libmemstomp.so.debug
/usr/lib/debug/usr/lib/libmemstomp.so.debug


5. Let's stick the debuginfos where they are expected.
# ln -s /usr/lib/debug/ /usr/lib64/debug


6. Get a backtrace now.
# LD_PRELOAD=libmemstomp.so:libmemstomp-backtrace-symbols.so ./w
memstomp: 0.1.4 successfully initialized for process w (pid 22544).


strcat(dest=0x601037, src=0x601034, bytes=4) overlap for w(22544)
        memstomp.c:347  strcat()
        w.c:10  main()
        libc-start.c:308        __libc_start_main()
        ??:0    _start()

This looks much more reasonable.


7. Closer look: (truncated)
# strace -etrace=open -ELD_PRELOAD=libmemstomp.so:libmemstomp-backtrace-symbols.so ./w

open("/lib64/.debug/libmemstomp.so.debug", O_RDONLY) = -1 ENOENT (No such file or directory)
open("/usr/lib64/debug/usr/lib64/libmemstomp.so.debug", O_RDONLY) = 4
open("/usr/lib64/debug/usr/lib64/libmemstomp.so.debug", O_RDONLY) = 4
open("/usr/lib64/debug/usr/lib64/../../.dwz/memstomp-0.1.4-11.el7.x86_64", O_RDONLY) = 5
open("/usr/lib64/debug/usr/lib64/../../.dwz/memstomp-0.1.4-11.el7.x86_64", O_RDONLY) = 5

open("/lib64/.debug/libc-2.17.so.debug", O_RDONLY) = -1 ENOENT (No such file or directory)
open("/usr/lib64/debug/usr/lib64/libc-2.17.so.debug", O_RDONLY) = 4
open("/usr/lib64/debug/usr/lib64/libc-2.17.so.debug", O_RDONLY) = 4

Note You need to log in before you can comment on or make changes to this bug.