-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Update boehmgc-coroutine-sp-fallback.diff for darwin #6987
Update boehmgc-coroutine-sp-fallback.diff for darwin #6987
Conversation
The darwin_stop_world implementation is slightly different. sp goes to altstack_lo instead of lo in this case. Assuming that is an implementation detail. But the fix is the same, when we detect alstack_lo outside of the expected stack range, we reset it to hi - stack_limit. Here stack_limit is calculated with pthread_get_stacksize_np since that is the BSD equivalent to pthread_attr_getstacksize.
Isn't this potentially bad for performance, since (if I read it correctly) it causes Boehm to scan the entire stack? Especially on 64-bit systems, the stack can potentially be very large, and reading it can cause uninitialized parts of the stack to become committed. (Nix uses a 64 MB stack, see src/nix/main.cc.) But maybe it's not too bad. |
Yeah maybe need to clarify with Robert on that, not really sure of the ramifications. I think this is definitely not an ideal solution since it relies on some guesswork of where the stack is. But it definitely beats the segfault you'd otherwise get! |
You've read correctly, but this penalty is only paid when GC happens while a coroutine is active, which seems to be only during
The altstack is for signal handling, so I'm almost certain that this is a wrong assumption. On reading the file more thoroughly it seems that we might need to support segmented stacks on darwin? I'm not sure, because that would also affect our stack protection page solution ( |
It seems that things can be made simpler by having coroutine building blocks directly in bdwgc. I've (re)started the discussion here ivmai/bdwgc#362 (comment). Another potentially "good enough" idea is to disable GC while any co-routine exists. This only works well if the number of co-routines reaches 0 quickly and often. Afaik this may be the case, but would need to be confirmed. |
Yeah, not sure what is going on. What gave me that impression was this block, which is the only place paltstack_lo is set: (and noticing that the callstack from the segfaults involves the |
…ine-sp-fallback-for-darwin Update boehmgc-coroutine-sp-fallback.diff for darwin
The darwin_stop_world implementation is slightly different. sp goes to
altstack_lo instead of lo in this case. Assuming that is an
implementation detail.
But the fix is the same, when we detect alstack_lo outside of the
expected stack range, we reset it to hi - stack_limit.
Here stack_limit is calculated with pthread_get_stacksize_np since
that is the BSD equivalent to pthread_attr_getstacksize.
Fixes #4919
cc @roberth @edolstra