Repository navigation
Release pthread runtime resources during PSP module teardown - #4
Open
DublikuntMux wants to merge 2 commits into
Open
DublikuntMux wants to merge 2 commits into
DublikuntMux wants to merge 2 commits into
Conversation
Release the implicit native main-thread pthread handle without deleting its OS thread. Clear the thread-reuse pool and destroy all six global mutex semaphores after key and thread cleanup. Propagate semaphore allocation failure from pthread_mutex_init rather than returning an invalid mutex. Applications must join their explicit workers before terminating the runtime.
Match the existing ordinary-mutex gthread selection for recursive mutexes. Both static initializers defer native resource allocation; libstdc++ wrappers must still run native destruction after use. Keep this implementation policy in pthread rather than adding PSP-specific code to GCC. Add C++11 destructor-trait coverage for ordinary, timed, recursive and recursive-timed mutexes. With unmodified GCC gthread code, the old header fails recursive assertions and this header passes all four.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
PSP module shutdown leaks pthread runtime resources: the implicit native main-thread handle, cached thread records and six global mutex semaphores survive termination. Mutex initialization also reports success when semaphore creation fails. C++ recursive mutex wrappers additionally omit native destruction because the public pthread header only selects GCC's ordinary-mutex initialization path.
Release the implicit thread record without deleting the native main thread, reset the reuse pool, and destroy global locks after key/thread cleanup. Propagate semaphore creation failure as
EAGAINand free the partially initialized mutex. Select_GTHREAD_USE_RECURSIVE_MUTEX_INIT_FUNCalongside the existing ordinary flag so C++ recursive wrappers release their resources using GCC's existing generic implementation. Add C++11 destructor-trait assertions for ordinary, timed, recursive and recursive-timed mutexes.Applications must finish/join explicit POSIX workers before calling
pthread_terminate. This targetsplatform_agnostic, the branch used by the PSP toolchain. Complete PSP module cleanup also needs PSPSDK PR #408, which invokes teardown before releasing the heap and cleans up PSP OSAL resources.