Deadline calculation in ibqReadTimeout and obqWriteTimeout Topic is solved

Report here problems in any of ChibiOS components. This forum is NOT for support.
Post Reply
greb
Posts: 10
Joined: Tue Apr 05, 2016 12:50 pm
Has thanked: 2 times
Been thanked: 3 times

Deadline calculation in ibqReadTimeout and obqWriteTimeout

Post 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
User avatar
Giovanni
Site Admin
Posts: 14893
Joined: Wed May 27, 2009 8:48 am
Has thanked: 1202 times
Been thanked: 997 times

Re: Deadline calculation in ibqReadTimeout and obqWriteTimeout

Post 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
User avatar
Giovanni
Site Admin
Posts: 14893
Joined: Wed May 27, 2009 8:48 am
Has thanked: 1202 times
Been thanked: 997 times

Re: Deadline calculation in ibqReadTimeout and obqWriteTimeout

Post by Giovanni »

Hi,

Fixed as bug #963.

Giovanni
Post Reply