Skip to content

libc/localtime: fix some issues and update to consistent with mainline - #6783

Merged
xiaoxiang781216 merged 5 commits into
apache:masterfrom
Donny9:sensor
Oct 19, 2022
Merged

xiaoxiang781216 merged 5 commits into
apache:masterfrom
Donny9:sensor

Conversation

@Donny9

@Donny9 Donny9 commented Aug 4, 2022 •

Copy link
Copy Markdown
Contributor

Summary

  1. Fix some issues about semphore hold in interrupt and idle stask.
  2. using recursive mutex fix deadlock.
  3. fix gmtime issue for isdst is true.
  4. update lib_localtime.c to conssisstent with mainline https://github.com/eggert/tz

Impact

Testing

timedatectl
set TZ Asia/Shanghai
timedatectl
timedatectl set-timezone Asia/Tokyo
timedatectl
timedatectl set-timezone Pacific/Honolulu
timedatectl
timedatectl set-timezone Asia/Shanghai
timedatectl
timedatectl set-timezone xxxaaa
timedatectl

@pkarashchenko pkarashchenko left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems like current code for localtime is hardly depending on presence of 64 bit types.

Comment thread libs/libc/time/lib_localtime.c Resolved
@Donny9
Donny9 force-pushed the sensor branch 2 times, most recently from 962ae37 to f5cfe74 Compare August 5, 2022 02:24
Comment thread libs/libc/time/lib_localtime.c Resolved
Comment thread libs/libc/time/lib_localtime.c Resolved
@xiaoxiang781216
xiaoxiang781216 marked this pull request as draft August 5, 2022 17:32
Comment thread libs/libc/time/lib_localtime.c Resolved

@pkarashchenko pkarashchenko left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I hope to find some time end of week to get more precise look into this.
Maybe you can describe some sample values that are failing currently, so I can focus on that.

Comment thread libs/libc/time/lib_localtime.c Resolved
Comment thread libs/libc/time/lib_localtime.c Resolved
@Donny9

Donny9 commented Aug 11, 2022

Copy link
Copy Markdown
Contributor Author

I hope to find some time end of week to get more precise look into this.
Maybe you can describe some sample values that are failing currently, so I can focus on that.

@pkarashchenko Based on the modification of pr, i found it maybe caused busyloop at line 2320.

[01/00 00:00:00.000000] [ 0] [ap] clock_basetime, line 89
[01/00 00:00:00.000000] [ 0] [ap] clock_basetime, line 97
[01/00 00:00:00.000000] [ 0] [ap] timegm, line 2679
[01/00 00:00:00.000000] [ 0] [ap] time1, line 2479
[01/00 00:00:00.000000] [ 0] [ap] time1, line 2486
[01/00 00:00:00.000000] [ 0] [ap] time1, line 2492
[01/00 00:00:00.000000] [ 0] [ap] time2, line 2456
[01/00 00:00:00.000000] [ 0] [ap] time2sub, line 2150
[01/00 00:00:00.000000] [ 0] [ap] time2sub, line 2161
[01/00 00:00:00.000000] [ 0] [ap] time2sub, line 2172
[01/00 00:00:00.000000] [ 0] [ap] time2sub, line 2179
[01/00 00:00:00.000000] [ 0] [ap] time2sub, line 2189
[01/00 00:00:00.000000] [ 0] [ap] time2sub, line 2200
[01/00 00:00:00.000000] [ 0] [ap] time2sub, line 2211
[01/00 00:00:00.000000] [ 0] [ap] time2sub, line 2231
[01/00 00:00:00.000000] [ 0] [ap] time2sub, line 2237
[01/00 00:00:00.000000] [ 0] [ap] time2sub, line 2245
[01/00 00:00:00.000000] [ 0] [ap] time2sub, line 2273
[01/00 00:00:00.000000] [ 0] [ap] time2sub, line 2293
[01/00 00:00:00.000000] [ 0] [ap] time2sub, line 2320
[01/00 00:00:00.000000] [ 0] [ap] time2sub, line 2320
[01/00 00:00:00.000000] [ 0] [ap] time2sub, line 2320
[01/00 00:00:00.000000] [ 0] [ap] time2sub, line 2320
[01/00 00:00:00.000000] [ 0] [ap] time2sub, line 2320
[01/00 00:00:00.000000] [ 0] [ap] time2sub, line 2320
[01/00 00:00:00.000000] [ 0] [ap] time2sub, line 2320
[01/00 00:00:00.000000] [ 0] [ap] time2sub, line 2320
[01/00 00:00:00.000000] [ 0] [ap] time2sub, line 2320
[01/00 00:00:00.000000] [ 0] [ap] time2sub, line 2320

image

@pkarashchenko

Copy link
Copy Markdown
Contributor

@Donny9

Donny9 commented Aug 11, 2022

Copy link
Copy Markdown
Contributor Author

@Donny9 can this is somehow related to an issue that I asked in https://lists.apache.org/thread/h4pnnv1b9hfoglwg6hp6jz12xpytff7r ?

I‘m not sure if busyloop is related to "struct tm", i feel like which condition is always satisfied, causing busyloop. Maybe realted to "sinse TYPE_SIGNED(int_fast64_t) is always true"

@xiaoxiang781216
xiaoxiang781216 marked this pull request as ready for review August 11, 2022 09:55
@xiaoxiang781216
xiaoxiang781216 marked this pull request as draft August 11, 2022 09:59
Donny9 and others added 2 commits October 18, 2022 14:05
Enable CONFIG_LIBC_LOCALTIME,CONFIG_RTC and CONFIG_SCHED_TICKLESS
In os clock init process, clock_initialize() --> ... -->
sim_rtc_rdtime() --> gmtime_r() --> gmtsub() --> return NULL
get the error rtctime.

Signed-off-by: wangbowen6 <[email protected]>
@Donny9 Donny9 changed the title libc/localtime: fix ats over time_t range libc/localtime: fix some issues and update to consistent with mainline Oct 18, 2022
@xiaoxiang781216
xiaoxiang781216 marked this pull request as ready for review October 18, 2022 06:26
Comment thread libs/libc/time/lib_localtime.c Resolved
when enable LIBC_LOCALTIME and SYSLOG_TIMESTAMP_LOCALTIME
and zoneinfo/posixrulesi isn't exist

[ EMERG] [ap] backtrace:
[ EMERG] [ap] [20] [<0xc1cc3c4>] arm_switchcontext+0xc/0x10
[ EMERG] [ap] [20] [<0xc1ac67a>] sem_wait+0x5a/0xc0
[ EMERG] [ap] [20] [<0xc1c4588>] tzset.part.0+0x8/0x160
[ EMERG] [ap] [20] [<0xc1c58de>] localtime_r+0xc6/0x114
[ EMERG] [ap] [20] [<0xc1a910a>] clock_gettime+0x16/0xa8
[ EMERG] [ap] [20] [<0xc1b7622>] nx_vsyslog+0x9e/0xc0
[ EMERG] [ap] [20] [<0xc4ba7e0>] romfs_stat+0xa4/0xf4
[ EMERG] [ap] [20] [<0xc4b47bc>] inode_semtake+0x24/0x5c
[ EMERG] [ap] [20] [<0xc1c0102>] bsearch+0x26/0x6c
[ EMERG] [ap] [20] [<0xc1c265a>] vsyslog+0x16/0x24
[ EMERG] [ap] [20] [<0xc1c2676>] syslog+0xe/0x1c
[ EMERG] [ap] [20] [<0xc4bae12>] romfs_open+0xee/0x178  <--- err log
[ EMERG] [ap] [20] [<0xc4b68ae>] file_vopen+0x116/0x144
[ EMERG] [ap] [20] [<0xc4b6ac8>] open+0x20/0x60
[ EMERG] [ap] [20] [<0xc1c3df4>] tzload+0x84/0x810
[ EMERG] [ap] [20] [<0xc1c6ef4>] mm_zalloc+0x10/0x18
[ EMERG] [ap] [20] [<0xc4bb426>] romfs_checkmount+0x22/0x58
[ EMERG] [ap] [20] [<0xc4bad74>] romfs_open+0x50/0x178
[ EMERG] [ap] [20] [<0xc1c392c>] tzparse+0x2c/0x470
[ EMERG] [ap] [20] [<0xc1ac5da>] nxsem_wait_uninterruptible+0x8a/0xd0
[ EMERG] [ap] [20] [<0xc1ac690>] sem_wait+0x70/0xc0
[ EMERG] [ap] [20] [<0xc4b47bc>] inode_semtake+0x24/0x5c
[ EMERG] [ap] [20] [<0xc4b481c>] inode_semgive+0x28/0x58
[ EMERG] [ap] [20] [<0xc4b58b4>] file_close+0x18/0x44
[ EMERG] [ap] [20] [<0xc4b4690>] close+0x80/0xb4
[ EMERG] [ap] [20] [<0xc1c43f4>] tzload+0x684/0x810
[ EMERG] [ap] [20] [<0xc1c4616>] tzset.part.0+0x96/0x160
[ EMERG] [ap] [20] [<0xc1c58de>] localtime_r+0xc6/0x114
[ EMERG] [ap] [20] [<0xc1a910a>] clock_gettime+0x16/0xa8
[ EMERG] [ap] [20] [<0xc1ea692>] cmd_date+0x276/0x37c

Signed-off-by: dongjiuzhu1 <[email protected]>
testcase:
set TZ CEST
time_t t = time(NULL);
struct tm *ts = localtime(&t);
t = timegm(ts);
t will return (time_t)-1;

Signed-off-by: dongjiuzhu1 <[email protected]>

@pkarashchenko pkarashchenko left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Few optional style changes

Comment thread libs/libc/time/lib_localtime.c Resolved
Comment thread libs/libc/time/lib_localtime.c Resolved
Comment thread libs/libc/time/lib_localtime.c Resolved
Comment thread libs/libc/time/lib_localtime.c Resolved
Comment thread libs/libc/time/lib_localtime.c Resolved
Comment thread libs/libc/time/lib_localtime.c Resolved
Comment thread libs/libc/time/lib_localtime.c Resolved
Comment thread libs/libc/time/lib_localtime.c Resolved
Comment thread libs/libc/time/lib_localtime.c Resolved
Comment thread libs/libc/time/lib_localtime.c Resolved
@xiaoxiang781216
xiaoxiang781216 merged commit 5510668 into apache:master Oct 19, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants