Bug 19676 - gdb fails with assert error if /proc is not mounted
Summary: gdb fails with assert error if /proc is not mounted
Status: RESOLVED FIXED
Alias: None
Product: gdb
Classification: Unclassified
Component: gdb (show other bugs)
Version: 7.10
: P2 normal
Target Milestone: 7.11.1
Assignee: Pedro Alves
URL:
Keywords:
: 18987 (view as bug list)
Depends on:
Blocks:
 
Reported: 2016-02-19 17:04 UTC by Len Sorensen
Modified: 2016-03-15 16:48 UTC (History)
2 users (show)

See Also:
Host:
Target:
Build:
Last reconfirmed:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Len Sorensen 2016-02-19 17:04:50 UTC
I was trying to run gdb in a chroot with debian sid armhf and kept getting a strange assertion error.  Downgrading gdb from 7.10 to 7.7 (from Debian jessie) made the problem go away.  I eventually realized that it was trying to somehow determine if the process was running or not so I tried mounting /proc which I generally don't bother to do in my chroots and never needed to before, and then the problem vanished.

Trying to run gdb 7.10 without /proc mounted gives:

(gdb) run
Starting program: /usr/bin/python3.5 /usr/bin/nosetests -s -v -A not\ network\ and\ not\ disabled pandas.io.tests.test_pytables:pandas.io.tests.test_pytables.TestHDFStore.test_append_frame_column_oriented
/build/gdb-eSlPCn/gdb-7.10/gdb/linux-thread-db.c:1675: internal-error: find_new_threads_once: Assertion `!target_has_execution || thread_db_use_events ()' failed.
A problem internal to GDB has been detected,
further debugging may prove unreliable.
Quit this debugging session? (y or n)

With /proc mounted it just works.

If gdb is going to insist on /proc being mounted to work now, perhaps it could say so clearly instead of blowing up with an assertion.  Better yet it should work without /proc like it used to.
Comment 1 Pedro Alves 2016-02-19 20:32:36 UTC
Could you try master / 7.11 ?
Comment 2 Len Sorensen 2016-02-22 16:41:09 UTC
I grabbed master from Friday and built it and ran it.  It doesn't work either when /proc isn't mounted, but the error is different:

root@rceng07:~# gdb /bin/ls
GNU gdb (Debian 7.11.50.20160219-0.1) 7.11.50.20160219-git
Copyright (C) 2016 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.  Type "show copying"
and "show warranty" for details.
This GDB was configured as "arm-linux-gnueabihf".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>.
Find the GDB manual and other documentation resources online at:
<http://www.gnu.org/software/gdb/documentation/>.
For help, type "help".
Type "apropos word" to search for commands related to "word"...
Reading symbols from /bin/ls...(no debugging symbols found)...done.
(gdb) run
Starting program: /bin/ls 
__GI__dl_debug_state () at dl-debug.c:74
74      dl-debug.c: No such file or directory.
Cannot find AT_ENTRY auxiliary vector entry.
(gdb) quit
A debugging session is active.

        Inferior 1 [process 23004] will be killed.

Quit anyway? (y or n) y
root@rceng07:~# mount -t proc /proc /proc
root@rceng07:~# gdb /bin/ls
GNU gdb (Debian 7.11.50.20160219-0.1) 7.11.50.20160219-git
Copyright (C) 2016 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.  Type "show copying"
and "show warranty" for details.
This GDB was configured as "arm-linux-gnueabihf".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>.
Find the GDB manual and other documentation resources online at:
<http://www.gnu.org/software/gdb/documentation/>.
For help, type "help".
Type "apropos word" to search for commands related to "word"...
Reading symbols from /bin/ls...(no debugging symbols found)...done.
(gdb) run
Starting program: /bin/ls 
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib/arm-linux-gnueabihf/libthread_db.so.1".
[Inferior 1 (process 23012) exited normally]
(gdb) quit
root@rceng07:~# ls
Comment 3 Pedro Alves 2016-03-01 16:50:05 UTC
I've just sent a fix for these two issues, here:

 https://sourceware.org/ml/gdb-patches/2016-03/msg00012.html

Also available in the users/palves/proc-no-mounted branch.
Comment 4 Pedro Alves 2016-03-01 16:54:09 UTC
*** Bug 18987 has been marked as a duplicate of this bug. ***
Comment 5 Len Sorensen 2016-03-01 20:54:15 UTC
I applied the two patches to the git version I tried, and it looks good to me.
Comment 6 cvs-commit@gcc.gnu.org 2016-03-15 16:34:05 UTC
The master branch has been updated by Pedro Alves <palves@sourceware.org>:

https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=16b4184277c4ad5b4a20278060fd3f6259d1ed49

commit 16b4184277c4ad5b4a20278060fd3f6259d1ed49
Author: Pedro Alves <palves@redhat.com>
Date:   Tue Mar 15 16:33:04 2016 +0000

    Fix PR gdb/19676: Disable displaced stepping if /proc not mounted
    
    On GNU/Linux archs that support displaced stepping, if /proc is not
    mounted, GDB gets stuck not able to step past breakpoints:
    
     (gdb) c
     Continuing.
     dl_main (phdr=<optimized out>, phnum=<optimized out>, user_entry=<optimized out>, auxv=<optimized out>) at rtld.c:2163
     2163      LIBC_PROBE (init_complete, 2, LM_ID_BASE, r);
     Cannot find AT_ENTRY auxiliary vector entry.
     (gdb) c
     Continuing.
     dl_main (phdr=<optimized out>, phnum=<optimized out>, user_entry=<optimized out>, auxv=<optimized out>) at rtld.c:2163
     2163      LIBC_PROBE (init_complete, 2, LM_ID_BASE, r);
     Cannot find AT_ENTRY auxiliary vector entry.
     (gdb)
    
    That's because GDB can't figure out where the scratch pad is.
    
    This is a regression introduced by the earlier changes to make the
    Linux native target always work in non-stop mode.
    
    This commit makes GDB detect the case and fallback to stepping over
    breakpoints in-line.
    
    gdb/ChangeLog:
    2016-03-15  Pedro Alves  <palves@redhat.com>
    
    	PR gdb/19676
    	* infrun.c (displaced_step_prepare): Also disable displaced
    	stepping on NOT_SUPPORTED_ERROR.
    	* linux-tdep.c (linux_displaced_step_location): If reading auxv
    	fails, throw NOT_SUPPORTED_ERROR instead of generic error.
Comment 7 cvs-commit@gcc.gnu.org 2016-03-15 16:34:11 UTC
The master branch has been updated by Pedro Alves <palves@sourceware.org>:

https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=1eb2dbb8d73c344e199fd04531ec3f649e2835b2

commit 1eb2dbb8d73c344e199fd04531ec3f649e2835b2
Author: Pedro Alves <palves@redhat.com>
Date:   Tue Mar 15 16:33:04 2016 +0000

    Fix PR gdb/19676: Internal error in linux-thread.db.c if /proc not mounted
    
    If /proc is not mounted, GDB fails an assertion in find_new_threads_once:
    
     Continuing.
     .../src/gdb/linux-thread-db.c:1249: internal-error: find_new_threads_once: Assertion `!target_has_execution' failed.
     A problem internal to GDB has been detected,
     further debugging may prove unreliable.
     Quit this debugging session? (y or n)
    
    That was supposed to catch misuses of td_ta_thr_iter, which is unsafe
    for live debugging.  However, if /proc is not mounted, we still
    fallback to using it.
    
    I didn't bother with a warning, because GDB already prints several
    others related to failing to open /proc files.
    
    gdb/ChangeLog:
    2016-03-15  Pedro Alves  <palves@redhat.com>
    
    	PR gdb/19676
    	* linux-thread-db.c (try_thread_db_load_1): Leave
    	info->td_ta_thr_iter_p NULL iff debugging a live process and we
    	have /proc access.
    	(find_new_threads_once): Assert that we have a non-NULL
    	info->td_ta_thr_iter_p instead of checking whether the target has
    	execution.
Comment 8 cvs-commit@gcc.gnu.org 2016-03-15 16:40:14 UTC
The gdb-7.11-branch branch has been updated by Pedro Alves <palves@sourceware.org>:

https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=4e57eb7028442f0e771c815d755b64daf7394e68

commit 4e57eb7028442f0e771c815d755b64daf7394e68
Author: Pedro Alves <palves@redhat.com>
Date:   Tue Mar 15 16:33:04 2016 +0000

    Fix PR gdb/19676: Disable displaced stepping if /proc not mounted
    
    On GNU/Linux archs that support displaced stepping, if /proc is not
    mounted, GDB gets stuck not able to step past breakpoints:
    
     (gdb) c
     Continuing.
     dl_main (phdr=<optimized out>, phnum=<optimized out>, user_entry=<optimized out>, auxv=<optimized out>) at rtld.c:2163
     2163      LIBC_PROBE (init_complete, 2, LM_ID_BASE, r);
     Cannot find AT_ENTRY auxiliary vector entry.
     (gdb) c
     Continuing.
     dl_main (phdr=<optimized out>, phnum=<optimized out>, user_entry=<optimized out>, auxv=<optimized out>) at rtld.c:2163
     2163      LIBC_PROBE (init_complete, 2, LM_ID_BASE, r);
     Cannot find AT_ENTRY auxiliary vector entry.
     (gdb)
    
    That's because GDB can't figure out where the scratch pad is.
    
    This is a regression introduced by the earlier changes to make the
    Linux native target always work in non-stop mode.
    
    This commit makes GDB detect the case and fallback to stepping over
    breakpoints in-line.
    
    gdb/ChangeLog:
    2016-03-15  Pedro Alves  <palves@redhat.com>
    
    	PR gdb/19676
    	* infrun.c (displaced_step_prepare): Also disable displaced
    	stepping on NOT_SUPPORTED_ERROR.
    	* linux-tdep.c (linux_displaced_step_location): If reading auxv
    	fails, throw NOT_SUPPORTED_ERROR instead of generic error.
Comment 9 cvs-commit@gcc.gnu.org 2016-03-15 16:40:20 UTC
The gdb-7.11-branch branch has been updated by Pedro Alves <palves@sourceware.org>:

https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=9312893c8d63934f7855451c6a78503e69a47453

commit 9312893c8d63934f7855451c6a78503e69a47453
Author: Pedro Alves <palves@redhat.com>
Date:   Tue Mar 15 16:33:04 2016 +0000

    Fix PR gdb/19676: Internal error in linux-thread.db.c if /proc not mounted
    
    If /proc is not mounted, GDB fails an assertion in find_new_threads_once:
    
     Continuing.
     .../src/gdb/linux-thread-db.c:1249: internal-error: find_new_threads_once: Assertion `!target_has_execution' failed.
     A problem internal to GDB has been detected,
     further debugging may prove unreliable.
     Quit this debugging session? (y or n)
    
    That was supposed to catch misuses of td_ta_thr_iter, which is unsafe
    for live debugging.  However, if /proc is not mounted, we still
    fallback to using it.
    
    I didn't bother with a warning, because GDB already prints several
    others related to failing to open /proc files.
    
    gdb/ChangeLog:
    2016-03-15  Pedro Alves  <palves@redhat.com>
    
    	PR gdb/19676
    	* linux-thread-db.c (try_thread_db_load_1): Leave
    	info->td_ta_thr_iter_p NULL iff debugging a live process and we
    	have /proc access.
    	(find_new_threads_once): Assert that we have a non-NULL
    	info->td_ta_thr_iter_p instead of checking whether the target has
    	execution.
Comment 10 Pedro Alves 2016-03-15 16:48:23 UTC
Fixed.  Fix will be in gdb 7.11.1.