I stumbled upon some behaviour, which I had not expected using mem::uninitialized. It has to do with this commit. The essence is, that before the change there was a struct field that remained uninitialized at first and was only set later in the same function. When I tried to run a benchmark using this code compiled with opt-level=3, the program segfaulted.
Now I am perfectly aware, that there are a lot of reasons for why it is dangerous to do that and I am also fine using an Option here. Nonetheless, there are two reasons, why I am still reporting this as an issue:
- There were no runtime failures after I switched to using an
Option, so I suspect that the code should not have crashed trying to drop uninitialized memory during unwinding.
- The error only occurred in the benchmarks, i.e. with
opt-level=3. Manually compiling the same benchmark without optimizations was successful.
Given these observations I wonder, whether there might be a problem with the optimization passes here. I tried to reproduce this issue in a minimal example but did not succeed. (Sorry for that :/)
I stumbled upon some behaviour, which I had not expected using
mem::uninitialized. It has to do with this commit. The essence is, that before the change there was a struct field that remained uninitialized at first and was only set later in the same function. When I tried to run a benchmark using this code compiled withopt-level=3, the program segfaulted.Now I am perfectly aware, that there are a lot of reasons for why it is dangerous to do that and I am also fine using an
Optionhere. Nonetheless, there are two reasons, why I am still reporting this as an issue:Option, so I suspect that the code should not have crashed trying to drop uninitialized memory during unwinding.opt-level=3. Manually compiling the same benchmark without optimizations was successful.Given these observations I wonder, whether there might be a problem with the optimization passes here. I tried to reproduce this issue in a minimal example but did not succeed. (Sorry for that :/)