I am seeing in very rare cases pthread_cond_timedwait() return EINVAL and cause a fatal crash on our system. I understand that this means one of the parameters passed in has to be invalid, but how does the mutex or cond variable become invalid?
Is there any way to check these arguments before calling pthread_cond_timedwait() to prevent a crash?
It is unspecified as exaclty what constitutes as invalid, but here are a few reasons that I have observed
pthread_cond_timedwaitreturningEINVAL:Without manually mimicking the validation calls that pthread is doing, then I do not know of a way to check the arguments before calling
pthread_cond_timewait(). However,pthread_cond_timewait()returningEINVALshould not cause a fatal crash, as it is a specified case. Consider examining other areas of application code that may not handle the return results appropriately. For example, code that assumes success as long as the return was notETIMEDOUT.