Bug 1818857 - Build python-debug with -O0 to avoid test_gdb failures
Summary: Build python-debug with -O0 to avoid test_gdb failures
Keywords:
Status: CLOSED RAWHIDE
Alias: None
Product: Fedora
Classification: Fedora
Component: python3.9
Version: rawhide
Hardware: Unspecified
OS: Unspecified
low
unspecified
Target Milestone: ---
Assignee: Charalampos Stratakis
QA Contact: Fedora Extras Quality Assurance
URL:
Whiteboard:
Depends On:
Blocks: ARMTracker 1926283
TreeView+ depends on / blocked
 
Reported: 2020-03-30 14:44 UTC by Charalampos Stratakis
Modified: 2021-02-08 15:03 UTC (History)
13 users (show)

Fixed In Version:
Doc Type: If docs needed, set a value
Doc Text:
Clone Of:
: 1926283 (view as bug list)
Environment:
Last Closed: 2021-01-29 13:53:09 UTC
Type: Bug
Embargoed:


Attachments (Terms of Use)

Description Charalampos Stratakis 2020-03-30 14:44:24 UTC
When compiling python3, test_gdb fails due to regex mismatch on the expected output, on s390x and arm 32 bits.

Traceback:

======================================================================
FAIL: test_basic_command (test.test_gdb.PyPrintTests)
Verify that the "py-print" command works
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/builddir/build/BUILD/Python-3.8.2/Lib/test/test_gdb.py", line 924, in test_basic_command
    self.assertMultilineMatches(bt,
  File "/builddir/build/BUILD/Python-3.8.2/Lib/test/test_gdb.py", line 279, in assertMultilineMatches
    self.fail(msg='%r did not match %r' % (actual, pattern))
AssertionError: 'Breakpoint 1 (builtin_id) pending.\n[Thread debugging using libthread_db enabled]\nUsing host libthread_db library "/lib/libthread_db.so.1".\n\nBreakpoint 1, builtin_id (self=, v=42) at /builddir/build/BUILD/Python-3.8.2/Python/bltinmodule.c:1171\n1171\t{\n#4 (frame information optimized out)\n\'args\' not found\n' did not match ".*\\nlocal 'args' = \\(1, 2, 3\\)\\n.*"
======================================================================
FAIL: test_print_after_up (test.test_gdb.PyPrintTests)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/builddir/build/BUILD/Python-3.8.2/Lib/test/test_gdb.py", line 933, in test_print_after_up
    self.assertMultilineMatches(bt,
  File "/builddir/build/BUILD/Python-3.8.2/Lib/test/test_gdb.py", line 279, in assertMultilineMatches
    self.fail(msg='%r did not match %r' % (actual, pattern))
AssertionError: 'Breakpoint 1 (builtin_id) pending.\n[Thread debugging using libthread_db enabled]\nUsing host libthread_db library "/lib/libthread_db.so.1".\n\nBreakpoint 1, builtin_id (self=, v=42) at /builddir/build/BUILD/Python-3.8.2/Python/bltinmodule.c:1171\n1171\t{\n#4 (frame information optimized out)\n#10 (frame information optimized out)\n\'c\' not found\n\'b\' not found\n\'a\' not found\n' did not match ".*\\nlocal 'c' = 3\\nlocal 'b' = 2\\nlocal 'a' = 1\\n.*"
======================================================================
FAIL: test_printing_builtin (test.test_gdb.PyPrintTests)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/builddir/build/BUILD/Python-3.8.2/Lib/test/test_gdb.py", line 949, in test_printing_builtin
    self.assertMultilineMatches(bt,
  File "/builddir/build/BUILD/Python-3.8.2/Lib/test/test_gdb.py", line 279, in assertMultilineMatches
    self.fail(msg='%r did not match %r' % (actual, pattern))
AssertionError: 'Breakpoint 1 (builtin_id) pending.\n[Thread debugging using libthread_db enabled]\nUsing host libthread_db library "/lib/libthread_db.so.1".\n\nBreakpoint 1, builtin_id (self=, v=42) at /builddir/build/BUILD/Python-3.8.2/Python/bltinmodule.c:1171\n1171\t{\n#4 (frame information optimized out)\n\'len\' not found\n' did not match ".*\\nbuiltin 'len' = <built-in method len of module object at remote 0x-?[0-9a-f]+>\\n.*"
======================================================================
FAIL: test_printing_global (test.test_gdb.PyPrintTests)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/builddir/build/BUILD/Python-3.8.2/Lib/test/test_gdb.py", line 941, in test_printing_global
    self.assertMultilineMatches(bt,
  File "/builddir/build/BUILD/Python-3.8.2/Lib/test/test_gdb.py", line 279, in assertMultilineMatches
    self.fail(msg='%r did not match %r' % (actual, pattern))
AssertionError: 'Breakpoint 1 (builtin_id) pending.\n[Thread debugging using libthread_db enabled]\nUsing host libthread_db library "/lib/libthread_db.so.1".\n\nBreakpoint 1, builtin_id (self=, v=42) at /builddir/build/BUILD/Python-3.8.2/Python/bltinmodule.c:1171\n1171\t{\n#4 (frame information optimized out)\n\'__name__\' not found\n' did not match ".*\\nglobal '__name__' = '__main__'\\n.*"
======================================================================
FAIL: test_basic_command (test.test_gdb.PyLocalsTests)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/builddir/build/BUILD/Python-3.8.2/Lib/test/test_gdb.py", line 958, in test_basic_command
    self.assertMultilineMatches(bt,
  File "/builddir/build/BUILD/Python-3.8.2/Lib/test/test_gdb.py", line 279, in assertMultilineMatches
    self.fail(msg='%r did not match %r' % (actual, pattern))
AssertionError: 'Breakpoint 1 (builtin_id) pending.\n[Thread debugging using libthread_db enabled]\nUsing host libthread_db library "/lib/libthread_db.so.1".\n\nBreakpoint 1, builtin_id (self=, v=42) at /builddir/build/BUILD/Python-3.8.2/Python/bltinmodule.c:1171\n1171\t{\n#4 (frame information optimized out)\n' did not match '.*\\nargs = \\(1, 2, 3\\)\\n.*'
======================================================================
FAIL: test_locals_after_up (test.test_gdb.PyLocalsTests)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/builddir/build/BUILD/Python-3.8.2/Lib/test/test_gdb.py", line 967, in test_locals_after_up
    self.assertMultilineMatches(bt,
  File "/builddir/build/BUILD/Python-3.8.2/Lib/test/test_gdb.py", line 279, in assertMultilineMatches
    self.fail(msg='%r did not match %r' % (actual, pattern))
AssertionError: 'Breakpoint 1 (builtin_id) pending.\n[Thread debugging using libthread_db enabled]\nUsing host libthread_db library "/lib/libthread_db.so.1".\n\nBreakpoint 1, builtin_id (self=, v=42) at /builddir/build/BUILD/Python-3.8.2/Python/bltinmodule.c:1171\n1171\t{\n#4 (frame information optimized out)\n#10 (frame information optimized out)\n' did not match '.*\\na = 1\\nb = 2\\nc = 3\\n.*'
----------------------------------------------------------------------
Ran 46 tests in 144.929s

Comment 1 Victor Stinner 2020-03-31 17:17:20 UTC
I validated with success that backporting my https://bugs.python.org/issue40019 change to 3.8 fix test_gdb on s390x and armv7hl.

See my PR https://src.fedoraproject.org/rpms/python3/pull-request/182 created to test that.

I backported my fix upstream from master to Python 3.7 and 3.8: https://bugs.python.org/issue40019.

This change only fix test_gdb. To get a fully working python-gdb.py, IMHO the best is to disable all compiler optimization using -O0 optimization level.

Comment 2 Charalampos Stratakis 2020-05-27 12:25:15 UTC
We need to not skip the test in the SPEC

Comment 3 Victor Stinner 2020-05-27 12:29:50 UTC
Python 3.8.3 has my fix https://github.com/python/cpython/commit/4ced9a7611ddfd923bd8f72aa61121d0e5aeb8fc

We can try to reenable test_gdb python3.9 package, and maybe also python 3.8 package.

Comment 4 Victor Stinner 2020-05-27 12:36:10 UTC
I created https://src.fedoraproject.org/rpms/python3.8/pull-request/1 to reenable test_gdb in python3.8. Let's see how it goes in CIs.

Comment 6 Miro Hrončok 2020-06-24 13:03:44 UTC
Let's build debug with -O0.

Comment 7 Petr Viktorin (pviktori) 2020-07-08 12:23:42 UTC
*** Bug 1846390 has been marked as a duplicate of this bug. ***

Comment 8 Victor Stinner 2020-08-10 14:48:19 UTC
FYI I modified test_gdb to skip it on gdb 9.2 and newer to work around a gdb issue:

* https://bugs.python.org/issue41473
* https://bugzilla.redhat.com/show_bug.cgi?id=1866884

"AArch64: sometimes, gdb fails to load symbols of a dynamic library with a pending breakpoint"

Fedora Rawhide is affected by the gdb issue.

Comment 9 Ben Cotton 2020-08-11 13:15:50 UTC
This bug appears to have been reported against 'rawhide' during the Fedora 33 development cycle.
Changing version to 33.

Comment 10 Miro Hrončok 2020-08-20 16:16:14 UTC
So if we simply change -Og with -O0, we get warnings like this:

In file included from /usr/include/bits/libc-header-start.h:33,
                 from /usr/include/limits.h:26,
                 from /usr/lib/gcc/x86_64-redhat-linux/10/include/limits.h:195,
                 from /usr/lib/gcc/x86_64-redhat-linux/10/include/syslimits.h:7,
                 from /usr/lib/gcc/x86_64-redhat-linux/10/include/limits.h:34,
                 from /builddir/build/BUILD/Python-3.9.0rc1/Include/Python.h:11,
                 from /builddir/build/BUILD/Python-3.9.0rc1/Programs/_freeze_importlib.c:5:
/usr/include/features.h:397:4: warning: #warning _FORTIFY_SOURCE requires compiling with optimization (-O) [-Wcpp]
  397 | #  warning _FORTIFY_SOURCE requires compiling with optimization (-O)
      |    ^~~~~~~


If we add -Wp,-D_FORTIFY_SOURCE=0, we have warnings like this:

<command-line>: warning: "_FORTIFY_SOURCE" redefined
<command-line>: note: this is the location of the previous definition
<command-line>: warning: "_FORTIFY_SOURCE" redefined
<command-line>: note: this is the location of the previous definition
<command-line>: warning: "_FORTIFY_SOURCE" redefined
<command-line>: note: this is the location of the previous definition


More over, even if we replace the FORTIFY_SOURCE value with some sed magic, annobin warns as well:

annobin: /builddir/build/BUILD/Python-3.9.0rc1/Programs/_freeze_importlib.c: Warning: -D_FORTIFY_SOURCE defined as 0


I suppose we will always get a warning of some sort anyway, one way it to use -Wno-cpp with the debug build. WDYT?

Comment 11 Victor Stinner 2020-08-20 16:27:53 UTC
> More over, even if we replace the FORTIFY_SOURCE value with some sed magic, annobin warns as well: (...)

Is it possible to tell annobin to ignore -D_FORTIFY_SOURCE?

Comment 12 Miro Hrončok 2020-08-20 16:36:17 UTC
I don't know.

Comment 13 Petr Viktorin (pviktori) 2020-10-13 09:07:11 UTC
Here is a PR: https://src.fedoraproject.org/rpms/python3.9/pull-request/30

Comment 14 Petr Viktorin (pviktori) 2020-11-24 10:07:24 UTC
test_gdb is skipped upstream. Compiling with -Og doesn't fix it even in versions where it isn't skipped.
Restoring test_gdb should be done upstream before we do this.

Comment 15 Victor Stinner 2020-12-04 15:30:31 UTC
https://bugzilla.redhat.com/show_bug.cgi?id=1866884 has been fixed (gdb 10.1).

I reenabled test_gdb on gdb 9.2+ on Python upstream: https://github.com/python/cpython/commit/066394018a8463643cc63d933493f0afa99d72cc

I move the issue statuc back to NEW even if there is a (closed) PR: https://src.fedoraproject.org/rpms/python3.9/pull-request/30

Comment 16 Victor Stinner 2021-01-29 15:49:39 UTC
Woooot, thanks, that's a major enhancement to make gdb usable on python3.9-debug! No make "optimized out" issue which prevent to inspect anything ;-)


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