You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
(minor) mismatched argument in overlapped_RegisterWaitWithQueue call to RegisterWaitForSingleObject #84331
This popped out at me while looking for something else. It's probably not much of an actual problem, since the wrong datatype is larger than the correct one, but it's worth fixing.
The problem is in overlapped_RegisterWaitWithQueue, at overlapped.c:297 (in _overlapped):
if (!RegisterWaitForSingleObject(
&NewWaitObject, Object, (WAITORTIMERCALLBACK)PostToQueueCallback,
pdata, Milliseconds,
WT_EXECUTEINWAITTHREAD | WT_EXECUTEONLYONCE))
...it stood out to me immediately while I was paging past, since function pointer casts of this sort are almost always wrong, and I've seen it too many times.
WAITORTIMERCALLBACK is a typedef of WAITORTIMERCALLBACKFUNC:
...where BOOL is an int, and BOOLEAN is an unsigned char. I guess there could be some kind of issue down the line if the generated code tries to read the BOOLEAN/int from the register/memory location where there's actually an unsigned char, but after about an hour of debugging, I can't see it. The documentation also states explicitly that this should be either TRUE or FALSE. Also, it doesn't matter what we actually pass to PostQueuedCompletionStatus: https://devblogs.microsoft.com/oldnewthing/20070525-00/?p=26693
By changing the (incorrect) BOOL declaration to BOOLEAN, then we don't need the cast.
New changeset f8055fb by Miss Islington (bot) in branch '3.8': bpo-40150: Fix mismatched argument in RegisterWaitForSingleObject() call (GH-19686) f8055fb
New changeset 4a02da4 by Miss Islington (bot) in branch '3.9': bpo-40150: Fix mismatched argument in RegisterWaitForSingleObject() call (GH-19686) 4a02da4
Activity
ariccio commentedon Apr 2, 2020
This popped out at me while looking for something else. It's probably not much of an actual problem, since the wrong datatype is larger than the correct one, but it's worth fixing.
The problem is in overlapped_RegisterWaitWithQueue, at overlapped.c:297 (in _overlapped):
...it stood out to me immediately while I was paging past, since function pointer casts of this sort are almost always wrong, and I've seen it too many times.
WAITORTIMERCALLBACK is a typedef of WAITORTIMERCALLBACKFUNC:
typedef VOID (NTAPI * WAITORTIMERCALLBACKFUNC) (PVOID, BOOLEAN );
...and PostToQueueCallback is defined as:
static VOID CALLBACK
PostToQueueCallback(PVOID lpParameter, BOOL TimerOrWaitFired)
...where BOOL is an int, and BOOLEAN is an unsigned char. I guess there could be some kind of issue down the line if the generated code tries to read the BOOLEAN/int from the register/memory location where there's actually an unsigned char, but after about an hour of debugging, I can't see it. The documentation also states explicitly that this should be either TRUE or FALSE. Also, it doesn't matter what we actually pass to PostQueuedCompletionStatus: https://devblogs.microsoft.com/oldnewthing/20070525-00/?p=26693
By changing the (incorrect) BOOL declaration to BOOLEAN, then we don't need the cast.
serhiy-storchaka commentedon Jul 15, 2020
New changeset af4eda4 by Zackery Spytz in branch 'master':
bpo-40150: Fix mismatched argument in RegisterWaitForSingleObject() call (GH-19686)
af4eda4
miss-islington commentedon Jul 15, 2020
New changeset f8055fb by Miss Islington (bot) in branch '3.8':
bpo-40150: Fix mismatched argument in RegisterWaitForSingleObject() call (GH-19686)
f8055fb
miss-islington commentedon Jul 15, 2020
New changeset 4a02da4 by Miss Islington (bot) in branch '3.9':
bpo-40150: Fix mismatched argument in RegisterWaitForSingleObject() call (GH-19686)
4a02da4