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 — bpo-33632: Avoid signed integer overflow in the _thread module by ZackerySpytz · Pull Request #12729 · python/cpython Conversation
|
|
@ZackerySpytz The approach looks good to me, but I think it would be good to add a test here. Is I also think it might be worth adding some of the details of exactly what user-facing behaviors will change with this patch to the changelog. "Avoid signed integer overflow" doesn't mean too much to me, out of context, and the BPO report is not much more detailed. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
| } | ||
| else { | ||
| timeout -= elapsed; | ||
| starttime += elapsed; |
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure that this part is really needed. I would prefer to leave starttime and timeout unchanged.
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.
Thank you, @vstinner, for your review.
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.
The original code also updates timeout every time it is interrupted. If you don’t adjust the timeout, I think the overall timeout could be too long. I expect you would be able to test this by installing a Python signal handler and sending signals while acquire or whatever method is running.
Perhaps you would prefer to calculate (overall) timeout − (overall) elapsed and pass that to PyThread_acquire_lock_timed.
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.
starttime += elapsed will cause starttime overflow. Because starttime is closer to _PyTime_GetMonotonicClock() + timeout by accumulating, and _PyTime_GetMonotonicClock() + timeout may overflow.
I think the else block is not needed.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
To clarify the changelog, you could say it is a timeout value that causes the overflow, and figure out what APIs are affected. I suspect some acquire method(s) of lock object(s), such as threading.Lock.acquire, but someone with an up-to-date copy of the code should confirm. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
@ZackerySpytz, please take a look at the code review comments. Thanks! |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
@ZackerySpytz Are you interested in continuing to work on this PR? |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
This was fixed in #28674, as mentioned on the bpo. |
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.