Page 1 of 1

Deadline calculation in ibqReadTimeout and obqWriteTimeout

Posted: Thu Jul 12, 2018 9:09 am
by greb
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

Re: Deadline calculation in ibqReadTimeout and obqWriteTimeout

Posted: Thu Jul 12, 2018 10:52 am
by Giovanni
Hi,

Using deadlines you cannot have intervals larger than systime_t, the only solution would be to remove deadlines and have plain timeouts (which would also fix the first problem), we already did this for queues.

Giovanni

Re: Deadline calculation in ibqReadTimeout and obqWriteTimeout

Posted: Sun Jul 15, 2018 8:52 am
by Giovanni
Hi,

Fixed as bug #963.

Giovanni