GeezerVisonThe World Wide Web, restored to 800 pixels of glory. | ||||||||||||||||||||||||||||||||||||||||||||
| Home|About|Gaming cabinet|Archives|How it works|Starter sites | ||||||||||||||||||||||||||||||||||||||||||||
GeezerVison is showing github.com — gh-118814: Fix crash in `_PyArg_UnpackKeywordsWithVararg` by picnixz · Pull Request #122558 · python/cpython Conversation
|
|
Ok, it's not fixed. I found another bug and the fix doesn't work. I need to think a bit more. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
Hopefully it's now fixed (the issue, if I'm correct, was about the check |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
This looks correct; I'll be able to review it in a day or two. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
This looks good to me, but I'd like @serhiy-storchaka's eyes on this, as he's more knowledgable about the arg parsing corners of the code base.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
The design of this function is questionable:
vararg is always equal maxpos. So this parameter is redundant.buf item that contains non-borrowed reference. This is error prone.I will address this in other issue.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
| // copy the first arguments until the 'vararg' index | ||
| memcpy(buf, args, vararg * sizeof(PyObject *)); | ||
| // remaining arguments are all considered as variadic ones | ||
| buf[vararg] = _PyTuple_FromArray(&args[vararg], varargssize); |
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Check the result for NULL.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
| } | ||
| } | ||
| // copy the first arguments until the 'vararg' index | ||
| memcpy(buf, args, vararg * sizeof(PyObject *)); |
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
There may be less than vararg items in args.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Right and this is something I didn't check. I need to add tests for that (I would like to suggest a way to generate more clinic tests because there is a lack of coverage).
Sorry, something went wrong.
There was an error while loading. Please reload this page.
| * buf = [1, 2, NULL, 3, 4]. | ||
| */ | ||
| if (nargs < vararg && i < vararg) { | ||
| if (current_arg != NULL) { |
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
This leaves buf[i] not initialized, isn't?
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Urgh... yes. I should probably change the way it's being checked... like a boolean checking whether I replaced something before or not. But depending on whether you want to change the logic of this function, I may delay the commit.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
Urgh, actually there's another issue: vararg_with_many_args a: object b: object c: object d: object *args: object e: bool f: bool = False g: bool = False
I wanted to avoid rewriting the entire function but I think it'll just be easier to just rewrite entirely... I just need to understand the internals a bit more (the variable naming doesn't help IMO...) |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
And yes... I'm pretty sure that my issue is about indices... (I like coding and so, but the topic that I always disliked whether it's in maths or in dev is about indices!!! (the irony being I'm doing stuff that requires indices a lot...))) |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
|
@serhiy-storchaka I think it's better to re-address the design of the function itself. Do you want to create a separate issue and work on that? (I'm only available today and will be leaving on holidays for roughly 10 days) I should also confess that I don't have the courage to think of it today... |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
The solution for this issue can be simpler: #122664. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
Closing in favor of #122664. If more test coverage is needed, we'll just extract my tests from this one in another PR. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
Successfully merging this pull request may close these issues.
There was an error while loading. Please reload this page.