Deadline calculation in ibqReadTimeout and obqWriteTimeout
Posted: Thu Jul 12, 2018 9:09 am
Hi,
Under certain circumstances ibqReadTimeout fails when called with a TIME_INFINITE interval.
On line 368 in hal_buffers.c the deadline gets calculated regardless if it's used later. If the size of systime_t and interval_t are different this triggers a chDbgCheck in chTimeAddX.
Recommendation: Only calculate deadline if interval isn't TIME_INFINITE or TIME_IMMEDIATE. The function obqWriteTimeout also has this problem.
Question: chTimeAddX could be a potential source of integer overflows if debug checks are disabled. How should we proceed if we want to add an interval that is larger then the max of systime_t ?
Best regards,
greb
Under certain circumstances ibqReadTimeout fails when called with a TIME_INFINITE interval.
On line 368 in hal_buffers.c the deadline gets calculated regardless if it's used later. If the size of systime_t and interval_t are different this triggers a chDbgCheck in chTimeAddX.
Recommendation: Only calculate deadline if interval isn't TIME_INFINITE or TIME_IMMEDIATE. The function obqWriteTimeout also has this problem.
Question: chTimeAddX could be a potential source of integer overflows if debug checks are disabled. How should we proceed if we want to add an interval that is larger then the max of systime_t ?
Best regards,
greb