File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1717#include <stdio.h>
1818#include <stdbool.h>
1919#include <stdlib.h>
20+ #include <reent.h>
2021#include <sys/lock.h>
2122#include <kernel.h>
2223
@@ -238,6 +239,13 @@ extern struct __lock __lock___arc4random_mutex;
238239
239240void __locks_init ()
240241{
242+ /* Reset stdio initialization state so __sinit will reinitialize
243+ * FILE structs and their locks on next use.
244+ * _impure_data lives in .data (survives BSS clear on restart via
245+ * ExecPS2), while FILE structs and locks live in .bss (zeroed).
246+ * Without this, __sinit skips reinitialization and uses NULL locks. */
247+ _REENT_CLEANUP (_REENT ) = NULL ;
248+
241249 _LOCK_T lock_malloc = & __lock___malloc_recursive_mutex ;
242250 _LOCK_T lock_atexit = & __lock___atexit_recursive_mutex ;
243251 _LOCK_T lock_quick_exit = & __lock___at_quick_exit_mutex ;
You can’t perform that action at this time.
0 commit comments