3 ms·
Can you elaborate on that. It doesn't seem to work correctly on my machine. Writing beyond heap bounds and uninitialized reads.
by ehmmm 11y ago
Can you elaborate on that.
It doesn't seem to work correctly on my machine. Writing beyond heap bounds and uninitialized reads.
- rumcajz 11y agoIt uses dynamically allocated array (char filler_[...]) to shift stack pointer to arbitrary memory address. If it doesn't work with your compiler you may try to use alloca() instead.
- ehmmm 11y agoOh I see, it moves the stack pointer so it coincides with the heap allocated memory? I like articles that combine hacking and C, but this one really needs more explanation.
- rumcajz 11y agoThis article is really about the arguments to the coroutine. The original idea for shifting the stack pointer comes from here: http://fanf.livejournal.com/105413.html http://fanf.livejournal.com/105413.html
- thechao 11y agoHere's my implementation in c++, using alloca(): https://github.com/jaroslov/coro https://github.com/jaroslov/coro. Without debugger support, coroutines are pretty difficult to work with.