-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Invalid codegen / dangling pointer for openArray escaping from block
#24261
Comments
|
A copy here is fine / expected. ie
this is the bug. semantically, The compiler can do two things: extend the lifetime of Of course, actually making view types work would be nice, though something tells me this is more work - ie the problem is the same: view types have to have correct lifetime analysis or they run into the same problem. |
Description
The following snippet results in a dangling pointer for the array access:
Here,
tyObject_ArrayBuf__3ViybJCcjsNgggY4gNLhwQ bX60gensym0_;
is generated inside a{}
block and the pointerT2_.Field0
is allowed to escape from out of that block.Because
bX60gensym0_
has gone out of scope, this allows the C compiler to reuse the stack space for other purposes which results in data corruption whenT2_
is accessed.Nim Version
2.0.8
Current Output
No response
Expected Output
No response
Known Workarounds
No response
Additional Information
No response
The text was updated successfully, but these errors were encountered: