classification
Title: test_gdb fails all tests on a profile-opt build configured --with-lto
Type: Stage: resolved
Components: Build Versions: Python 3.6, Python 3.5
process
Status: closed Resolution: out of date
Dependencies: Superseder:
Assigned To: Nosy List: alecsandru.patrascu, gregory.p.smith, methane, vstinner
Priority: normal Keywords: patch

Created on 2016-04-17 06:29 by gregory.p.smith, last changed 2020-06-11 13:41 by vstinner. This issue is now closed.

Files
File name Uploaded Description Edit
issue26788.patch alecsandru.patrascu, 2016-04-23 07:58 review
Messages (7)
msg263599 - (view) Author: Gregory P. Smith (gregory.p.smith) * (Python committer) Date: 2016-04-17 06:29
cpython/build35.lto$ ./python ../3.5/Lib/test/test_gdb.py
GDB version 7.10:
    GNU gdb (Ubuntu 7.10-1ubuntu2) 7.10
...
======================================================================
FAIL: test_tuples (__main__.PrettyPrintTests)
Verify the pretty-printing of tuples
----------------------------------------------------------------------
Traceback (most recent call last):
  File "../3.5/Lib/test/test_gdb.py", line 359, in test_tuples
    self.assertGdbRepr(tuple(), '()')
  File "../3.5/Lib/test/test_gdb.py", line 279, in assertGdbRepr
    gdb_repr, gdb_output = self.get_gdb_repr('id(' + ascii(val) + ')')
  File "../3.5/Lib/test/test_gdb.py", line 255, in get_gdb_repr
    self.fail('Unexpected gdb output: %r\n%s' % (gdb_output, gdb_output))
AssertionError: Unexpected gdb output: 'Breakpoint 1 at 0x4cc310\n[Thread debugging using libthread_db enabled]\nUsing host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1".\n\nBreakpoint 1, builtin_id ()\n#0  builtin_id ()\n'
Breakpoint 1 at 0x4cc310
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1".

Breakpoint 1, builtin_id ()
#0  builtin_id ()

I don't know the right thing to do here.  This might depend on compiler, linker, arch and gdb version?  Are it's LTO executables debuggable?  It's not clear to me that we can do anything about this.  We may just want to skip the test when configured --with-lto.  Or perhaps this is an indication that this specific toolchain's LTO build (x86_64, ubuntu wily gcc 5.2.1 and gdb 7.1.0) has issues and shouldn't be used?
msg263625 - (view) Author: Alecsandru Patrascu (alecsandru.patrascu) * Date: 2016-04-17 19:56
I will investigate this issue to understand what is happening there and submit a fix. Thank you for pointing out the exact OS and toolchain used.
msg264055 - (view) Author: Alecsandru Patrascu (alecsandru.patrascu) * Date: 2016-04-23 07:58
I uploaded a patch that skips these tests if optimizations are available.
msg287979 - (view) Author: Inada Naoki (methane) * (Python committer) Date: 2017-02-17 08:44
LGTM, but would you send pull request on Github?
msg287982 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2017-02-17 10:07
+@unittest.skipIf(python_is_optimized(),
+                 "Python was compiled with optimizations")
 class PrettyPrintTests(DebuggerTests):

I disagree with this skip. I just compiled Python with "./configure" and GCC: these tests pass. Except of one buildbot, PGO is not used on buildbots nor Travis CI. I would prefer to keep running these tests by default, but only skip on PGO build.

By the way, would it maybe possible to find the missing information "<optimized out>" from other variables?
msg288021 - (view) Author: Gregory P. Smith (gregory.p.smith) * (Python committer) Date: 2017-02-17 16:52
there may be something in sysconfig.get_config_vars() we could use or, better, we could add something specific to indicate both pgo and lto builds.
msg371279 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2020-06-11 13:40
I fail to reproduce the issue on the master branch of Python on Fedora 32:

* Python master at commit 9727694f08cad4b019d2939224e3416312b1c0e1
* Fedora 32
* gcc (GCC) 10.1.1
* GNU gdb (GDB) Fedora 9.1-5.fc32

Notice that multiple tests are skipped:

$ ./configure --with-lto && make && ./python -m test -v test_gdb 
(...)
gcc -pthread -fPIC -Wno-unused-result -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall -flto -fuse-linker-plugin -ffat-lto-objects -flto-partition=none -g -std=c99 (...)
(...)
== CPython 3.10.0a0 (heads/master:9727694f08, Jun 11 2020, 15:31:25) [GCC 10.1.1 20200507 (Red Hat 10.1.1-1)]
== Linux-5.6.16-300.fc32.x86_64-x86_64-with-glibc2.31 little-endian
== cwd: /home/vstinner/python/master/build/test_python_139705
== CPU count: 8
== encodings: locale=UTF-8, FS=utf-8
0:00:00 load avg: 2.77 Run tests sequentially
0:00:00 load avg: 2.77 [1/1] test_gdb
GDB version 9.1:
    GNU gdb (GDB) Fedora 9.1-5.fc32
    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.
test_NULL_ob_type (test.test_gdb.PrettyPrintTests)
Ensure that a PyObject* with NULL ob_type is handled gracefully ... ok
test_NULL_ptr (test.test_gdb.PrettyPrintTests)
Ensure that a NULL PyObject* is handled gracefully ... ok
test_builtin_method (test.test_gdb.PrettyPrintTests) ... ok
test_builtins_help (test.test_gdb.PrettyPrintTests)
Ensure that the new-style class _Helper in site.py can be handled ... ok
test_bytes (test.test_gdb.PrettyPrintTests)
Verify the pretty-printing of bytes ... ok
test_corrupt_ob_type (test.test_gdb.PrettyPrintTests)
Ensure that a PyObject* with a corrupt ob_type is handled gracefully ... ok
test_corrupt_tp_flags (test.test_gdb.PrettyPrintTests)
Ensure that a PyObject* with a type with corrupt tp_flags is handled ... ok
test_corrupt_tp_name (test.test_gdb.PrettyPrintTests)
Ensure that a PyObject* with a type with corrupt tp_name is handled ... ok
test_dicts (test.test_gdb.PrettyPrintTests)
Verify the pretty-printing of dictionaries ... ok
test_exceptions (test.test_gdb.PrettyPrintTests) ... ok
test_frames (test.test_gdb.PrettyPrintTests) ... ok
test_frozensets (test.test_gdb.PrettyPrintTests)
Verify the pretty-printing of frozensets ... ok
test_getting_backtrace (test.test_gdb.PrettyPrintTests) ... ok
test_int (test.test_gdb.PrettyPrintTests)
Verify the pretty-printing of various int values ... ok
test_lists (test.test_gdb.PrettyPrintTests)
Verify the pretty-printing of lists ... ok
test_modern_class (test.test_gdb.PrettyPrintTests)
Verify the pretty-printing of new-style class instances ... ok
test_selfreferential_dict (test.test_gdb.PrettyPrintTests)
Ensure that a reference loop involving a dict doesn't lead proxyval ... ok
test_selfreferential_list (test.test_gdb.PrettyPrintTests)
Ensure that a reference loop involving a list doesn't lead proxyval ... ok
test_selfreferential_new_style_instance (test.test_gdb.PrettyPrintTests) ... ok
test_selfreferential_old_style_instance (test.test_gdb.PrettyPrintTests) ... ok
test_sets (test.test_gdb.PrettyPrintTests)
Verify the pretty-printing of sets ... ok
test_singletons (test.test_gdb.PrettyPrintTests)
Verify the pretty-printing of True, False and None ... ok
test_strings (test.test_gdb.PrettyPrintTests)
Verify the pretty-printing of unicode strings ... ok
test_subclassing_list (test.test_gdb.PrettyPrintTests)
Verify the pretty-printing of an instance of a list subclass ... ok
test_subclassing_tuple (test.test_gdb.PrettyPrintTests)
Verify the pretty-printing of an instance of a tuple subclass ... ok
test_truncation (test.test_gdb.PrettyPrintTests)
Verify that very long output is truncated ... ok
test_tuples (test.test_gdb.PrettyPrintTests)
Verify the pretty-printing of tuples ... ok
test_bt (test.test_gdb.PyBtTests)
Verify that the "py-bt" command works ... skipped 'Python was compiled with optimizations'
test_bt_full (test.test_gdb.PyBtTests)
Verify that the "py-bt-full" command works ... skipped 'Python was compiled with optimizations'
test_gc (test.test_gdb.PyBtTests)
Verify that "py-bt" indicates if a thread is garbage-collecting ... skipped 'Python was compiled with optimizations'
test_pycfunction (test.test_gdb.PyBtTests)
Verify that "py-bt" displays invocations of PyCFunction instances ... skipped 'Python was compiled with optimizations'
test_threads (test.test_gdb.PyBtTests)
Verify that "py-bt" indicates threads that are waiting for the GIL ... ok
test_wrapper_call (test.test_gdb.PyBtTests) ... skipped 'Python was compiled with optimizations'
test_basic_command (test.test_gdb.PyListTests)
Verify that the "py-list" command works ... skipped 'Python was compiled with optimizations'
test_one_abs_arg (test.test_gdb.PyListTests)
Verify the "py-list" command with one absolute argument ... skipped 'Python was compiled with optimizations'
test_two_abs_args (test.test_gdb.PyListTests)
Verify the "py-list" command with two absolute arguments ... skipped 'Python was compiled with optimizations'
test_basic_command (test.test_gdb.PyLocalsTests) ... skipped 'Python was compiled with optimizations'
test_locals_after_up (test.test_gdb.PyLocalsTests) ... skipped 'Python was compiled with optimizations'
test_basic_command (test.test_gdb.PyPrintTests)
Verify that the "py-print" command works ... skipped 'Python was compiled with optimizations'
test_print_after_up (test.test_gdb.PyPrintTests) ... skipped 'Python was compiled with optimizations'
test_printing_builtin (test.test_gdb.PyPrintTests) ... skipped 'Python was compiled with optimizations'
test_printing_global (test.test_gdb.PyPrintTests) ... skipped 'Python was compiled with optimizations'
test_down_at_bottom (test.test_gdb.StackNavigationTests)
Verify handling of "py-down" at the bottom of the stack ... ok
test_pyup_command (test.test_gdb.StackNavigationTests)
Verify that the "py-up" command works ... skipped 'Python was compiled with optimizations'
test_up_at_top (test.test_gdb.StackNavigationTests)
Verify handling of "py-up" at the top of the stack ... ok
test_up_then_down (test.test_gdb.StackNavigationTests)
Verify "py-up" followed by "py-down" ... skipped 'Python was compiled with optimizations'

----------------------------------------------------------------------

Ran 46 tests in 84.636s

OK (skipped=16)
test_gdb passed in 1 min 25 sec

== Tests result: SUCCESS ==

1 test OK.

Total duration: 1 min 25 sec
Tests result: SUCCESS
History
Date User Action Args
2020-06-11 13:41:00vstinnersetstatus: open -> closed
resolution: out of date
messages: + msg371279

stage: resolved
2017-02-17 16:52:26gregory.p.smithsetmessages: + msg288021
2017-02-17 10:07:29vstinnersetnosy: + vstinner
messages: + msg287982
2017-02-17 08:44:44methanesetnosy: + methane
messages: + msg287979
2016-04-23 07:58:14alecsandru.patrascusetfiles: + issue26788.patch
keywords: + patch
messages: + msg264055
2016-04-17 19:56:14alecsandru.patrascusetmessages: + msg263625
2016-04-17 06:30:12gregory.p.smithlinkissue25702 dependencies
2016-04-17 06:29:59gregory.p.smithcreate