bpo-41060: Avoid SEGFAULT when calling GET_INVALID_TARGET in the grammar#21020
bpo-41060: Avoid SEGFAULT when calling GET_INVALID_TARGET in the grammar#21020pablogsal merged 3 commits intopython:masterfrom
Conversation
`GET_INVALID_TARGET` might unexpectedly return `NULL`, which if not caught will cause a SEGFAULT. Therefore, this PR introduces a new inline function `RAISE_SYNTAX_ERROR_INVALID_TARGET` that always checks for `GET_INVALID_TARGET` returning NULL and can be used in the grammar, replacing the long C ternary operation used till now.
|
Seems that there is something missing still: |
|
I have to say that I am a bit scared about how we are dealing with this part, it seems that is super easy to forget some combination that segfaults :( |
I agree that this approach makes it fairly easy to miss corner cases. Still, I'm having a hard time figuring out what other approaches we could think of that don't. |
A lot of the time the problem is that we pass |
That is what this PR does, no? The return value of |
| Traceback (most recent call last): | ||
| SyntaxError: invalid syntax | ||
|
|
||
| >>> for a, b |
There was a problem hiding this comment.
If we backport this PR, are these compatible with the old parser?
There was a problem hiding this comment.
Yup yup, they should be.
Yep yep, I wrote that before checking 😅 What I had in mind is some in-between message not that generic as |
This error message would be misleading in some cases though. For the input |
|
Thanks @lysnikolaou for the PR, and @pablogsal for merging it 🌮🎉.. I'm working now to backport this PR to: 3.9. |
|
Sorry, @lysnikolaou and @pablogsal, I could not cleanly backport this to |
|
Seems that we need to do a manual backport |
No worries, I'll do it. |
…mar (pythonGH-21020) `GET_INVALID_TARGET` might unexpectedly return `NULL`, which if not caught will cause a SEGFAULT. Therefore, this commit introduces a new inline function `RAISE_SYNTAX_ERROR_INVALID_TARGET` that always checks for `GET_INVALID_TARGET` returning NULL and can be used in the grammar, replacing the long C ternary operation used till now. (cherry picked from commit 6c4e0bd)
|
GH-21024 is a backport of this pull request to the 3.9 branch. |
…e grammar (GH-21020) (GH-21024) `GET_INVALID_TARGET` might unexpectedly return `NULL`, which if not caught will cause a SEGFAULT. Therefore, this commit introduces a new inline function `RAISE_SYNTAX_ERROR_INVALID_TARGET` that always checks for `GET_INVALID_TARGET` returning NULL and can be used in the grammar, replacing the long C ternary operation used till now. (cherry picked from commit 6c4e0bd) Automerge-Triggered-By: @pablogsal
…mar (pythonGH-21020) `GET_INVALID_TARGET` might unexpectedly return `NULL`, which if not caught will cause a SEGFAULT. Therefore, this commit introduces a new inline function `RAISE_SYNTAX_ERROR_INVALID_TARGET` that always checks for `GET_INVALID_TARGET` returning NULL and can be used in the grammar, replacing the long C ternary operation used till now.
GET_INVALID_TARGETmight unexpectedly returnNULL, which if notcaught will cause a SEGFAULT. Therefore, this PR introduces a new
inline function
RAISE_SYNTAX_ERROR_INVALID_TARGETthat alwayschecks for
GET_INVALID_TARGETreturning NULL and can be used inthe grammar, replacing the long C ternary operation used till now.
https://bugs.python.org/issue41060