Bug 1639242 - py-bt is broken, results in exception
Summary: py-bt is broken, results in exception
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Fedora
Classification: Fedora
Component: gdb
Version: 28
Hardware: Unspecified
OS: Unspecified
unspecified
unspecified
Target Milestone: ---
Assignee: Sergio Durigan Junior
QA Contact: Fedora Extras Quality Assurance
URL:
Whiteboard:
: 1613614 (view as bug list)
Depends On: 1613614
Blocks: 1660220
TreeView+ depends on / blocked
 
Reported: 2018-10-15 11:28 UTC by Victor Stinner
Modified: 2019-01-24 03:31 UTC (History)
21 users (show)

Fixed In Version: gdb-8.2-5.fc29 gdb-8.1.1-4.fc28
Doc Type: If docs needed, set a value
Doc Text:
Clone Of: 1613614
: 1660220 (view as bug list)
Environment:
Last Closed: 2018-12-02 08:27:45 UTC
Type: Bug
Embargoed:


Attachments (Terms of Use)

Description Victor Stinner 2018-10-15 11:28:15 UTC
+++ This bug was initially created as a clone of Bug #1613614 +++

Description of problem:
py-bt is broken, results in exception:

(gdb) py-bt
Traceback (most recent call first):
  (frame information optimized out)
Python Exception <class 'TypeError'> 'FakeRepr' object is not subscriptable: 
Error occurred in Python command: 'FakeRepr' object is not subscriptable

It worked fine in a recent version before that.

Version-Release number of selected component (if applicable):
python3: python3-3.6.6-1.fc28.src.rpm
gdb: 8.1-25.fc28

How reproducible:
100%

Steps to Reproduce:
1. Open gdb
2. Attach to python3 process
3. Type py-bt

Actual results:
doesn't work, gives error Python Exception <class 'TypeError'> 'FakeRepr' object is not subscriptable

Expected results:
works

Additional info:

--- Additional comment from Victor Stinner on 2018-10-15 06:59:57 EDT ---

I reproduced the issue:

$ sudo dnf debuginfo-install python3

$ cat x.py
import time
def dodo():
    print("dodo")
    time.sleep(3600)
dodo()

vstinner@apu$ gdb -args python3 x.py
GNU gdb (GDB) Fedora 8.1.1-3.fc28
(...)
Reading symbols from python3...Reading symbols from /usr/lib/debug/usr/bin/python3.6-3.6.6-1.fc28.x86_64.debug...done.
done.
Dwarf Error: could not find partial DIE containing offset 0x316 [in module /usr/lib/debug/usr/bin/python3.6-3.6.6-1.fc28.x86_64.debug]

(gdb) run
Starting program: /usr/bin/python3 x.py
(...)
dodo

^C
Program received signal SIGINT, Interrupt.
0x00007ffff6bf2787 in select () from /lib64/libc.so.6

(gdb) py-bt
Traceback (most recent call first):
  <unknown at remote 0x7ffff7e5f7e0>
Python Exception <class 'TypeError'> 'FakeRepr' object is not subscriptable: 
Error occurred in Python command: 'FakeRepr' object is not subscriptable


The root issue comes from gdb:
"Dwarf Error: could not find partial DIE containing offset 0x316 [in module /usr/lib/debug/usr/bin/python3.6-3.6.6-1.fc28.x86_64.debug]"

I debugged /usr/lib/debug/usr/lib64/libpython3.6m.so.1.0-3.6.6-1.fc28.x86_64.debug-gdb.py : the FakeRepr error indirectly comes from the fact that gdb fails to read debug symbols (the Dwarf Error).


On the Python side, python-gdb.py should be enhanced to better handle such error (exception while computing the line number), but the root issue is in gdb which fails to read debug symbols.

--- Additional comment from Victor Stinner on 2018-10-15 07:27:00 EDT ---

> On the Python side, python-gdb.py should be enhanced to better handle such error (exception while computing the line number)

I created https://bugs.python.org/issue34989 and proposed a fix for that.

Comment 1 Victor Stinner 2018-10-15 11:29:26 UTC
Steps to reproduce the issue on Fedora 28:

$ sudo dnf install gdb
$ sudo dnf debuginfo-install python3
$ gdb python3
GNU gdb (GDB) Fedora 8.1.1-3.fc28
(...)
Reading symbols from python3...Reading symbols from /usr/lib/debug/usr/bin/python3.6-3.6.6-1.fc28.x86_64.debug...done.
done.
Dwarf Error: could not find partial DIE containing offset 0x316 [in module /usr/lib/debug/usr/bin/python3.6-3.6.6-1.fc28.x86_64.debug]
(gdb) 

The problem is the "Dwarf Error".

Comment 2 Petr Viktorin (pviktori) 2018-11-28 13:30:08 UTC
On Rawhide, the steps in Comment 1 result in the same Dwarf Error.

Sergio, could you help with this issue? I don't know where to investigate further.

Comment 3 Sergio Durigan Junior 2018-11-29 06:39:48 UTC
(In reply to Petr Viktorin from comment #2)
> On Rawhide, the steps in Comment 1 result in the same Dwarf Error.
> 
> Sergio, could you help with this issue? I don't know where to investigate
> further.

Sorry about the delay, this bug has fallen through the cracks.  Anyway, with help from Keith and Jan we now have a patch for this issue.  I expect to submit it this Thursday, let's see how upstream receives it.  If everything goes well, I'll release a fixed GDB on Fedora by next week.  Hope this helps, and thanks for the ping!

Comment 4 Sergio Durigan Junior 2018-11-30 18:13:13 UTC
A patch has been posted upstream:

https://sourceware.org/ml/gdb-patches/2018-11/msg00574.html

And approved:

https://sourceware.org/ml/gdb-patches/2018-11/msg00576.html

commit 81fbbaf96216ed88973a069e4ed25379d7421ec8 (HEAD -> master, origin/master, origin/HEAD)
Author: Sergio Durigan Junior <sergiodj>
Date:   Wed Nov 28 17:22:08 2018 -0500

    Fix dwarf2read.c:dwarf2_find_containing_comp_unit's binary search

I'm working on backporting it to F28/F29 GDB now.

Comment 5 Fedora Update System 2018-11-30 21:03:06 UTC
gdb-8.2-5.fc29 has been submitted as an update to Fedora 29. https://bodhi.fedoraproject.org/updates/FEDORA-2018-1497d92365

Comment 6 Fedora Update System 2018-11-30 21:16:14 UTC
gdb-8.1.1-4.fc28 has been submitted as an update to Fedora 28. https://bodhi.fedoraproject.org/updates/FEDORA-2018-c86898e4a7

Comment 7 Fedora Update System 2018-12-01 01:38:48 UTC
gdb-8.1.1-4.fc28 has been pushed to the Fedora 28 testing repository. If problems still persist, please make note of it in this bug report.
See https://fedoraproject.org/wiki/QA:Updates_Testing for
instructions on how to install test updates.
You can provide feedback for this update here: https://bodhi.fedoraproject.org/updates/FEDORA-2018-c86898e4a7

Comment 8 Fedora Update System 2018-12-01 02:43:56 UTC
gdb-8.2-5.fc29 has been pushed to the Fedora 29 testing repository. If problems still persist, please make note of it in this bug report.
See https://fedoraproject.org/wiki/QA:Updates_Testing for
instructions on how to install test updates.
You can provide feedback for this update here: https://bodhi.fedoraproject.org/updates/FEDORA-2018-1497d92365

Comment 9 Fedora Update System 2018-12-02 08:27:45 UTC
gdb-8.2-5.fc29 has been pushed to the Fedora 29 stable repository. If problems still persist, please make note of it in this bug report.

Comment 10 Victor Stinner 2018-12-04 15:06:28 UTC
I tested again with gdb-8.2-3.fc29.x86_64 (with the bug):

$ cat x.py 
import time
def func():
    time.sleep(2500)
func()

$ gdb -args python3 x.py
(...)
Dwarf Error: could not find partial DIE containing offset 0x7d [in module /usr/lib/debug/usr/bin/python3.7-3.7.1-4.fc29.x86_64.debug]

I upgraded gdb to gdb-8.2-5.fc29.x86_64:

$ gdb -args python3 x.py
(...)
Reading symbols from python3...Reading symbols from /usr/lib/debug/usr/bin/python3.7-3.7.1-4.fc29.x86_64.debug...done.

(gdb) run
(...)

^C

(gdb) py-bt
Traceback (most recent call first):
  <built-in method sleep of module object at remote 0x7fffea6fb688>
  File "x.py", line 3, in func
    time.sleep(2500)
  File "x.py", line 4, in <module>
    func()

Great! It works as expected on Fedora 29 on an up-to-date system ;-)

Comment 11 Victor Stinner 2018-12-04 16:21:21 UTC
*** Bug 1613614 has been marked as a duplicate of this bug. ***

Comment 12 Fedora Update System 2019-01-24 03:31:46 UTC
gdb-8.1.1-4.fc28 has been pushed to the Fedora 28 stable repository. If problems still persist, please make note of it in this bug report.


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