Repository navigation
0.14.1 --- a copy of the space can start a thread - #29
Merged
Merged
Conversation
kal_space_start made the copy with the duplication primitive alone, and this system's fork does more: around the primitive the system library takes its locks and, in the copy, makes its state true of the new process. Without that the copy's first thread failed with EAGAIN (mcpplibs/openkal-musl#55). The three preparations fork itself calls are now called around the primitive, under names no C library defines, and port/libSystem.tbd names them. tests/conformance_space_task.cpp starts a context, joins it and starts one with a least stack size in a copy, three times.
The system library exports them and its development stub does not list them, because they are not part of the interface it documents. -U leaves each for the loader to find among the loaded images; port/libSystem.tbd lists them for a link made elsewhere.
_libSystem_atfork_* are not exported on macOS 14.8.9; the parts they call are. Measured in a program that duplicated itself with the primitive and asked the copy for a thread: nothing, EAGAIN; the two child preparations alone, the copy was killed; with the thread library's locks around the primitive, 0; the whole set in the library's order, five rounds of twenty threads, 0. The whole set is called, in that order, and named in port/libSystem.tbd and in -U flags.
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.
Fixes mcpplibs/openkal-musl#55.
kal_space_startmade the copy with the duplication primitive alone. This system'sforkdoes more: around the primitive each part of the system library takes its locks, and in the copy each makes its state true of the new process. Without that, the copy's first thread failed withEAGAIN.Measured on macOS 14.8.9, in a program that duplicated itself with the primitive and asked the copy for a thread:
pthread_createEAGAINThe routine
forkitself calls (_libSystem_atfork_*) is not exported; the parts it calls are (dyld, malloc, libc, the thread library, and_mach_fork_child). They are called in the library's order, under names no C library in this ecosystem defines, so they are reachable beneath one.port/libSystem.tbdlists them for a link made elsewhere, and-Uleaves them for the loader in a native link, whose development stub need not list them. Handlers a program registers withpthread_atforkare not run: a copy made here is not aforkthe program asked for.tests/conformance_space_task.cppstarts a context, joins it and starts one with a least stack size in a copy, three times, and reads the outcome throughkal_process_wait.