This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: Unit test failure in test_gdb only with -O0
Type: behavior Stage: needs patch
Components: Library (Lib) Versions: Python 3.10
process
Status: open Resolution:
Dependencies: Superseder:
Assigned To: Nosy List: larry, pablogsal, skip.montanaro
Priority: normal Keywords: 3.10regression

Created on 2021-04-26 05:02 by larry, last changed 2022-04-11 14:59 by admin.

Files
File name Uploaded Description Edit
test_gdb.out skip.montanaro, 2021-07-07 20:45
Messages (9)
msg391878 - (view) Author: Larry Hastings (larry) * (Python committer) Date: 2021-04-26 05:02
Recent Python source trees fail a regression test in test_gdb.  Oddly, the behavior only appears up when optimization is turned off.

To reproduce:

% git clone cpython buildtrunk
% cd buildtrunk
% ./configure
% vi Makefile  # change "-O3" to "-O0" !!
% make -j
% ./python -m test -v test_gdb

You'll be rewarded with one failure:

======================================================================
FAIL: test_wrapper_call (test.test_gdb.PyBtTests)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/larry/src/python/buildtrunk/Lib/test/test_gdb.py", line 947, in test_wrapper_call
    self.assertRegex(gdb_output,
AssertionError: Regex didn't match: "<method-wrapper u?'__init__' of MyList object at " not found in 'Breakpoint 1 at 0x281f5a: file Python/bltinmodule.c, line 1207.\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 (self=<cfunction_enter_call+35>, v=<unknown at remote 0x7fffffffc7b0>) at Python/bltinmodule.c:1207\n1207\t{\nBreakpoint 2: file Objects/descrobject.c, line 1386.\n\nBreakpoint 2, wrapper_call (wp=<unknown at remote 0x555555973820>, args=<unknown at remote 0x55555581dee8>, kwds=<unknown at remote 0x5555555bde85>) at Objects/descrobject.c:1386\n1386\t{\nTraceback (most recent call first):\n  <unknown at remote 0x555555973820>\n  File "<string>", line 4, in __init__\n  File "<string>", line 7, in <module>\n'

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

I just reproduced this with version 3c4850e222388889426e250ff43308e4802dc582 .  Note that if you don't change the Makefile, and leave the optimization level at "-O3", you won't see this test failure.

Pablo, I nosied you just to get it on your radar.  Good luck with getting Python 3.10 over the finish line!
msg392063 - (view) Author: Pablo Galindo Salgado (pablogsal) * (Python committer) Date: 2021-04-27 12:36
Thanks, Larry for pinging me!

What compiler / gdb version are you using?

I tried to reproduce but I don't see any failure:

master on  master [$]  pyenv 3.9.1 took 9s
❯ ./python -m sysconfig | grep CFLAGS
        BASECFLAGS = "-Wno-unused-result -Wsign-compare"
        CFLAGS = "-Wno-unused-result -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall -g3 -O0 -g3 -O0"
        CFLAGSFORSHARED = ""
        CFLAGS_ALIASING = ""
        CFLAGS_NODIST = ""
        CONFIGURE_CFLAGS = "-g3 -O0"
        CONFIGURE_CFLAGS_NODIST = "-std=c99 -Wextra -Wno-unused-result -Wno-unused-parameter -Wno-missing-field-initializers -Werror=implicit-function-declaration -fvisibility=hidden"
        CONFIG_ARGS = "'-C' 'CFLAGS=-g3 -O0'"
        EXTRA_CFLAGS = ""
        PY_BUILTIN_MODULE_CFLAGS = "-Wno-unused-result -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall -g3 -O0 -g3 -O0 -std=c99 -Wextra -Wno-unused-result -Wno-unused-parameter -Wno-missing-field-initializers -Werror=implicit-function-declaration -fvisibility=hidden  -I./Include/internal -I. -I./Include -DPy_BUILD_CORE_BUILTIN"
        PY_CFLAGS = "-Wno-unused-result -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall -g3 -O0 -g3 -O0"
        PY_CFLAGS_NODIST = "-std=c99 -Wextra -Wno-unused-result -Wno-unused-parameter -Wno-missing-field-initializers -Werror=implicit-function-declaration -fvisibility=hidden  -I./Include/internal"
        PY_CORE_CFLAGS = "-Wno-unused-result -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall -g3 -O0 -g3 -O0 -std=c99 -Wextra -Wno-unused-result -Wno-unused-parameter -Wno-missing-field-initializers -Werror=implicit-function-declaration -fvisibility=hidden  -I./Include/internal -I. -I./Include -DPy_BUILD_CORE"
        PY_STDMODULE_CFLAGS = "-Wno-unused-result -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall -g3 -O0 -g3 -O0 -std=c99 -Wextra -Wno-unused-result -Wno-unused-parameter -Wno-missing-field-initializers -Werror=implicit-function-declaration -fvisibility=hidden  -I./Include/internal -I. -I./Include"

master on  master [$]  pyenv 3.9.1
❯ ./python -m test test_gdb -m test_wrapper_call -v
== CPython 3.10.0a7+ (heads/master:d92513390a, Apr 27 2021, 13:20:32) [GCC 10.2.0]
== Linux-5.11.16-arch1-1-x86_64-with-glibc2.33 little-endian
== cwd: /home/pablogsal/github/python/master/build/test_python_27393æ
== CPU count: 36
== encodings: locale=UTF-8, FS=utf-8
0:00:00 load avg: 1.47 Run tests sequentially
0:00:00 load avg: 1.47 [1/1] test_gdb
GDB version 10.1:
    GNU gdb (GDB) 10.1
    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_wrapper_call (test.test_gdb.PyBtTests) ... ok

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

Ran 1 test in 8.752s

OK

== Tests result: SUCCESS ==

1 test OK.

Total duration: 9.2 sec
Tests result: SUCCESS


These are my versions:

❯ gcc --version
gcc (GCC) 10.2.0
Copyright (C) 2020 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.


master on  master [$]  pyenv 3.9.1
❯ gdb --version
GNU gdb (GDB) 10.1
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.
msg392064 - (view) Author: Larry Hastings (larry) * (Python committer) Date: 2021-04-27 12:40
I'm on "Pop!_OS 20.10".  Current versions:

* Linux kernel 5.11.0-7612
* gcc version 10.2.0 (Ubuntu 10.2.0-13ubuntu1)
* GNU gdb (Ubuntu 9.2-0ubuntu2) 9.2


% ./python -m sysconfig | grep CFLAGS
        BASECFLAGS = "-Wno-unused-result -Wsign-compare"
        CFLAGS = "-Wno-unused-result -Wsign-compare -DNDEBUG -g -fwrapv -O0 -Wall"
        CFLAGSFORSHARED = ""
        CFLAGS_ALIASING = ""
        CFLAGS_NODIST = ""
        CONFIGURE_CFLAGS = ""
        CONFIGURE_CFLAGS_NODIST = "-std=c99 -Wextra -Wno-unused-result -Wno-unused-parameter -Wno-missing-field-initializers -Werror=implicit-function-declaration -fvisibility=hidden"
        EXTRA_CFLAGS = ""
        PY_BUILTIN_MODULE_CFLAGS = "-Wno-unused-result -Wsign-compare -DNDEBUG -g -fwrapv -O0 -Wall -std=c99 -Wextra -Wno-unused-result -Wno-unused-parameter -Wno-missing-field-initializers -Werror=implicit-function-declaration -fvisibility=hidden  -I./Include/internal -I. -I./Include -DPy_BUILD_CORE_BUILTIN"
        PY_CFLAGS = "-Wno-unused-result -Wsign-compare -DNDEBUG -g -fwrapv -O0 -Wall"
        PY_CFLAGS_NODIST = "-std=c99 -Wextra -Wno-unused-result -Wno-unused-parameter -Wno-missing-field-initializers -Werror=implicit-function-declaration -fvisibility=hidden  -I./Include/internal"
        PY_CORE_CFLAGS = "-Wno-unused-result -Wsign-compare -DNDEBUG -g -fwrapv -O0 -Wall -std=c99 -Wextra -Wno-unused-result -Wno-unused-parameter -Wno-missing-field-initializers -Werror=implicit-function-declaration -fvisibility=hidden  -I./Include/internal -I. -I./Include -DPy_BUILD_CORE"
        PY_STDMODULE_CFLAGS = "-Wno-unused-result -Wsign-compare -DNDEBUG -g -fwrapv -O0 -Wall -std=c99 -Wextra -Wno-unused-result -Wno-unused-parameter -Wno-missing-field-initializers -Werror=implicit-function-declaration -fvisibility=hidden  -I./Include/internal -I. -I./Include"
msg392067 - (view) Author: Pablo Galindo Salgado (pablogsal) * (Python committer) Date: 2021-04-27 12:54
Can you try to do this:

% make distclean
% export CFLAGS='-O0 -g3'
% ./configure
% make -j
% ./python -m test test_gdb -m test_wrapper_call -v

My guess is that the DWARF generated is not sufficient for whatever reason (hence the -g3) in my proposal.
msg392068 - (view) Author: Larry Hastings (larry) * (Python committer) Date: 2021-04-27 13:01
Did that.  Well, technically, I replaced two lines with the equivalent:
% CFLAGS='-O0 -g3' ./configure

I do see this in the Makefile:
    CONFIGURE_CFLAGS=       -O0 -g3
so, I didn't screw it up!


The test still failed:

=====================================================================
FAIL: test_wrapper_call (test.test_gdb.PyBtTests)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/larry/src/python/buildtrunk/Lib/test/test_gdb.py", line 947, in test_wrapper_call
    self.assertRegex(gdb_output,
AssertionError: Regex didn't match: "<method-wrapper u?'__init__' of MyList object at " not found in 'Breakpoint 1 at 0x281f5a: file Python/bltinmodule.c, line 1207.\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 (self=<cfunction_enter_call+35>, v=<unknown at remote 0x7fffffffc7b0>) at Python/bltinmodule.c:1207\n1207\t{\nBreakpoint 2: file Objects/descrobject.c, line 1386.\n\nBreakpoint 2, wrapper_call (wp=<unknown at remote 0x555555973820>, args=<unknown at remote 0x55555581dee8>, kwds=<unknown at remote 0x5555555bde85>) at Objects/descrobject.c:1386\n1386\t{\nTraceback (most recent call first):\n  <unknown at remote 0x555555973820>\n  File "<string>", line 4, in __init__\n  File "<string>", line 7, in <module>\n'

----------------------------------------------------------------------
msg392072 - (view) Author: Pablo Galindo Salgado (pablogsal) * (Python committer) Date: 2021-04-27 13:46
I will try to reproduce this in other systems this afternoon. I trust that this fails, but we must know exactly what triggers this first.
msg397115 - (view) Author: Skip Montanaro (skip.montanaro) * (Python triager) Date: 2021-07-07 20:45
I routinely build with -O0 and have been getting test_gdb failures building the 3.10 branch. I tried adding -g3 to my configure flags:

nice ./configure OPT="-O0 -g3 -Wall" --with-pydebug --with-trace-refs

but test_gdb still fails. Output attached. Note that I have been getting CRC mismatches between a couple files. They are copious in the test output, so I won't elaborate here.
msg397120 - (view) Author: Pablo Galindo Salgado (pablogsal) * (Python committer) Date: 2021-07-07 22:31
Skip: I am still unable to reproduce in my machine unfortunately. Could you maybe bisect the failures if you can reliably reproduce the problem so we can at least narrow it down to one commit?
msg397121 - (view) Author: Skip Montanaro (skip.montanaro) * (Python triager) Date: 2021-07-07 23:03
Unfortunately, I'm currently not able to build Python 3.8, 3.9 or 3.10 and get a non-failing test_gdb. I'll mess around a bit more, but I'm skeptical I'll find something simple. (I wonder if something changed in GDB which is causing the failure.)
History
Date User Action Args
2022-04-11 14:59:44adminsetgithub: 88107
2021-07-07 23:03:14skip.montanarosetmessages: + msg397121
2021-07-07 22:31:32pablogsalsetmessages: + msg397120
2021-07-07 20:45:59skip.montanarosetfiles: + test_gdb.out
nosy: + skip.montanaro
messages: + msg397115

2021-04-27 13:46:45pablogsalsetmessages: + msg392072
2021-04-27 13:01:58larrysetmessages: + msg392068
2021-04-27 12:54:23pablogsalsetmessages: + msg392067
2021-04-27 12:40:39larrysetmessages: + msg392064
2021-04-27 12:36:22pablogsalsetmessages: + msg392063
2021-04-26 05:02:16larrycreate