Skip to content

Commit 2bac3a6

Browse files
authored
Merge pull request #813 from fjtrujy/fixLockAPIRestart
Fix missing conditions for reinitialization
2 parents a4d5418 + 93206ac commit 2bac3a6

1 file changed

Lines changed: 8 additions & 0 deletions

File tree

ee/libcglue/src/lock.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
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

239240
void __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;

0 commit comments

Comments
 (0)