[Home]

Summary:ASTERISK-29674: Adjust for 64bit time_t
Reporter:Andre Heider (dhewg)Labels:
Date Opened:2021-09-30 01:10:15Date Closed:2022-03-24 11:23:12
Priority:MinorRegression?
Status:Closed/CompleteComponents:Core/General
Versions:18.6.0 Frequency of
Occurrence
Constant
Related
Issues:
Environment:Attachments:
Description:musl 1.2 switched time_t to 64bit [0].
glibc still defaults to 32bit, but starting with v2.34 has a macro to
swich to 64bit too.

Use the PRId64 format specifier for time_t to work with both settings,
fixing [2].

[0] https://musl.libc.org/time64.html
[1] https://sourceware.org/git/?p=glibc.git;a=tag;h=9df03063320651bc629fa427eef3ac73fabb61ba
[2] https://github.com/openwrt/telephony/issues/690
Comments:By: Asterisk Team (asteriskteam) 2021-09-30 01:10:16.558-0500

Thanks for creating a report! The issue has entered the triage process. That means the issue will wait in this status until a Bug Marshal has an opportunity to review the issue. Once the issue has been reviewed you will receive comments regarding the next steps towards resolution. Please note that log messages and other files should not be sent to the Sangoma Asterisk Team unless explicitly asked for. All files should be placed on this issue in a sanitized fashion as needed.

A good first step is for you to review the [Asterisk Issue Guidelines|https://wiki.asterisk.org/wiki/display/AST/Asterisk+Issue+Guidelines] if you haven't already. The guidelines detail what is expected from an Asterisk issue report.

Then, if you are submitting a patch, please review the [Patch Contribution Process|https://wiki.asterisk.org/wiki/display/AST/Patch+Contribution+Process].

Please note that once your issue enters an open state it has been accepted. As Asterisk is an open source project there is no guarantee or timeframe on when your issue will be looked into. If you need expedient resolution you will need to find and pay a suitable developer. Asking for an update on your issue will not yield any progress on it and will not result in a response. All updates are posted to the issue when they occur.

Please note that by submitting data, code, or documentation to Sangoma through JIRA, you accept the Terms of Use present at [https://www.asterisk.org/terms-of-use/|https://www.asterisk.org/terms-of-use/].

By: Andre Heider (dhewg) 2021-09-30 02:02:12.942-0500

The attached patch fixes asterisk for 64bit time_t and builds warning free in that regard.

There're some spots which may not be y2038 ready or can at least be cleaned up additionally, see output of
git grep tv_sec|grep -w ld
git grep tv_sec|grep -w lu
git grep -i time|grep -w ld
git grep -i start|grep -w ld
git grep -i end|grep -w ld
git grep -i expire|grep -w ld

By: Kevin Harwell (kharwell) 2021-09-30 13:08:16.832-0500

Thanks for the contribution!

Unfortunately I've had to remove the patch for now. All contributors must sign a [License Agreement|https://wiki.asterisk.org/wiki/display/AST/Digium+License+Agreement] before submitting a patch. You can sign the agreement [here|https://issues.asterisk.org/jira/secure/DigiumLicense.jspa], and more information about the process can be found [here|https://wiki.asterisk.org/wiki/display/AST/Patch+Contribution+Process].

Also, if you'd like your contribution to be included faster, you should submit your patch for [code review|https://wiki.asterisk.org/wiki/display/AST/Code+Review] by the Asterisk Developer Community. When ready, submit your patch and any tests to [Gerrit|https://wiki.asterisk.org/wiki/display/AST/Gerrit+Usage] for code review.

Is signing the agreement, and possibly submitting your patch to Gerrit something you'd be interested in doing?

Thanks!

By: Andre Heider (dhewg) 2021-09-30 13:29:43.986-0500

Thanks, but no, I'm not interested in signing anything.

But the changes are trivial anyway, as already described it boils down to using the PRId64 format specifier for time_t values (which implies struct timeval.tv_secs too).

By: Sean Bright (seanbright) 2021-10-04 15:41:37.093-0500

As of right now, I am not able to reproduce this on Ubuntu Impish Indri which ships with glibc 2.34. I've set {{_TIME_BITS}} appropriately and a debug line I added shows that {{sizeof(time_t)}} is reporting 8.

I don't currently have an environment where I can test against musl, so this may have to wait until someone that does and has signed the project's CLA is willing to contribute a fix.

By: Sean Bright (seanbright) 2021-10-05 09:40:10.960-0500

Update: compiling with {{-m32}} - at least with a sample program - causes the warnings to appear:

{noformat}
cc -m32    time.c   -o time
time.c: In function ‘main’:
time.c:11:17: warning: format ‘%lu’ expects argument of type ‘long unsigned int’, but argument 3 has type ‘time_t’ {aka ‘long long int’} [-Wformat=]
  11 |   printf("%zu %lu\n", sizeof(time_t), now);
     |               ~~^                     ~~~
     |                 |                     |
     |                 long unsigned int     time_t {aka long long int}
     |               %llu
{noformat}


By: Andre Heider (dhewg) 2021-10-11 07:38:21.557-0500

Those are the very same warnings I fixed using PRId64 to solve the issue - nothing more, so that's good so far!

And "willing to contribute a fix" is not equal to "willing to sign some agreement". It may be the same outcome in this case, but there's an important difference.

By: Sean Bright (seanbright) 2021-10-11 08:55:45.863-0500

Contributing code to this project requires signing the contributor license agreement, so for the purposes of this project those statements are equal.

I've updated my previous comment to clarify the language you found problematic.

By: Friendly Automation (friendly-automation) 2022-03-24 11:23:13.499-0500

Change 18123 merged by Friendly Automation:
time: add support for time64 libcs

[https://gerrit.asterisk.org/c/asterisk/+/18123|https://gerrit.asterisk.org/c/asterisk/+/18123]

By: Friendly Automation (friendly-automation) 2022-03-24 11:25:09.992-0500

Change 18115 merged by Friendly Automation:
time: add support for time64 libcs

[https://gerrit.asterisk.org/c/asterisk/+/18115|https://gerrit.asterisk.org/c/asterisk/+/18115]

By: Friendly Automation (friendly-automation) 2022-03-24 12:01:04.410-0500

Change 18013 merged by Kevin Harwell:
time: add support for time64 libcs

[https://gerrit.asterisk.org/c/asterisk/+/18013|https://gerrit.asterisk.org/c/asterisk/+/18013]

By: Friendly Automation (friendly-automation) 2022-03-24 12:01:36.875-0500

Change 18116 merged by Kevin Harwell:
time: add support for time64 libcs

[https://gerrit.asterisk.org/c/asterisk/+/18116|https://gerrit.asterisk.org/c/asterisk/+/18116]