-
Notifications
You must be signed in to change notification settings - Fork 13.2k
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
Windows split stack complications? #3445
Comments
Full text of reddit comment: If anyone's thinking of doing this on Windows, please make sure you do it correctly: Use CreateFiber() and SwitchToFiber() to create and swap in new stack segments. Do not attempt to allocate stack space yourself. This is the only supported way to update the stack bounds in the thread environment block (TEB). Maintain the singly-linked Structured Exception Handling (SEH) chain pointed to by FS:[0]. This must always consist of singly linked nodes at ascending addresses within the current OS stack. If you are copying out stack blocks, you must either add handlers to bridge across the segments or appropriately link and unlink nodes in each segment. Debugging this problem in Stackless Python was not fun. Failure to handle either case will lead to hard termination of the process on an exception due to corrupted stack state. I'm not sure if Go handles this in its version, but I didn't see FS: updating code.... |
Nominating for production ready. |
accepted for production-ready milestone |
Fibers are designed for cooperative multitasking, not for segmented stacks, and will likely create too much overhead to be useful for implementing the latter. Specifically:
|
visiting for bug triage, email 2013-08-05. I don't have anything to add beyond what's written on the bug currently, though there certainly seem to be a lot of interesting nitty gritty details here. |
Page boundaries may well be a requirement anyways. I believe they were in the last version of segmented stacks we had. Beyond that, the original poster seems to be trying to help us write non-crashy code when handling exception not fast code. If it's truly the only way to live through an SEH call, we'll have to do something like the recommended thing. Maybe not exactly it, but something that preserves the SEH chain. |
The comment says we must be aware of stack info at TEB (TIB) which is only officially available by using fiber functions. When I did mingw-w64 work (#8488), I added management code for them. Factor and Go do similar to what I did. Factor developer left a blog post which is great source for this issue. Here is relevant Factor code I guess. |
In today's meeting we have decided to jettison segmented stacks. Additionally, we are currently managing custom stack bounds in the TEB/TIB on win64 (as pointed out by @klutzy), so I believe that this is closed. If this should stay open though, then feel free to reopen! |
Add eventfd shim Fixes rust-lang#3445 Design docs: https://hackmd.io/`@tiif/rk9hlmP4R`
This reddit thread suggests that there are extra precautions necessary for split stacks on Windows.
http://www.reddit.com/r/programming/comments/zk05a/a_trip_down_the_gcc_split_stack_rabbithole/c65bezg
The text was updated successfully, but these errors were encountered: