rtncnt_t should be defined as uint64_t in order to prevent integer overflows Topic is solved

Report here problems in any of ChibiOS components. This forum is NOT for support.
quasi_mod
Posts: 1
Joined: Sun Aug 23, 2020 5:53 am

rtncnt_t should be defined as uint64_t in order to prevent integer overflows  Topic is solved

Postby quasi_mod » Sun Aug 23, 2020 6:05 am

port_rt_get_counter_value defined in os/common/ports/SIMIA32/chcore.c uses gettimeofday() to create a counter value.
The result is returned as rtncnt_t. However, since the type of time_t is fixed to int64_t or equivalent types in most recent
libraries because of Y2038 problem, port_rt_get_counter_value will return an invalid counter value since the value might
overflow when returned as rtncnt_t.

I think the return value should be uint64_t, which means that either rtncnt_t should be uint64_t, or a different type should
be defined to be used.

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

Re: rtncnt_t should be defined as uint64_t in order to prevent integer overflows

Postby Giovanni » Sun Aug 23, 2020 6:43 am

Hi,

The purpose of rtcnt_t is to perform execution time measurements, it is not a time-of-day service and it is meant to overflow.

The only thing affected by the counter size is the number of cycles that can be measured. It is 32 bits because the simulator is compiled in 32 bits mode sand 32 bits operation add less overhead to measurements.

Giovanni


Return to “Bug Reports”

Who is online

Users browsing this forum: No registered users and 10 guests