bpo-32962: Fix test_gdb failure in debug build with -mcet -fcf-protection -O0 · Pull Request #6754 · python/cpython (original) (raw)

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 andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Conversation11 Commits4 Checks0 Files changed

Conversation

This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters

[ Show hidden characters]({{ revealButtonHref }})

ghost

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

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

@stratakis

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

@ghost ghost changed the titlebpo-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.

vstinner

@@ -202,6 +202,8 @@ def get_stack_trace(self, source=None, script=None,
'BFD: ',
# ignore all warnings
'warning: ',
# See #32962
'Python Exception',

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.

vstinner

@@ -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

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.

vstinner

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

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.

Marcel Plch added 2 commits

June 15, 2018 14:46

vstinner

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.

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

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

vstinner

Choose a reason for hiding this comment

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

LGTM.

@bedevere-bot

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

vstinner added a commit that referenced this pull request

Jun 15, 2018

@vstinner

…H-7710)

python-gdb now catchs ValueError on read_var(): when Python has no debug symbols for example.

(cherry picked from commit 019d33b)

python-gdb now catchs UnicodeDecodeError exceptions when calling string().

(cherry picked from commit d22fc0b)

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

@vstinner

… (GH-7711)

python-gdb now catchs ValueError on read_var(): when Python has no debug symbols for example.

(cherry picked from commit 019d33b)

python-gdb now catchs UnicodeDecodeError exceptions when calling string().

(cherry picked from commit d22fc0b)

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

vstinner added a commit that referenced this pull request

Jun 15, 2018

@vstinner

vstinner added a commit that referenced this pull request

Jun 15, 2018

@vstinner

@vstinner