libc/minimal: static variable of gmtime() does not located to z_libc_partition at usermode. #40679
Labels
area: Minimal libc
Minimal C Standard Library
area: Userspace
Userspace
bug
The issue is a bug, or the PR is fixing a bug
priority: medium
Medium impact/importance bug
Milestone
Describe the bug
A access fault occur when call gmtime() from a user thread.
gmtime() have a static allocated variable named "struct tm shared".
(zephyr/lib/libc/minimal/source/time/gmtime.c)
This variable is defined locally in the function, but allocated statically. So, it should be located to z_libc_partition.
Currently it is not. Therefore, an access fault occur when call gmtime() from user thread.
Issue 1:
The variable "shared" in gmtime() should be qualified with LIBC_DATA same as minimal/source/stdlib/rand.c.
Issue 2:
Currently, to create "z_libc_partition" parition, CONFIG_MINIMAL_LIBC_RAND is also needed.
This configuration should only relate to rand function, not time function.
To Reproduce
Expected behavior
gmtime() can be called from user thread when the thread have a permission to access "z_libc_partition".
Impact
I can use gmtime_r() instead of gmtime().
However, some library may use gmtime(), especially mbedtls. A example call flow is here.
Logs and console output
Expected output (after workaround)
Environment (please complete the following information):
The text was updated successfully, but these errors were encountered: