Skip to content

bpo-45826: Fix a crash in suggestions.c by checking for traceback is None#29590

Merged
ambv merged 5 commits into
python:mainfrom
sweeneyde:suggest_crash
Nov 17, 2021
Merged

bpo-45826: Fix a crash in suggestions.c by checking for traceback is None#29590
ambv merged 5 commits into
python:mainfrom
sweeneyde:suggest_crash

Conversation

@sweeneyde

@sweeneyde sweeneyde commented Nov 17, 2021

Copy link
Copy Markdown
Member

@sweeneyde sweeneyde added needs backport to 3.10 only security fixes type-bug An unexpected behavior, bug, or error labels Nov 17, 2021
Comment thread Python/suggestions.c
// Abort if we don't have a variable name or we have an invalid one
// or if we don't have a traceback to work with
if (name == NULL || traceback == NULL || !PyUnicode_CheckExact(name)) {
if (name == NULL || !PyUnicode_CheckExact(name) ||

@pablogsal pablogsal Nov 17, 2021

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Instead of checking for None, we can check if the traceback object parent class is the traceback type (.PyTraceBack_Type) . This way we also stop segfaults if someone placed any other object there

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Isn't tb_next is supposed to be None or a Traceback? Regardless, I agree that it is more clear to just check for type.

@ambv
ambv merged commit 5d90c46 into python:main Nov 17, 2021
@miss-islington

Copy link
Copy Markdown
Contributor

Thanks @sweeneyde for the PR, and @ambv for merging it 🌮🎉.. I'm working now to backport this PR to: 3.10.
🐍🍒⛏🤖

@miss-islington

Copy link
Copy Markdown
Contributor

Sorry @sweeneyde and @ambv, I had trouble checking out the 3.10 backport branch.
Please backport using cherry_picker on command line.
cherry_picker 5d90c467c02ffefdb13c1abc83a171db1a99ffad 3.10

ambv pushed a commit to ambv/cpython that referenced this pull request Nov 17, 2021
…back is None` (pythonGH-29590)

(cherry picked from commit 5d90c46)

Co-authored-by: Dennis Sweeney <36520290+sweeneyde@users.noreply.github.com>
@bedevere-bot

Copy link
Copy Markdown

GH-29602 is a backport of this pull request to the 3.10 branch.

@bedevere-bot bedevere-bot removed the needs backport to 3.10 only security fixes label Nov 17, 2021
ambv added a commit that referenced this pull request Nov 18, 2021
…back is None` (GH-29590) (GH-29602)

(cherry picked from commit 5d90c46)

Co-authored-by: Dennis Sweeney <36520290+sweeneyde@users.noreply.github.com>
remykarem pushed a commit to remykarem/cpython that referenced this pull request Dec 7, 2021
@sweeneyde
sweeneyde deleted the suggest_crash branch December 19, 2021 05:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

type-bug An unexpected behavior, bug, or error

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants