First Class Functions in C - Because That's Totally a Good Idea
zenhack.net
zenhack.net
The problem is that the caller cleans up the stack in the 32-bit ccall calling convention.
For example, when main calls write_stdout("foo", 3) it will push 3 and "foo" to the stack. The generated stub pushes 1 to the stack, and jumps into the write() function. After write() returns, main() pops off the 2 parameters it pushed, and now the stack is misaligned since no-one popped the parameter pushed by the generated stub.