cpython icon indicating copy to clipboard operation
cpython copied to clipboard

gh-99240: Fix double-free bug in Argument Clinic str_converter generated code

Open colorfulappl opened this issue 3 years ago • 4 comments

Fix double-free bug mentioned at https://github.com/python/cpython/issues/99240, by moving memory clean up out of "exit" label.

  • Issue: gh-99240

colorfulappl avatar Nov 08 '22 07:11 colorfulappl

Most changes to Python require a NEWS entry.

Please add it using the blurb_it web app or the blurb command-line tool.

bedevere-bot avatar Nov 08 '22 07:11 bedevere-bot

Of particular note, since the generated files check in CI passed, does that mean we don't have any actual standard library argument clinic uses of this str conversion via codec functionality yet?

gpshead avatar Nov 09 '22 01:11 gpshead

does that mean we don't have any actual standard library argument clinic uses of this str conversion via codec functionality yet?

Yes, I have searched this in CPython source code and didn't find any usage of argument clinic str conversion with "encoding" parameter setting.

And test for this functionality is added in https://github.com/python/cpython/pull/96178, which has not been merged yet.

colorfulappl avatar Nov 09 '22 02:11 colorfulappl

Also, my preference, as stated in https://github.com/python/cpython/pull/96178#issuecomment-1304911989, would be to first merge that PR (with a minimal test suite), and then for each bugfix PR (such as this one) add both the bugfix and the complementing test. So, I'm suggesting putting this on hold until #96178 is merged.

erlend-aasland avatar Nov 09 '22 13:11 erlend-aasland

Added Argument Clinic functional test (#96002).

colorfulappl avatar Nov 24 '22 07:11 colorfulappl

I do think your second bullet from the bug "If function _PyArg_ParseStack parses failed, assign all the parsed arguments to "NULL" after they are freed, this should be done in _PyArg_ParseStack." is also worth doing to make bugs like this less likely to occur. That can be done in its own PR.

@colorfulappl, are you up for fixing _PyArg_ParseStack while you're at it?

erlend-aasland avatar Nov 24 '22 13:11 erlend-aasland

are you up for fixing _PyArg_ParseStack while you're at it?

I have not started yet, but I am willing to have a try. :)

colorfulappl avatar Nov 24 '22 13:11 colorfulappl

Status check is done, and it's a success ✅.

miss-islington avatar Nov 24 '22 14:11 miss-islington

GH-100352 is a backport of this pull request to the 3.11 branch.

bedevere-bot avatar Dec 20 '22 02:12 bedevere-bot

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

bedevere-bot avatar Dec 20 '22 02:12 bedevere-bot