-
-
Notifications
You must be signed in to change notification settings - Fork 32.2k
gh-116502: Fix memory access violation on fatal error with Windows #116503
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
base: main
Are you sure you want to change the base?
gh-116502: Fix memory access violation on fatal error with Windows #116503
Conversation
Most changes to Python require a NEWS entry. Add one using the blurb_it web app or the blurb command-line tool. If this change has little impact on Python users, wait for a maintainer to apply the |
Is NULL supposed to be valid value for |
Most changes to Python require a NEWS entry. Add one using the blurb_it web app or the blurb command-line tool. If this change has little impact on Python users, wait for a maintainer to apply the |
277b5a0
to
f67eab6
Compare
Most changes to Python require a NEWS entry. Add one using the blurb_it web app or the blurb command-line tool. If this change has little impact on Python users, wait for a maintainer to apply the |
f67eab6
to
3f13c4e
Compare
Most changes to Python require a NEWS entry. Add one using the blurb_it web app or the blurb command-line tool. If this change has little impact on Python users, wait for a maintainer to apply the |
3f13c4e
to
c0e6be8
Compare
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.
It's a nice catch because at L3307, we have this kind of if (msg)
check.
I would advise adding an assert(msg != NULL)
in fatal_output_debug
though and add a comment for fatal_error
saying that msg = NULL
is allowed.
c0e6be8
to
5fdc099
Compare
I've added the |
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.
Sorry to block, but I think this is the wrong fix. When fatal_error
is called with a NULL message (via _Py_FatalErrorFormat
), fatal_output_debug
should not write the Fatal Python Error
header, because the caller already wrote it. I think it makes more sense to not call fatal_output_debug
at all if msg
is NULL.
Two other things:
- This is definitely testable, we should test
_Py_FatalErrorFormat
in_testinternalcapi
. - I would have thought this needed a news entry, because this is a crash fix.
Bénédikt, what was your rationale behind skip news
and no tests? I'm happy to defer if you have concerns about either.
A Python core developer has requested some changes be made to your pull request before we can consider merging it. If you could please address their requests along with any other requests in other reviews from core developers that would be appreciated. Once you have made the requested changes, please leave a comment on this pull request containing the phrase |
Ah I forgot about the NEWS. Since the OP committed quite a lot, there was the bot notif and I added the label just to reduce the noise, but I forgot to add one. As for the tests, sure we can add some! I may have missed the fact that the header was already written. However the function has already some if (msg) checks so we should also change them if needed. |
Most changes to Python require a NEWS entry. Add one using the blurb_it web app or the blurb command-line tool. If this change has little impact on Python users, wait for a maintainer to apply the |
No worries, it's not particularly intuitive. |
5fdc099
to
8da834c
Compare
Most changes to Python require a NEWS entry. Add one using the blurb_it web app or the blurb command-line tool. If this change has little impact on Python users, wait for a maintainer to apply the |
@dlaugt Until now it wasn't bothering me, but could you avoid force-pushing? it rewrites the history and makes incremental reviews harder. TiA! (until now, you only changed 1 file so it was fine for me, but now that we need tests and a NEWS entry, it'll be better for us). We squash-merge at the end anyway, so don't worry. |
Good point. However, on Windows, when we call I have modified the pull request according to that. However, with this solution in term of performance, But, at the end, if This is only a proposal. Up to the reviewers to decide. |
@picnixz, ok I didn't know that the merges are squashed at the end... I will avoid to amend the commits next time. |
Most changes to Python require a NEWS entry. Add one using the blurb_it web app or the blurb command-line tool. If this change has little impact on Python users, wait for a maintainer to apply the |
It should not be annoying to have this extra |
Oh, hmm, I think you're right.
We can't use |
Ok I will see later in the weekend what could be done to avoid the malloc. However, |
Yeah, that might be a bug on its own. Let's figure that out later. |
Check if msg pointer is not null before calling strlen().