import core.memory, core.thread;
void foo()
{
GC.collect();
}
void main()
{
auto f = new Fiber(&foo);
f.call();
}
----------
GetThreadContext in thread_suspendAll will fail.
http://msdn.microsoft.com/en-us/library/windows/desktop/ms679362(v=vs.85).aspx
states under remarks:
"If you call GetThreadContext for the current thread, the function returns successfully; however, the context returned is not valid."
Now it seems that the function can't handle calls from
an unknown stack region (fiber stack) for the running thread.
It does work for suspended threads though.
We should simply use popad/asm to save the context.
OS is Windows7.
Comment #1 by code — 2012-02-13T13:31:46Z
I can't reproduce the issue on Windows Server 2008 R2 – you are getting a "Unable to load thread context" exception? In any case, rewriting the code directly in assembler should be easy enough (and potentially faster), so I'll have a look at it.
Comment #2 by code — 2012-02-13T14:47:26Z
I get a 0 return value and an empty context but I don't remember the error code.
Don't waste your time on this until I've rechecked it. There probably IS some
issue with getting the context from suspended threads as well.
Note: This is definitely no stack overflow issue.
Comment #3 by robert.schadek — 2024-12-07T13:31:46Z