Repository navigation
Closed
Description
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:
assignee = None
closed_at = <Date 2018-10-10.10:55:19.914>
created_at = <Date 2018-02-27.09:02:47.068>
labels = ['3.8', '3.7', 'tests']
title = 'test_gdb fails in debug build with `-mcet -fcf-protection -O0`'
updated_at = <Date 2018-10-10.10:55:19.911>
user = 'https://github.com/irushchyshyn'bugs.python.org fields:
activity = <Date 2018-10-10.10:55:19.911>
actor = 'vstinner'
assignee = 'none'
closed = True
closed_date = <Date 2018-10-10.10:55:19.914>
closer = 'vstinner'
components = ['Tests']
creation = <Date 2018-02-27.09:02:47.068>
creator = 'ishcherb'
dependencies = []
files = []
hgrepos = []
issue_num = 32962
keywords = ['patch']
message_count = 29.0
messages = ['312985', '317851', '319518', '319538', '319546', '319547', '319549', '319624', '319626', '319630', '319669', '319671', '319672', '319674', '319675', '319679', '319888', '319909', '319918', '319920', '319929', '319930', '327406', '327411', '327414', '327417', '327418', '327465', '327466']
nosy_count = 7.0
nosy_names = ['vstinner', 'serhiy.storchaka', 'cstratak', 'ishcherb', 'Dormouse759', 'pablogsal', 'miss-islington']
pr_nums = ['6754', '7692', '7693', '7710', '7711', '7723', '7724', '7725', '7726', '9656', '9770', '9771', '9788']
priority = 'normal'
resolution = 'fixed'
stage = 'resolved'
status = 'closed'
superseder = None
type = None
url = 'https://bugs.python.org/issue32962'
versions = ['Python 2.7', 'Python 3.6', 'Python 3.7', 'Python 3.8']
Activity
irushchyshyn commentedon Feb 27, 2018
test_gdb fails on Fedora 28. This happens only in debug build, and only if built with control flow protection flags:
-mcet -fcf-protectionAND optimization-O0.Reproduction steps on Fedora 28 (x86_64):
./configure --with-pydebug
make 'EXTRA_CFLAGS=-mcet -fcf-protection -O0'
make test TESTOPTS='-v test_gdb'
Actual result:
Re-running test 'test_gdb' in verbose mode
GDB version 8.1:
GNU gdb (GDB) Fedora 8.1-8.fc28
Copyright (C) 2018 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. Type "show copying"
and "show warranty" for details.
This GDB was configured as "x86_64-redhat-linux-gnu".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/\>.
Find the GDB manual and other documentation resources online at:
<http://www.gnu.org/software/gdb/documentation/\>.
For help, type "help".
Type "apropos word" to search for commands related to "word".
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) ... FAIL
test_builtins_help (test.test_gdb.PrettyPrintTests)
Ensure that the new-style class _Helper in site.py can be handled ... FAIL
test_bytes (test.test_gdb.PrettyPrintTests)
Verify the pretty-printing of bytes ... FAIL
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 ... FAIL
test_exceptions (test.test_gdb.PrettyPrintTests) ... FAIL
test_frames (test.test_gdb.PrettyPrintTests) ... FAIL
test_frozensets (test.test_gdb.PrettyPrintTests)
Verify the pretty-printing of frozensets ... FAIL
test_getting_backtrace (test.test_gdb.PrettyPrintTests) ... ok
test_int (test.test_gdb.PrettyPrintTests)
Verify the pretty-printing of various int values ... FAIL
test_lists (test.test_gdb.PrettyPrintTests)
Verify the pretty-printing of lists ... FAIL
test_modern_class (test.test_gdb.PrettyPrintTests)
Verify the pretty-printing of new-style class instances ... FAIL
test_selfreferential_dict (test.test_gdb.PrettyPrintTests)
Ensure that a reference loop involving a dict doesn't lead proxyval ... FAIL
test_selfreferential_list (test.test_gdb.PrettyPrintTests)
Ensure that a reference loop involving a list doesn't lead proxyval ... FAIL
test_selfreferential_new_style_instance (test.test_gdb.PrettyPrintTests) ... FAIL
test_selfreferential_old_style_instance (test.test_gdb.PrettyPrintTests) ... FAIL
test_sets (test.test_gdb.PrettyPrintTests)
Verify the pretty-printing of sets ... FAIL
test_singletons (test.test_gdb.PrettyPrintTests)
Verify the pretty-printing of True, False and None ... FAIL
test_strings (test.test_gdb.PrettyPrintTests)
Verify the pretty-printing of unicode strings ... FAIL
test_subclassing_list (test.test_gdb.PrettyPrintTests)
Verify the pretty-printing of an instance of a list subclass ... FAIL
test_subclassing_tuple (test.test_gdb.PrettyPrintTests)
Verify the pretty-printing of an instance of a tuple subclass ... FAIL
test_truncation (test.test_gdb.PrettyPrintTests)
Verify that very long output is truncated ... FAIL
test_tuples (test.test_gdb.PrettyPrintTests)
Verify the pretty-printing of tuples ... FAIL
test_basic_command (test.test_gdb.PyListTests)
Verify that the "py-list" command works ... FAIL
test_one_abs_arg (test.test_gdb.PyListTests)
Verify the "py-list" command with one absolute argument ... FAIL
test_two_abs_args (test.test_gdb.PyListTests)
Verify the "py-list" command with two absolute arguments ... FAIL
test_down_at_bottom (test.test_gdb.StackNavigationTests)
Verify handling of "py-down" at the bottom of the stack ... FAIL
test_pyup_command (test.test_gdb.StackNavigationTests)
Verify that the "py-up" command works ... FAIL
test_up_at_top (test.test_gdb.StackNavigationTests)
Verify handling of "py-up" at the top of the stack ... FAIL
test_up_then_down (test.test_gdb.StackNavigationTests)
Verify "py-up" followed by "py-down" ... FAIL
test_bt (test.test_gdb.PyBtTests)
Verify that the "py-bt" command works ... FAIL
test_bt_full (test.test_gdb.PyBtTests)
Verify that the "py-bt-full" command works ... FAIL
test_gc (test.test_gdb.PyBtTests)
Verify that "py-bt" indicates if a thread is garbage-collecting ... ok
test_pycfunction (test.test_gdb.PyBtTests)
Verify that "py-bt" displays invocations of PyCFunction instances ... ok
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) ... FAIL
test_basic_command (test.test_gdb.PyPrintTests)
Verify that the "py-print" command works ... FAIL
test_print_after_up (test.test_gdb.PyPrintTests) ... FAIL
test_printing_builtin (test.test_gdb.PyPrintTests) ... FAIL
test_printing_global (test.test_gdb.PyPrintTests) ... FAIL
test_basic_command (test.test_gdb.PyLocalsTests) ... FAIL
test_locals_after_up (test.test_gdb.PyLocalsTests) ... FAIL
======================================================================
FAIL: test_builtin_method (test.test_gdb.PrettyPrintTests)
----------------------------------------------------------------------
======================================================================
FAIL: test_builtins_help (test.test_gdb.PrettyPrintTests)
Ensure that the new-style class _Helper in site.py can be handled
----------------------------------------------------------------------
======================================================================
FAIL: test_bytes (test.test_gdb.PrettyPrintTests)
Verify the pretty-printing of bytes
----------------------------------------------------------------------
======================================================================
FAIL: test_dicts (test.test_gdb.PrettyPrintTests)
Verify the pretty-printing of dictionaries
----------------------------------------------------------------------
======================================================================
FAIL: test_exceptions (test.test_gdb.PrettyPrintTests)
----------------------------------------------------------------------
Traceback (most recent call last): File "/builddir/build/BUILD/Python-3.6.4/Lib/test/test_gdb.py", line 393, in test_exceptions ''') File "/builddir/build/BUILD/Python-3.6.4/Lib/test/test_gdb.py", line 241, in get_gdb_repr import_site=import_site) File "/builddir/build/BUILD/Python-3.6.4/Lib/test/test_gdb.py", line 219, in get_stack_trace self.assertEqual(unexpected_errlines, []) AssertionError: Lists differ: ["Python Exception <class 'UnicodeDecodeEr[197 chars]e: "] != [] First list contains 2 additional elements. First extra element 0: "Python Exception <class 'UnicodeDecodeError'> 'utf-8' codec can't decode byte 0xb0 in position 0: invalid start byte: " + [] - ["Python Exception <class 'UnicodeDecodeError'> 'utf-8' codec can't decode " - 'byte 0xb0 in position 0: invalid start byte: ', - "Python Exception <class 'UnicodeDecodeError'> 'utf-8' codec can't decode " - 'byte 0xb0 in position 0: invalid start byte: ']======================================================================
FAIL: test_frames (test.test_gdb.PrettyPrintTests)
----------------------------------------------------------------------
======================================================================
FAIL: test_frozensets (test.test_gdb.PrettyPrintTests)
Verify the pretty-printing of frozensets
----------------------------------------------------------------------
======================================================================
FAIL: test_int (test.test_gdb.PrettyPrintTests)
Verify the pretty-printing of various int values
----------------------------------------------------------------------
======================================================================
FAIL: test_lists (test.test_gdb.PrettyPrintTests)
Verify the pretty-printing of lists
----------------------------------------------------------------------
======================================================================
FAIL: test_modern_class (test.test_gdb.PrettyPrintTests)
Verify the pretty-printing of new-style class instances
----------------------------------------------------------------------
======================================================================
FAIL: test_selfreferential_dict (test.test_gdb.PrettyPrintTests)
Ensure that a reference loop involving a dict doesn't lead proxyval
----------------------------------------------------------------------
Traceback (most recent call last): File "/builddir/build/BUILD/Python-3.6.4/Lib/test/test_gdb.py", line 542, in test_selfreferential_dict self.assertEqual(gdb_repr, "{'foo': {'bar': {...}}}") AssertionError: "<CodecInfo(name='utf-8', encode=<built-in[326 chars]3b8>" != "{'foo': {'bar': {...}}}" - <CodecInfo(name='utf-8', encode=<built-in method utf_8_encode of module object at remote 0x7ffff7e87ad8>, decode=<function at remote 0x7ffff7e19560>, incrementalencoder=<type at remote 0x5555557b26e8>, incrementaldecoder=<type at remote 0x5555557b2ae8>, streamwriter=<type at remote 0x5555557b2ee8>, streamreader=<type at remote 0x5555557b32e8>) at remote 0x7ffff7e7e3b8> + {'foo': {'bar': {...}}}======================================================================
FAIL: test_selfreferential_list (test.test_gdb.PrettyPrintTests)
Ensure that a reference loop involving a list doesn't lead proxyval
----------------------------------------------------------------------
Traceback (most recent call last): File "/builddir/build/BUILD/Python-3.6.4/Lib/test/test_gdb.py", line 530, in test_selfreferential_list self.assertEqual(gdb_repr, '[3, 4, 5, [...]]') AssertionError: '<unknown at remote 0xf7e4a1a8>' != '[3, 4, 5, [...]]' - <unknown at remote 0xf7e4a1a8> + [3, 4, 5, [...]]======================================================================
FAIL: test_selfreferential_new_style_instance (test.test_gdb.PrettyPrintTests)
----------------------------------------------------------------------
======================================================================
FAIL: test_selfreferential_old_style_instance (test.test_gdb.PrettyPrintTests)
----------------------------------------------------------------------
======================================================================
FAIL: test_sets (test.test_gdb.PrettyPrintTests)
Verify the pretty-printing of sets
----------------------------------------------------------------------
======================================================================
FAIL: test_singletons (test.test_gdb.PrettyPrintTests)
Verify the pretty-printing of True, False and None
----------------------------------------------------------------------
======================================================================
FAIL: test_strings (test.test_gdb.PrettyPrintTests)
Verify the pretty-printing of unicode strings
----------------------------------------------------------------------
======================================================================
FAIL: test_subclassing_list (test.test_gdb.PrettyPrintTests)
Verify the pretty-printing of an instance of a list subclass
----------------------------------------------------------------------
======================================================================
FAIL: test_subclassing_tuple (test.test_gdb.PrettyPrintTests)
Verify the pretty-printing of an instance of a tuple subclass
----------------------------------------------------------------------
======================================================================
FAIL: test_truncation (test.test_gdb.PrettyPrintTests)
Verify that very long output is truncated
----------------------------------------------------------------------
======================================================================
FAIL: test_tuples (test.test_gdb.PrettyPrintTests)
Verify the pretty-printing of tuples
----------------------------------------------------------------------
======================================================================
FAIL: test_basic_command (test.test_gdb.PyListTests)
Verify that the "py-list" command works
----------------------------------------------------------------------
======================================================================
FAIL: test_one_abs_arg (test.test_gdb.PyListTests)
Verify the "py-list" command with one absolute argument
----------------------------------------------------------------------
======================================================================
FAIL: test_two_abs_args (test.test_gdb.PyListTests)
Verify the "py-list" command with two absolute arguments
----------------------------------------------------------------------
======================================================================
FAIL: test_down_at_bottom (test.test_gdb.StackNavigationTests)
Verify handling of "py-down" at the bottom of the stack
----------------------------------------------------------------------
======================================================================
FAIL: test_pyup_command (test.test_gdb.StackNavigationTests)
Verify that the "py-up" command works
----------------------------------------------------------------------
======================================================================
FAIL: test_up_at_top (test.test_gdb.StackNavigationTests)
Verify handling of "py-up" at the top of the stack
----------------------------------------------------------------------
======================================================================
FAIL: test_up_then_down (test.test_gdb.StackNavigationTests)
Verify "py-up" followed by "py-down"
----------------------------------------------------------------------
======================================================================
FAIL: test_bt (test.test_gdb.PyBtTests)
Verify that the "py-bt" command works
----------------------------------------------------------------------
======================================================================
FAIL: test_bt_full (test.test_gdb.PyBtTests)
Verify that the "py-bt-full" command works
----------------------------------------------------------------------
======================================================================
FAIL: test_wrapper_call (test.test_gdb.PyBtTests)
----------------------------------------------------------------------
======================================================================
FAIL: test_basic_command (test.test_gdb.PyPrintTests)
Verify that the "py-print" command works
----------------------------------------------------------------------
======================================================================
FAIL: test_print_after_up (test.test_gdb.PyPrintTests)
----------------------------------------------------------------------
======================================================================
FAIL: test_printing_builtin (test.test_gdb.PyPrintTests)
----------------------------------------------------------------------
======================================================================
FAIL: test_printing_global (test.test_gdb.PyPrintTests)test test_gdb failed
----------------------------------------------------------------------
======================================================================
FAIL: test_basic_command (test.test_gdb.PyLocalsTests)
----------------------------------------------------------------------
======================================================================
FAIL: test_locals_after_up (test.test_gdb.PyLocalsTests)
----------------------------------------------------------------------
Ran 46 tests in 20.175s
FAILED (failures=37)
1 test failed again:
test_gdb
Total duration: 29 min 42 sec
Tests result: FAILURE
Expected result: no failures
Original bug report: https://bugzilla.redhat.com/show_bug.cgi?id=1541967
stratakis commentedon May 28, 2018
Ping. Could someone take a look? There is a PR ready.
vstinner commentedon Jun 14, 2018
New changeset 019d33b by Victor Stinner in branch 'master':
bpo-32962: python-gdb catchs ValueError on read_var() (GH-7692)
019d33b
serhiy-storchaka commentedon Jun 14, 2018
Wouldn't be better to use the "surrogateescape" or the "backslashreplace" error handlers?
vstinner commentedon Jun 14, 2018
Are you talking about my #7693 fix? If yes, the error comes from the string() method which comes from the gdb API. I don't see how to control how gdb decodes bytes.
vstinner commentedon Jun 14, 2018
New changeset d22fc0b by Victor Stinner in branch 'master':
bpo-32962: python-gdb catchs UnicodeDecodeError (GH-7693)
d22fc0b
vstinner commentedon Jun 14, 2018
Reminder: test_gdb is skipped on Travis CI and AppVeyor. I tested my two changes manually. I will backport python-gdb.py enhancements to other branches once PR 6754 fix will be merged.
vstinner commentedon Jun 15, 2018
New changeset 9b7c74c by Victor Stinner (Marcel Plch) in branch 'master':
bpo-32962: Fix test_gdb failure in debug build with -mcet -fcf-protection -O0 (bpo-6754)
9b7c74c
vstinner commentedon Jun 15, 2018
New changeset ca4cb84 by Victor Stinner in branch '3.7':
[3.7] bpo-32962: Backport python-gdb.py and test_gdb.py from master (GH-7710)
ca4cb84
vstinner commentedon Jun 15, 2018
New changeset 5279759 by Victor Stinner in branch '3.6':
bpo-32962: Backport python-gdb.py and test_gdb.py from master (GH-7710) (GH-7711)
5279759
vstinner commentedon Jun 15, 2018
Oh :-( The change caused two buildbot failures, so I wrote PR 7723 to revert it.
x86 Gentoo Non-Debug with X 3.x:
http://buildbot.python.org/all/#/builders/99/builds/1095
======================================================================
FAIL: test_NULL_ptr (test.test_gdb.PrettyPrintTests)
Ensure that a NULL PyObject* is handled gracefully
----------------------------------------------------------------------
First list contains 1 additional elements.
First extra element 0:
'No symbol "v" in current context.'
+ []
======================================================================
FAIL: test_builtins_help (test.test_gdb.PrettyPrintTests)
Ensure that the new-style class _Helper in site.py can be handled
----------------------------------------------------------------------
Breakpoint 1, builtin_id (self=, v=<_Helper at remote 0xb796c2ec>) at Python/bltinmodule.c:1204
1204 {
__x86.get_pc_thunk.bx ()
#0 __x86.get_pc_thunk.bx ()
======================================================================
FAIL: test_up_at_top (test.test_gdb.StackNavigationTests)
Verify handling of "py-up" at the top of the stack
----------------------------------------------------------------------
AMD64 Debian PGO 3.x:
http://buildbot.python.org/all/#/builders/47/builds/1173
======================================================================
FAIL: test_tuples (test.test_gdb.PrettyPrintTests)
Verify the pretty-printing of tuples
----------------------------------------------------------------------
Breakpoint 1, builtin_id (self=, v=()) at Python/bltinmodule.c:1205
1205 return PyLong_FromVoidPtr(v);
PyLong_FromVoidPtr () at Objects/longobject.c:1021
1021 {
#0 PyLong_FromVoidPtr () at Objects/longobject.c:1021
vstinner commentedon Jun 15, 2018
It seems to only be related to this change:
"""
New changeset 9b7c74c by Victor Stinner (Marcel Plch) in branch 'master':
bpo-32962: Fix test_gdb failure in debug build with -mcet -fcf-protection -O0 (bpo-6754)
9b7c74c
"""
Since I also backported this change to 3.7 and 3.6, buildbot of 3.7 and 3.6 also failed:
AMD64 Debian PGO 3.7
http://buildbot.python.org/all/#builders/128/builds/417
AMD64 Debian PGO 3.6
http://buildbot.python.org/all/#builders/77/builds/419
x86 Gentoo Non-Debug with X 3.7
http://buildbot.python.org/all/#builders/115/builds/365
vstinner commentedon Jun 15, 2018
New changeset 2f9cbaa by Victor Stinner in branch 'master':
Revert "bpo-32962: Fix test_gdb failure in debug build with -mcet -fcf-protection -O0 (GH-6754)" (bpo-7723)
2f9cbaa
vstinner commentedon Jun 15, 2018
New changeset 74565aa by Victor Stinner in branch '3.6':
Revert "bpo-32962: Fix test_gdb failure in debug build with -mcet -fcf-protection -O0 (GH-6754)" (bpo-7725)
74565aa
4 remaining items
vstinner commentedon Jun 18, 2018
It's already done, no? But the title issue is "-mcet -fcf-protection
-O0" and -O0 disables optimizations.
vstinner commentedon Jun 18, 2018
Related issue: bpo-31237.
Dormouse759 commentedon Jun 19, 2018
Some of the simple tests are still run even with optimizations.
Disabled optimizations is what we want, because then the function doesn't get inlined --> the 'next' jumps in, not out.
vstinner commentedon Jun 19, 2018
Oh I see. But currently, many test_gdb tests pass even with optimization. I dislike reducing the test coverage when Python is compiled with optimizations, just to support -mcet -fcf-protection.
Would it be possible to detect the special case "-mcet -fcf-protection" *and* optimizations, and only skip test_gdb in that case?
vstinner commentedon Oct 9, 2018
More info about -fcf-protection=full -mcet:
"Enable control flow protection on x86-64 using -fcf-protection=full -mcet."
https://fedoraproject.org/wiki/Changes/HardeningFlags28
man gcc:
vstinner commentedon Oct 9, 2018
I tested the following configurations on my Fedora 28:
./configure --with-pydebug CFLAGS=-O0 -mcet -fcf-protection
./configure CFLAGS=-mcet -fcf-protection
./configure --with-pydebug CFLAGS=-O0 -mcet -fcf-protection=none
./configure CFLAGS=-mcet -fcf-protection=none
./configure --with-pydebug CFLAGS=-O0 -mcet -fcf-protection=branch
./configure CFLAGS=-mcet -fcf-protection=branch
./configure --with-pydebug CFLAGS=-O0 -mcet -fcf-protection=return
./configure CFLAGS=-mcet -fcf-protection=return
./configure --with-pydebug CFLAGS=-O0 -mcet -fcf-protection=full
./configure CFLAGS=-mcet -fcf-protection=full
test_gdb now pass with all these configurations
vstinner commentedon Oct 9, 2018
New changeset 79d2133 by Victor Stinner in branch 'master':
bpo-32962: Fix test_gdb failure in debug build with -mcet -fcf-protection -O0 (GH-9656)
79d2133
miss-islington commentedon Oct 9, 2018
New changeset 25bfb1a by Miss Islington (bot) in branch '3.6':
bpo-32962: Fix test_gdb failure in debug build with -mcet -fcf-protection -O0 (GH-9656)
25bfb1a
miss-islington commentedon Oct 9, 2018
New changeset 0ce31d3 by Miss Islington (bot) in branch '3.7':
bpo-32962: Fix test_gdb failure in debug build with -mcet -fcf-protection -O0 (GH-9656)
0ce31d3
vstinner commentedon Oct 10, 2018
New changeset b274f1c by Victor Stinner in branch '2.7':
bpo-32962: Fix test_gdb failure in debug build with -mcet -fcf-protection -O0 (GH-9656) (GH-9788)
b274f1c
vstinner commentedon Oct 10, 2018
Ok, the issue should now be fixed.
Thanks Iryna Shcherbina for your bug report, and thanks Marcel Plch for your initial fix! Marcel: my final fix is based on yours, I just made the "next" conditional.