Function calls can be inlined in naked functions, leading to crashes / memory corruption #7286
Labels
bug
Observed behavior contradicts documented or intended behavior
miscompilation
The compiler reports success but produces semantically incorrect code.
stage1
The process of building from source via WebAssembly and the C backend.
Milestone
Say you have code like:
If the call
f
is inlined (as is the case here), it generates code using%rbp
assuming there were a stack frame, when there is none.If it's not inlined, it emits a call instruction which then sets up
f
's own new stack frame.Does Zig want to define what behavior happens here? Right now it doesn't even error or warn, it just miscompiles it.
I think there are two ways to approach this:
In either case it should always error if the call involves an argument on the stack (pertinent to #72).
And yes, I ran into this in real code. GCC/Clang doesn't let you call functions from naked functions, but Zig let me so I thought it might work -- until I compiled in release mode and my callee was inlined.
The text was updated successfully, but these errors were encountered: