rt-thread/components/libc
kenneth.liu cffaa514e2 components: libc: fix reset static variable unsolved in dlmodule_load_shared_object
[Problem Description]
In the dlmodule_load_shared_object function,
if a module loading fails once due to an unresolved symbol,
all subsequent attempts to load any module will fail.
The system becomes unable to load modules correctly until a reboot.

[Problem Analysis]
The root cause is that the variable unsolved is defined as static.
Static variables retain their value between function calls.
If a relocation error occurs, unsolved is set to RT_TRUE.
However, when the function returns with an error, the value of unsolved is not reset.
Consequently, on the next function call, unsolved remains RT_TRUE from the previous execution.
This causes the check if (unsolved) to trigger immediately (or after the loop),
forcing the function to return an error regardless of whether the current module is valid or not.

[Solution]
Reset the unsolved variable to RT_FALSE before returning the error code -RT_ERROR.
This ensures the variable is in a clean state for the next function call, preventing state leakage between invocations.

Signed-off-by: Liu Gui <kenneth.liu@sophgo.com>
2026-03-12 13:59:15 +08:00
..
compilers [components][clock_time] Refactor time subsystem around clock_time (#11111) 2026-01-31 17:44:27 +08:00
cplusplus components:libc:cplusplus:os/utest:Some comments have been initially added. 2025-12-12 14:00:36 +08:00
posix components: libc: fix reset static variable unsolved in dlmodule_load_shared_object 2026-03-12 13:59:15 +08:00
Kconfig 除了bsp之外的Kconfig使用rsource替代source 2024-06-20 14:40:42 +08:00
SConscript [nano] rt-thread susport nano option 2023-11-30 11:39:34 +08:00
posix-info.txt update posix-info.txt 2022-01-25 13:40:10 +08:00