The timeout is calculated with begin and end times, acquired using a non monotonic clock. If the system time changes backwards, the timeout may be decreased with a negative value.
Attached a simple fix that bail out if the system time has changed backwards during the wait loop.
Created attachment 2 [details]
Really add the patch