How do we proceed?
LIU Hao wrote:
> 在 2026-9-24 16:21, Kirill Makurin 写道:
>> 0003.txt
>>
>> + /**
>> + * Try setting an invalid value; default attribute value must be used.
>> + */
>> + DoTest (0xFF, PTHREAD_PROCESS_PRIVATE, EINVAL, 0);
>
> Looks like this should be `PTHREAD_MUTEX_STALLED`.
That's an obvious fix.
>> 0004.txt
>>
>> + case WAIT_FAILED:;
>> + DWORD errorCode = GetLastError ();
>> +
>> + /**
>> + * Recursive lock count has been exceeded.
>> + */
>> + if (errorCode == ERROR_MUTANT_LIMIT_EXCEEDED) {
>> + error_code = EAGAIN;
>> + break;
>> + }
>
> There's a superfluous semicolon after `case WAIT_FAILED:`.
>
> The `default` label below jumps pass the initialization of `errorCode`; if
> this was c++, it would be a
> compiler error. Perhaps it's not necessary to introduce a local variable
> here. You can just do
> `GetLastError () == ERROR_MUTANT_LIMIT_EXCEEDED`.
Would you prefer me to update this or you're ok with keeping it as is?
>> + if (unlikely (InterlockedCompareExchange (&mutex->State,
>> Inconsistent, OwnerDied) == OwnerDied)) {
>> + error_code = EOWNERDEAD;
>> + }
>
> If `WinpthreadsRobustMutexTimedLock()` returns `OwnerDied`, the state should
> already be `Inconsistent`,
> so this CAS will never succeed?
I looked over code once again and I think we can remove `OwnerDied` logic for
error checking but not recursive mutexes. OTOH, I think consistently using
`OwnerDied` for all robust mutexes makes general logic easier to follow.
- Kirill Makurin
_______________________________________________
Mingw-w64-public mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/mingw-w64-public