skip to Main Content

The following error occurred while attempting to use gdb to debug errors in Apache Age. The postgres server was started using pg_ctl and a connection to a database was established using psql. The running process ID (pid) of psql was found using the SELECT pg_backend_pid() command. However, when attempting to attach gdb to the psql process using gdb --pid 4585, the following error message was received:

Attaching to process 4585
Could not attach to process.  If your uid matches the uid of the target
process, check the setting of /proc/sys/kernel/yama/ptrace_scope, or try
again as the root user.  For more details, see /etc/sysctl.d/10-ptrace.conf
ptrace: Operation not permitted.

Afterwards, I attempted to run gdb with elevated privileges by using the command sudo gdb --pid 4585. However, the following error message was displayed:

Starting program: /home/mohayu/Desktop/age_installation/pg/postgresql-11.18/bin/postgres 
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1".
"root" execution of the PostgreSQL server is not permitted.
The server must be started under an unprivileged user ID to prevent
possible system security compromise.  See the documentation for
more information on how to properly start the server.
[Inferior 1 (process 5056) exited with code 01]

If you are unsure about the reasons behind the errors occurring, just tell me on how to debug Apache Age with gdb.

2

Answers


  1. Run gdb while you are the user who owns the PostgreSQL processes, usually postgres.

    Make sure you have the PostgreSQL debugging symbols installed and that the extension is built with -g or -ggdb.

    Login or Signup to reply.
  2. With your first approach, using gdb --pid 4585, I got the same error. Although in the second approach using sudo I was successful, I have another suggestion:

    First, try just the sudo gdb command. The system must return the following:

    For help, type "help".
    Type "apropos word" to search for commands related to "word".
    (gdb)
    

    Then, use the attach [ID] command replacing [ID] with the pid. If it succeeds, the terminal will return something similar to the following messages:

    Reading symbols from /usr/local/pgsql-12/bin/postgres...
    Reading symbols from /lib/x86_64-linux-gnu/libpthread.so.0...
    Reading symbols from /usr/lib/debug/.build-id/7b/4536f41cdaa5888408e82d0836e33dcf436466.debug...
    [Thread debugging using libthread_db enabled]
    Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1".
    Reading symbols from /lib/x86_64-linux-gnu/librt.so.1...
    Reading symbols from /usr/lib/debug/.build-id/ce/016c975d94bc4770ed8c62d45dea6b71405a2c.debug...
    Reading symbols from /lib/x86_64-linux-gnu/libdl.so.2...
    Reading symbols from /usr/lib/debug/.build-id/c0/f40155b3f8bf8c494fa800f9ab197ebe20ed6e.debug...
    Reading symbols from /lib/x86_64-linux-gnu/libm.so.6...
    Reading symbols from /usr/lib/debug/.build-id/fe/91b4090ea04c1559ff71dd9290062776618891.debug...
    Reading symbols from /lib/x86_64-linux-gnu/libc.so.6...
    Reading symbols from /usr/lib/debug/.build-id/18/78e6b475720c7c51969e69ab2d276fae6d1dee.debug...
    Reading symbols from /lib64/ld-linux-x86-64.so.2...
    Reading symbols from /usr/lib/debug/.build-id/45/87364908de169dec62ffa538170118c1c3a078.debug...
    Reading symbols from /lib/x86_64-linux-gnu/libnss_files.so.2...
    --Type <RET> for more, q to quit, c to continue without paging--
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search