Skip to content

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

Merged
merged 4 commits into from Jun 15, 2018
Merged

bpo-32962: Fix test_gdb failure in debug build with -mcet -fcf-protection -O0 #6754

merged 4 commits into from Jun 15, 2018

Conversation

ghost
Copy link

@ghost ghost commented May 10, 2018

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

@vstinner
Copy link
Member

Reminder for reviewers: test_gdb is not run on Travis CI. Tests must be run manually before merging such change.

@stratakis
Copy link
Contributor

Also in order to test the change, gcc >= 8 is required.

@ghost ghost changed the title bpo-32962: test_gdb fails in debug build with -mcet -fcf-protection -O0 bpo-32962: Fix test_gdb failure in debug build with -mcet -fcf-protection -O0 May 14, 2018
…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.
@@ -202,6 +202,8 @@ def get_stack_trace(self, source=None, script=None,
'BFD: ',
# ignore all warnings
'warning: ',
# See #32962
'Python Exception',
Copy link
Member

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.

@@ -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
Copy link
Member

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.

@@ -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'])
Copy link
Member

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.

Copy link
Member

@vstinner vstinner left a 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.

@@ -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.
Copy link
Member

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.

@@ -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
Copy link
Member

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".

Copy link
Member

@vstinner vstinner left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM.

@vstinner vstinner merged commit 9b7c74c into python:master Jun 15, 2018
@bedevere-bot
Copy link

@vstinner: Please replace # with GH- in the commit message next time. Thanks!

vstinner added a commit that referenced this pull request Jun 15, 2018
…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)
vstinner added a commit that referenced this pull request Jun 15, 2018
… (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)
vstinner added a commit that referenced this pull request Jun 15, 2018
vstinner added a commit that referenced this pull request Jun 15, 2018
vstinner added a commit that referenced this pull request Jun 15, 2018
@vstinner
Copy link
Member

@Traceur759: I'm sorry, I had to revert this change because it caused failures on two buildbots:
https://bugs.python.org/issue32962#msg319669

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants