LWIP: bug in sys_now

Report here problems in any of ChibiOS components. This forum is NOT for support.
drizzi
Posts: 4
Joined: Wed Apr 19, 2017 4:52 pm
Been thanked: 1 time

LWIP: bug in sys_now

Postby drizzi » Thu Mar 07, 2024 5:18 pm

Hello,
regarding the LWIP bindings, I think there is a bug in sys_now (sys_arch.c), at least in the (OSAL_ST_FREQUENCY / 1000) >= 1 && OSAL_ST_FREQUENCY % 1000) == 0 case.

LWIP expects sys_now to wrap at 0xFFFFFFFF but, if e.g. OSAL_ST_FREQUENCY == 10kHz it wraps at 0x1999999A

Code: Select all

  return ((u32_t)chVTGetSystemTimeX() - 1) / (OSAL_ST_FREQUENCY / 1000) + 1;


(0xFFFFFFFF-1)/10 + 1 = 0x1999999A

This result in the TCP thread to hang after ~5 days (see sys_timeouts_sleeptime and TIME_LESS_THAN in LWIP timeouts.c).

User avatar
Giovanni
Site Admin
Posts: 14458
Joined: Wed May 27, 2009 8:48 am
Location: Salerno, Italy
Has thanked: 1076 times
Been thanked: 922 times
Contact:

Re: LWIP: bug in sys_now

Postby Giovanni » Thu Mar 07, 2024 9:24 pm

Hi,

Moving in bug reports.

Giovanni


Return to “Bug Reports”

Who is online

Users browsing this forum: No registered users and 7 guests