* Stefan Hajnoczi: >> But going against ABI and toolchain in this way is really no long-term >> solution. You need to switch to stackless co-routines, or we need to >> provide proper ABI-level support for this. Today it's the thread >> pointer, tomorrow it's the shadow stack pointer, and the day after that, >> it's the SafeStack pointer. And further down the road, it's some thread >> state for garbage collection support. Or something like that. > > Yes, understood :(. This does feel like solving an undefined behavior > problem by adding more undefined behavior on top! > > Stackless coroutines have been tried in the past using Continuation > Passing C (https://github.com/kerneis/cpc). Ideally we'd use a solution > built into the compiler though. I'm concerned that CPC might not be > supported or available everywhere QEMU needs to run now and in the > future.
That seems to be require an entirely different toolchain (based on CIL). It's one way to solve the ABI issues, but perhaps not the direction you want to go in. > I took a quick look at C++20 coroutines since they are available in > compilers but the primitives look hard to use even from C++, let alone > from C. Could you go into details what makes them hard to use? Is it because coroutines are infectious across the call stack? Thanks, Florian