[Bug 1926815] [NEW] gdb doesn't work properly when attaching to R
Kevin Ushey
1926815 at bugs.launchpad.net
Fri Apr 30 22:45:04 UTC 2021
Public bug reported:
Sorry for the somewhat weird / vague title; hopefully the rest of this
issue will make it more concrete ...
First, to set the stage; gdb and R both installed from apt repositories:
$ /usr/bin/gdb --version
GNU gdb (Ubuntu 9.2-0ubuntu1~20.04) 9.2
Copyright (C) 2020 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
$ /usr/bin/R --version
R version 4.0.5 (2021-03-31) -- "Shake and Throw"
Copyright (C) 2021 The R Foundation for Statistical Computing
Platform: x86_64-pc-linux-gnu (64-bit)
R is free software and comes with ABSOLUTELY NO WARRANTY.
You are welcome to redistribute it under the terms of the
GNU General Public License versions 2 or 3.
For more information about these matters see
https://www.gnu.org/licenses/.
Now, I can use gdb in batch mode to introspect a bash process; e.g.
print the SHELL environment variable:
$ /usr/bin/gdb -batch -p $(pgrep -nx bash) -ex 'print (char*) getenv("SHELL")'
0x00007f5623d8c1db in __pselect (nfds=1, readfds=0x7ffdaeda52f0, writefds=0x0, exceptfds=0x0, timeout=<optimized out>, sigmask=0x5615fe778140 <_rl_orig_sigset>) at ../sysdeps/unix/sysv/linux/pselect.c:48
48 ../sysdeps/unix/sysv/linux/pselect.c: No such file or directory.
$1 = 0x5615ffc825d0 "/bin/bash"
[Inferior 1 (process 640102) detached]
But, if I try to do the same with a running R process, I see:
$ R -s -e "Sys.sleep(100)" &
[1] 643585
$ /usr/bin/gdb -batch -p $(pgrep -nx R) -ex 'print (char*) getenv("SHELL")'
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1".
0x00007f47944050da in select () from /usr/lib/x86_64-linux-gnu/libc.so.6
Invalid character '"' in expression.
[Inferior 1 (process 643585) detached]
Note the very confusing 'Invalid character '"' in expression.' error, implying that gdb was for some reason unable to handle the double-quoted string passed to getenv().
I cannot reproduce this in a version of gdb 9.2 built from sources
locally; e.g.
$ gdb --version
GNU gdb (GDB) 9.2
Copyright (C) 2020 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
$ gdb -batch -p $(pgrep -nx R) -ex 'print (char*) getenv("SHELL")'
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1".
0x00007fba31ad60da in select () from /usr/lib/x86_64-linux-gnu/libc.so.6
$1 = 0x7fff4dc9adfe "/bin/bash"
[Inferior 1 (process 701827) detached]
So it seems like something specifically is broken in the version of GDB
packaged for Ubuntu 20.04.
** Affects: gdb (Ubuntu)
Importance: Undecided
Status: New
--
You received this bug notification because you are a member of Ubuntu
Foundations Bugs, which is subscribed to gdb in Ubuntu.
https://bugs.launchpad.net/bugs/1926815
Title:
gdb doesn't work properly when attaching to R
Status in gdb package in Ubuntu:
New
Bug description:
Sorry for the somewhat weird / vague title; hopefully the rest of this
issue will make it more concrete ...
First, to set the stage; gdb and R both installed from apt
repositories:
$ /usr/bin/gdb --version
GNU gdb (Ubuntu 9.2-0ubuntu1~20.04) 9.2
Copyright (C) 2020 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
$ /usr/bin/R --version
R version 4.0.5 (2021-03-31) -- "Shake and Throw"
Copyright (C) 2021 The R Foundation for Statistical Computing
Platform: x86_64-pc-linux-gnu (64-bit)
R is free software and comes with ABSOLUTELY NO WARRANTY.
You are welcome to redistribute it under the terms of the
GNU General Public License versions 2 or 3.
For more information about these matters see
https://www.gnu.org/licenses/.
Now, I can use gdb in batch mode to introspect a bash process; e.g.
print the SHELL environment variable:
$ /usr/bin/gdb -batch -p $(pgrep -nx bash) -ex 'print (char*) getenv("SHELL")'
0x00007f5623d8c1db in __pselect (nfds=1, readfds=0x7ffdaeda52f0, writefds=0x0, exceptfds=0x0, timeout=<optimized out>, sigmask=0x5615fe778140 <_rl_orig_sigset>) at ../sysdeps/unix/sysv/linux/pselect.c:48
48 ../sysdeps/unix/sysv/linux/pselect.c: No such file or directory.
$1 = 0x5615ffc825d0 "/bin/bash"
[Inferior 1 (process 640102) detached]
But, if I try to do the same with a running R process, I see:
$ R -s -e "Sys.sleep(100)" &
[1] 643585
$ /usr/bin/gdb -batch -p $(pgrep -nx R) -ex 'print (char*) getenv("SHELL")'
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1".
0x00007f47944050da in select () from /usr/lib/x86_64-linux-gnu/libc.so.6
Invalid character '"' in expression.
[Inferior 1 (process 643585) detached]
Note the very confusing 'Invalid character '"' in expression.' error, implying that gdb was for some reason unable to handle the double-quoted string passed to getenv().
I cannot reproduce this in a version of gdb 9.2 built from sources
locally; e.g.
$ gdb --version
GNU gdb (GDB) 9.2
Copyright (C) 2020 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
$ gdb -batch -p $(pgrep -nx R) -ex 'print (char*) getenv("SHELL")'
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1".
0x00007fba31ad60da in select () from /usr/lib/x86_64-linux-gnu/libc.so.6
$1 = 0x7fff4dc9adfe "/bin/bash"
[Inferior 1 (process 701827) detached]
So it seems like something specifically is broken in the version of
GDB packaged for Ubuntu 20.04.
To manage notifications about this bug go to:
https://bugs.launchpad.net/ubuntu/+source/gdb/+bug/1926815/+subscriptions
More information about the foundations-bugs
mailing list