-
-
Notifications
You must be signed in to change notification settings - Fork 32.3k
bpo-32962: Fix test_gdb failure in debug build with -mcet -fcf-protection -O0 #6754
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
Conversation
Reminder for reviewers: test_gdb is not run on Travis CI. Tests must be run manually before merging such change. |
Also in order to test the change, gcc >= 8 is required. |
-mcet -fcf-protection -O0
…H-6754) When Python is built with the intel control-flow protection flags, -mcet -fcf-protection, gdb is not able to read the stack without actually jumping inside the function. This means an extra 'next' command is required to make the $pc (program counter) enter the function and make the stack of the function exposed to gdb.
Lib/test/test_gdb.py
Outdated
@@ -202,6 +202,8 @@ def get_stack_trace(self, source=None, script=None, | |||
'BFD: ', | |||
# ignore all warnings | |||
'warning: ', | |||
# See #32962 | |||
'Python Exception', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hum, this is not a good idea to ignore bugs :-( Please revert this change.
My #7693 should fix this bug.
Lib/test/test_gdb.py
Outdated
@@ -162,7 +162,7 @@ def get_stack_trace(self, source=None, script=None, | |||
commands += ['set print entry-values no'] | |||
|
|||
if cmds_after_breakpoint: | |||
commands += cmds_after_breakpoint | |||
commands += ['next'] + cmds_after_breakpoint |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please add a comment explaining why next is needed. Something like:
# bpo-32962: When Python is compiled with -mcet -fcf-protection,
# arguments are unusable before running the first instruction
# of the function entry point.
Lib/test/test_gdb.py
Outdated
@@ -849,7 +851,7 @@ def __init__(self): | |||
''') | |||
# Verify with "py-bt": | |||
gdb_output = self.get_stack_trace(cmd, | |||
cmds_after_breakpoint=['break wrapper_call', 'continue', 'py-bt']) | |||
cmds_after_breakpoint=['break wrapper_call', 'continue', 'next', 'py-bt']) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ditto: please add a comment.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, just two minor remarks on comments.
Lib/test/test_gdb.py
Outdated
@@ -161,8 +161,11 @@ def get_stack_trace(self, source=None, script=None, | |||
if (gdb_major_version, gdb_minor_version) >= (7, 4): | |||
commands += ['set print entry-values no'] | |||
|
|||
# bpo-32962: When Python is compiled with -mcet -fcf-protection, | |||
# arguments are unusable before running the first instruction | |||
# of the function entry point. Next makes the required first step. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would you mind to replace Next with >The 'next' command< to make it more explicit?
Move also the comment inside the if block.
Lib/test/test_gdb.py
Outdated
@@ -847,9 +850,12 @@ def __init__(self): | |||
id("first break point") | |||
l = MyList() | |||
''') | |||
# bpo-32962: same case as in get_stack_trace(): | |||
# we need one extra step in order to read arguments |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Replace "we need one extra step" with "we need 'next' extra command".
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM.
@vstinner: Please replace |
…H-7710) * bpo-32962: python-gdb catchs ValueError on read_var() (GH-7692) python-gdb now catchs ValueError on read_var(): when Python has no debug symbols for example. (cherry picked from commit 019d33b) * bpo-32962: python-gdb catchs UnicodeDecodeError (GH-7693) python-gdb now catchs UnicodeDecodeError exceptions when calling string(). (cherry picked from commit d22fc0b) * bpo-32962: Fix test_gdb failure in debug build with -mcet -fcf-protection -O0 (GH-6754) When Python is built with the intel control-flow protection flags, -mcet -fcf-protection, gdb is not able to read the stack without actually jumping inside the function. This means an extra 'next' command is required to make the $pc (program counter) enter the function and make the stack of the function exposed to gdb. (cherry picked from commit 9b7c74c)
… (GH-7711) * bpo-32962: python-gdb catchs ValueError on read_var() (GH-7692) python-gdb now catchs ValueError on read_var(): when Python has no debug symbols for example. (cherry picked from commit 019d33b) * bpo-32962: python-gdb catchs UnicodeDecodeError (GH-7693) python-gdb now catchs UnicodeDecodeError exceptions when calling string(). (cherry picked from commit d22fc0b) * bpo-32962: Fix test_gdb failure in debug build with -mcet -fcf-protection -O0 (GH-6754) When Python is built with the intel control-flow protection flags, -mcet -fcf-protection, gdb is not able to read the stack without actually jumping inside the function. This means an extra 'next' command is required to make the $pc (program counter) enter the function and make the stack of the function exposed to gdb. (cherry picked from commit 9b7c74c) (cherry picked from commit ca4cb84)
@Traceur759: I'm sorry, I had to revert this change because it caused failures on two buildbots: |
This pull request solves problem with reading stack of the interpreter from gdb when new protection flags are used.
The new flags also cause some noise, which is now ignored, on stderr.
https://bugs.python.org/issue32962