Repository navigation
GDB extensions fails with optimized 3.13 due to cframe removal #127147
Copy link
Copy link
Closed
Labels
3.13only security fixesonly security fixes3.14bugs and security fixesbugs and security fixestriagedThe issue has been accepted as valid by a triager.The issue has been accepted as valid by a triager.type-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error
Description
Bug report
Bug description:
When using the python gdb extention python-gdb.py on an optimized python 3.13 installation, gdb shows no backtrace:
Reading symbols from .pyenv/versions/3.13.0/bin/python...
Attaching to program: .pyenv/versions/3.13.0/bin/python, process 53537
Reading symbols from .pyenv/versions/3.13.0/lib/libpython3.13.so.1.0...
Reading symbols from /lib64/libpthread.so.0...
(No debugging symbols found in /lib64/libpthread.so.0)
Reading symbols from /lib64/libdl.so.2...
(No debugging symbols found in /lib64/libdl.so.2)
Reading symbols from /lib64/libutil.so.1...
(No debugging symbols found in /lib64/libutil.so.1)
Reading symbols from /lib64/libm.so.6...
(No debugging symbols found in /lib64/libm.so.6)
Reading symbols from /lib64/libc.so.6...
(No debugging symbols found in /lib64/libc.so.6)
Reading symbols from /lib64/ld-linux-x86-64.so.2...
(No debugging symbols found in /lib64/ld-linux-x86-64.so.2)
Reading symbols from .pyenv/versions/3.13.0/lib/python3.13/lib-dynload/readline.cpython-313-x86_64-linux-gnu.so...
Reading symbols from /lib64/libreadline.so.7...
(No debugging symbols found in /lib64/libreadline.so.7)
Reading symbols from /lib64/libtinfo.so.6...
(No debugging symbols found in /lib64/libtinfo.so.6)
Reading symbols from .pyenv/versions/3.13.0/lib/python3.13/lib-dynload/_opcode.cpython-313-x86_64-linux-gnu.so...
Reading symbols from .pyenv/versions/3.13.0/lib/python3.13/lib-dynload/unicodedata.cpython-313-x86_64-linux-gnu.so...
Reading symbols from .pyenv/versions/3.13.0/lib/python3.13/lib-dynload/select.cpython-313-x86_64-linux-gnu.so...
Reading symbols from .pyenv/versions/3.13.0/lib/python3.13/lib-dynload/_struct.cpython-313-x86_64-linux-gnu.so...
Reading symbols from .pyenv/versions/3.13.0/lib/python3.13/lib-dynload/termios.cpython-313-x86_64-linux-gnu.so...
Reading symbols from .pyenv/versions/3.13.0/lib/python3.13/lib-dynload/fcntl.cpython-313-x86_64-linux-gnu.so...
Reading symbols from .pyenv/versions/3.13.0/lib/python3.13/lib-dynload/_curses.cpython-313-x86_64-linux-gnu.so...
Reading symbols from /lib64/libncursesw.so.6...
(No debugging symbols found in /lib64/libncursesw.so.6)
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib64/libthread_db.so.1".
0x00007f798865ea53 in poll () from /lib64/libc.so.6
--Type <RET> for more, q to quit, c to continue without paging--
Missing separate debuginfos, use: zypper install glibc-debuginfo-2.31-150300.89.2.x86_64 libncurses6-debuginfo-6.1-150000.5.27.1.x86_64 libreadline7-debuginfo-7.0-150400.27.3.2.x86_64
(gdb) py-bt
Traceback (most recent call first):
(unable to read python frame information)
<built-in method exec of module object at remote 0x7f7988499800>
(unable to read python frame information)
If the same setup is used but python is compiled in non-optimized mode (just don't set the CC and PYTHON_CONFIGURE_OPTS env variable), the backtrace works as expected. Same applies for python 3.12 and lower
Reading symbols from .pyenv/versions/3.13.0/bin/python...
Attaching to program: .pyenv/versions/3.13.0/bin/python, process 79951
Reading symbols from .pyenv/versions/3.13.0/lib/libpython3.13.so.1.0...
Reading symbols from /lib64/libpthread.so.0...
(No debugging symbols found in /lib64/libpthread.so.0)
Reading symbols from /lib64/libdl.so.2...
(No debugging symbols found in /lib64/libdl.so.2)
Reading symbols from /lib64/libutil.so.1...
(No debugging symbols found in /lib64/libutil.so.1)
Reading symbols from /lib64/libm.so.6...
(No debugging symbols found in /lib64/libm.so.6)
Reading symbols from /lib64/libc.so.6...
(No debugging symbols found in /lib64/libc.so.6)
Reading symbols from /lib64/ld-linux-x86-64.so.2...
(No debugging symbols found in /lib64/ld-linux-x86-64.so.2)
Reading symbols from .pyenv/versions/3.13.0/lib/python3.13/lib-dynload/readline.cpython-313-x86_64-linux-gnu.so...
Reading symbols from /lib64/libreadline.so.7...
(No debugging symbols found in /lib64/libreadline.so.7)
Reading symbols from /lib64/libtinfo.so.6...
(No debugging symbols found in /lib64/libtinfo.so.6)
Reading symbols from .pyenv/versions/3.13.0/lib/python3.13/lib-dynload/_opcode.cpython-313-x86_64-linux-gnu.so...
Reading symbols from .pyenv/versions/3.13.0/lib/python3.13/lib-dynload/unicodedata.cpython-313-x86_64-linux-gnu.so...
Reading symbols from .pyenv/versions/3.13.0/lib/python3.13/lib-dynload/select.cpython-313-x86_64-linux-gnu.so...
Reading symbols from .pyenv/versions/3.13.0/lib/python3.13/lib-dynload/_struct.cpython-313-x86_64-linux-gnu.so...
Reading symbols from .pyenv/versions/3.13.0/lib/python3.13/lib-dynload/termios.cpython-313-x86_64-linux-gnu.so...
Reading symbols from .pyenv/versions/3.13.0/lib/python3.13/lib-dynload/fcntl.cpython-313-x86_64-linux-gnu.so...
Reading symbols from .pyenv/versions/3.13.0/lib/python3.13/lib-dynload/_curses.cpython-313-x86_64-linux-gnu.so...
Reading symbols from /lib64/libncursesw.so.6...
(No debugging symbols found in /lib64/libncursesw.so.6)
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib64/libthread_db.so.1".
0x00007f947f668a53 in poll () from /lib64/libc.so.6
--Type <RET> for more, q to quit, c to continue without paging--
Missing separate debuginfos, use: zypper install glibc-debuginfo-2.31-150300.89.2.x86_64 libncurses6-debuginfo-6.1-150000.5.27.1.x86_64 libreadline7-debuginfo-7.0-150400.27.3.2.x86_64
(gdb) py-bt
Traceback (most recent call first):
File ".pyenv/versions/3.13.0/lib/python3.13/_pyrepl/unix_console.py", line 426, in wait
or bool(self.pollob.poll(timeout))
File ".pyenv/versions/3.13.0/lib/python3.13/_pyrepl/reader.py", line 756, in handle1
self.console.wait(100)
File ".pyenv/versions/3.13.0/lib/python3.13/_pyrepl/reader.py", line 801, in readline
self.handle1()
File ".pyenv/versions/3.13.0/lib/python3.13/_pyrepl/readline.py", line 389, in multiline_input
return reader.readline()
File ".pyenv/versions/3.13.0/lib/python3.13/_pyrepl/simple_interact.py", line 151, in run_multiline_interactive_console
statement = multiline_input(more_lines, ps1, ps2)
File ".pyenv/versions/3.13.0/lib/python3.13/_pyrepl/main.py", line 59, in interactive_console
run_multiline_interactive_console(console)
File ".pyenv/versions/3.13.0/lib/python3.13/_pyrepl/__main__.py", line 6, in <module>
__pyrepl_interactive_console()
<built-in method exec of module object at remote 0x7f947f4a5800>
File "<frozen runpy>", line 88, in _run_code
File "<frozen runpy>", line 198, in _run_module_as_main
Steps to reproduce
- install pyenv incl. all OS packages which are needed
- install gcc12
export CC="gcc-12"export PYTHON_CONFIGURE_OPTS="--enable-shared --with-lto --enable-optimizations"pyenv install 3.13.0- Open a new python3.13 shell using the just installed python and execute the following commands
6.1.import os
6.2.os.getpid()
6.3.while True: pass - Switch to another shell and execute
gdb -q <path-to-pyenv>/versions/3.13.0/bin/python -p <pid> - Wait till gdb spins up and execute
py-bt
OS: SUSE Linux Enterprise Server 15 SP4
CPython versions tested on:
3.13
Operating systems tested on:
Linux
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
3.13only security fixesonly security fixes3.14bugs and security fixesbugs and security fixestriagedThe issue has been accepted as valid by a triager.The issue has been accepted as valid by a triager.type-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error
Activity
[-]python 3.13 gdb extension does not work with optimized build[/-][+]GDB extensions fails with optimized 3.13 due to cframe removal[/+]kasium commentedon Jan 9, 2025
I had now some time to dig into this issue further. It happens in the python3.13-gdb.py file within the following code
With an optimized build, the first if evaluates to false, so that the code tries to read
cframe. This variable was removed with #108036 so there needs to be some fix which changes the usage ofcframeto the successorpicnixz commentedon Feb 10, 2025
cc @gaogaotiantian (are you the relevant expert here?)
gaogaotiantian commentedon Feb 10, 2025
I have basically 0 knowledge of that file. @markshannon has touched that one a few times I believe but not sure if he is the expert either. He is the expert on the cframe overall however. I can try to take a look if he's too busy.
markshannon commentedon Feb 11, 2025
The reference to
cframeis clearly wrong, we should remove that.It looks like the gdb extension for 3.13 needs debug symbols to work.
The exact behavior of the gdb plugin is neither tested or documented, it is just a "best effort".
The docs say only that a debug build is recommended, not required for debugging, so maybe we should treat this as a bug?
If it worked for 3.12, it would be nice if it worked for 3.13 and 3.14.
cielavenir commentedon Dec 3, 2025
In #142095 (comment) @mpage showed updated implementation using _Py_tss_gilstate but (1) _Py_tss_gilstate is Py3.15 only, Py3.14 can cherry-pick b8998fe but not sure if libpython3.14 ABI is compatible (2) Py3.13 is not compatible (cherry-pick causes conflict)
cielavenir commentedon Jan 9, 2026
@colesbury can this be closed as well?
colesbury commentedon Jan 9, 2026
yes, thanks
kasium commentedon Jan 12, 2026
Thanks a lot!