Compiler generates invalid program that segfault when executed #83111
Labels
A-linkage
Area: linking into static, shared libraries and binaries
A-lint
Area: Lints (warnings about flaws in source code) such as unused_mut.
C-enhancement
Category: An issue proposing an enhancement or a PR with one.
T-compiler
Relevant to the compiler team, which will review and decide on the PR/issue.
I tried this code:
Playground: https://play.rust-lang.org/?version=stable&mode=debug&edition=2018&gist=f5501d69b691435bbdcf9c758de6111b
I expected to see this happen:
A valid program is being generated by the compiler and it prints
a = 42
and then exists when executed.Instead, this happened:
The program segfaults when executed.
Meta
You can verify using the playground link that its segfaulting on:
1.50.0
I also manually tried locally with
1.49.0
and it also segfaults.Debug
Debugging with gdb:
The whole call stack is filled by calls to free. I guess it makes sense in some way since that I mistakenly re-defined free with a function that calls itself, leading to a recursive call "loop".
I fully understand that problem is on my side, I probably should not have re-defined free but arguably when defining ffi-compatible function, one could re-use an already existing libc function name without realizing it and thus leading to all sort of surprising behavior.
Maybe the compiler should:
The text was updated successfully, but these errors were encountered: