[llvm-bugs] [Bug 26924] New: LLDB can't attach to the PostgreSQL backend process

via llvm-bugs llvm-bugs at lists.llvm.org
Sat Mar 12 00:27:51 PST 2016


https://llvm.org/bugs/show_bug.cgi?id=26924

            Bug ID: 26924
           Summary: LLDB can't attach to the PostgreSQL backend process
           Product: lldb
           Version: 3.7
          Hardware: PC
                OS: All
            Status: NEW
          Severity: normal
          Priority: P
         Component: All Bugs
          Assignee: lldb-dev at lists.llvm.org
          Reporter: afiskon at gmail.com
                CC: llvm-bugs at lists.llvm.org
    Classification: Unclassified

I compiled PostgreSQL on FreeBSD 10.2 using CLang 3.7. The problem is that I
can't attach to the PostgreSQL backend process using LLDB 3.7:

```
[eax at freebsd102 ~]$ ps wuax | grep postgres 
eax   29177   0.0  2.0 169592 20888  -  Is    6:11PM   0:00.00 postgres:
checkpointer process    (postgres)
eax   29178   0.0  2.0 169592 20924  -  Ss    6:11PM   0:00.07 postgres: writer
process    (postgres)
eax   29179   0.0  2.0 169592 20924  -  Ss    6:11PM   0:00.01 postgres: wal
writer process    (postgres)
eax   29180   0.0  2.1 169592 21140  -  Is    6:11PM   0:00.01 postgres:
autovacuum launcher process    (postgres)
eax   29181   0.0  1.0  24320 10216  -  Ss    6:11PM   0:00.00 postgres: stats
collector process    (postgres)
eax   29192   0.0  2.3 169592 23456  -  Ss    6:14PM   0:00.04 postgres: eax
eax [local] idle (postgres)
eax   29083   0.0  2.0 169592 20880  0  S     6:06PM   0:00.07
/usr/home/eax/postgresql-install/bin/postgres -D
/home/eax/postgresql-install/data
eax   29196   0.0  0.2  18824  2340  1  S+    6:15PM   0:00.00 grep postgres
[eax at freebsd102 ~]$ lldb -p 29192
(lldb) process attach --pid 29192
error: attach failed: unable to find executable for 'postgres: eax eax [local]
idle'
(lldb) q
```

In the same time everything works as expected for processes with "regular
names":

```
[eax at freebsd102 ~]$ lldb -p 29192
(lldb) process attach --pid 29192
error: attach failed: unable to find executable for 'postgres: eax eax [local]
idle'
(lldb) q
[eax at freebsd102 ~]$ lldb -p 29083
(lldb) process attach --pid 29083
Process 29083 stopped

Executable module set to "/usr/home/eax/postgresql-install/bin/postgres".
Architecture set to: x86_64-unknown-freebsd10.2-unknown.
(lldb) bt
* thread #1: tid = 100429, 0x000000080147beea libc.so.7`__sys_select + 10
  * frame #0: 0x000000080147beea libc.so.7`__sys_select + 10
    frame #1: 0x000000000081a326 postgres`ServerLoop + 262 at postmaster.c:1654
    frame #2: 0x0000000000817db8 postgres`PostmasterMain(argc=3,
argv=0x00007fffffffeab0) + 6008 at postmaster.c:1298
    frame #3: 0x00000000007481a9 postgres`main(argc=3, argv=0x00007fffffffeab0)
+ 793 at main.c:228
    frame #4: 0x0000000000471baf postgres`_start + 367
(lldb) q
```

There is no such issue in gdb/gcc.

In the same time for such a program:

```

#include <stdio.h>
#include <string.h>
#include <sys/types.h>
#include <unistd.h>

char new_name[] = "postgres: eax eax [local] idle";

int main(int argc, char* argv[])
{
  memcpy(argv[0], new_name, sizeof(new_name));

  printf("Parent: %d\n", getpid());

  if(0 == fork()) {
    printf("Child: %d\n", getpid());
  }

  sleep(100);
}

```

... everything works as expected:

```
[eax at freebsd102 ~/temp]$ /usr/local/bin/clang37 -O0 -g test.c -o test
[eax at freebsd102 ~/temp]$ ./test &
[1] 829
[eax at freebsd102 ~/temp]$ Parent: 829
Child: 830

[eax at freebsd102 ~/temp]$ lldb -p 829
(lldb) process attach --pid 829
Process 829 stopped

Executable module set to "./test".
Architecture set to: x86_64-unknown-freebsd10.2-unknown.
(lldb) bt
* thread #1: tid = 100363, 0x00000008008f9cea libc.so.7`__sys_nanosleep + 10
  * frame #0: 0x00000008008f9cea libc.so.7`__sys_nanosleep + 10
    frame #1: 0x000000080087ed1b libc.so.7`sleep + 43
    frame #2: 0x00000000004008cf test`main(argc=1, argv=0x00007fffffffebb8) +
175 at test.c:18
    frame #3: 0x000000000040073f test`_start + 367
(lldb) ^D
[1]+  Done                    ./test
[eax at freebsd102 ~/temp]$ lldb -p 830
(lldb) process attach --pid 830
Process 830 stopped

Executable module set to "./test".
Architecture set to: x86_64-unknown-freebsd10.2-unknown.
(lldb) b
No breakpoints currently set.
(lldb) bt
* thread #1: tid = 100351, 0x00000008008f9cea libc.so.7`__sys_nanosleep + 10
  * frame #0: 0x00000008008f9cea libc.so.7`__sys_nanosleep + 10
    frame #1: 0x000000080087ed1b libc.so.7`sleep + 43
    frame #2: 0x00000000004008cf test`main(argc=1, argv=0x00007fffffffebb8) +
175 at test.c:18
    frame #3: 0x000000000040073f test`_start + 367
(lldb) ^D

```

So the problem seems to be a bit more complicated then just handling changed
argv[0].

-- 
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20160312/90ae1516/attachment.html>


More information about the llvm-bugs mailing list