-
-
Notifications
You must be signed in to change notification settings - Fork 30.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
test_gdb fails on Python 3.6 when built with LTO+PGO #74530
Comments
cstratak reported the following test failure on Fedora 24 when building Python 3.6 with LTO + PGO: ====================================================================== Traceback (most recent call last):
File "/builddir/build/BUILD/Python-3.6.1/Lib/test/test_gdb.py", line 783, in test_threads
cmds_after_breakpoint=['thread apply all py-bt'])
File "/builddir/build/BUILD/Python-3.6.1/Lib/test/test_gdb.py", line 218, in get_stack_trace
self.assertEqual(unexpected_errlines, [])
AssertionError: Lists differ: ["Python Exception <class 'ValueError'> Va[95 chars]nd."] != []
First list contains 2 additional elements.
First extra element 0:
"Python Exception <class 'ValueError'> Variable 'func_obj' not found.: "
+ []
- ["Python Exception <class 'ValueError'> Variable 'func_obj' not found.: ",
- "Error occurred in Python command: Variable 'func_obj' not found."] |
Full build log |
All the dependencies dragged. gdb is of version 7.11. The failures do not happen with gdb 7.12 (which exists in later Fedora releases). |
I created #1549 to update test_gdb.py and python-gdb.py in Python 3.6. I don't know if it will fix the issus, but it shouldn't hurt :-) |
Note: test_gdb is skipped on later Fedora's actually (possibly due to gdb package no being dragged at the minimal buildroot) so the issue might still be there, so the gdb version might have no effect on that. Will investigate further. |
So the issue wasn't restricted to a specific gdb version or distro release, as due to some issues dependency issues the gdb binary wasn't pulled in the buildroot which makes test_gdb to get skipped. So I was able to reproduce it on my system by installing gdb (version 7.12.1), compiling python 3.6 from sources with Also applied the relevant PR however it didn't fix the issue. Attaching the full log of 'make test' |
I rebuilt my python-3.6.1 with the path (d05f7fd) and tried debugging again -- same problem: % gdb7121 /opt/bin/python3.6 |
The actual stack, which I'm trying to debug, begins like this: #0 0xbfbfd34e in ?? () Maybe, it is "too deep" into the native (not Python) code for the feature to work? |
It seems that commit (c525723) changed the parameter name in the definition of _PyCFunction_FastCallDict(). I believe that changing 'func_obj' to just 'func' should fix it (in Tools/gdb/libpython.py). |
So, I tried the modified patch (see http://aldan.algebra.com/~mi/tmp/patch-issue30345) -- and now I simply get a different variable name in the error-message: (gdb) py-bt However, the older version of the patch only referenced "func_obj" in test_gdb.py -- not in libpython.py -- so I may have misunderstood Jeremy's suggestion entirely... |
LTO may break the debug symbols and make GDB unusable. I suggest these options as possible approaches:
|
Yes, but that is not a fix really in this case. |
I tested on the current master: git clean -fdx Python is compiled twice:
I see -g in both compilation steps. It seems like debug symbols are still here: vstinner@apu$ file ./python But I confirm that test_gdb fails when using LTO+PGO. gdb seems to be to read any C function argument: $ gdb -args ./python Lib/test/gdb_sample.py
(gdb) b builtin_id
(gdb) run
Breakpoint 1, 0x0000000000518da0 in builtin_id ()
(gdb) py-bt
Traceback (most recent call first):
(unable to read python frame information)
(unable to read python frame information)
(unable to read python frame information)
(unable to read python frame information) |
Those -g switches you see there are during compile-time. Except for py-bt, you should also try bt. With this link flag enabled, I can observe significant slowdown on my machine during the backtrace when using bt command (At least when I let the PGO do all the profiling, when compiled with the sed edit you posted here, I observe none). |
Oh. Using PGO+LTO but without LDFLAGS=-g, bt only shows me function names: all arguments are missing. I tested with LDFLAGS=-g: py-bt and bt work as expected, and test_gdb pass. I created PR 7709 to always compile Python with LDFLAGS=-g. |
Very interesting article about PGO and LTO changes in GCC: See "Early debug info" paragraph. |
Ok, I pushed a change to the master branch. Now the question is if Python 2.7, 3.6 and 3.7 should be fixed as well? I will wait at least one day to see if buildbots are happy. |
I created backports to 2.7, 3.6 and 3.7 branches: do you see any reason to not fix python-gdb.py in these branches? (Any reason to not add -g to $LTOFLAGS?) |
Honestly, the risk is very low: only "./configure --with-lto" is impacted and the addition of -g is protected by $ac_cv_prog_cc_g in configure. The -g flag just asks to copy debug symbols, it should not impact compiler performances. Thanks cstratak for the bug report, and thanks Marcel Plch for the proposed fix (it works well)! |
I think test_gdb is useful for 3.8 branch because some PEP-590 relating changes will be backported to it. |
I'm fine with relying on buildbots for test_gdb on Python 3.7 and older. Thanks for the fixes. |
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
bugs.python.org fields:
The text was updated successfully, but these errors were encountered: