TimelyDataflow / differential-dataflow

An implementation of differential dataflow using timely dataflow on Rust.
MIT License
2.54k stars 183 forks source link

Get rid of some UB #412

Closed umanwizard closed 10 months ago

umanwizard commented 10 months ago

Constructing a reference to an invalid value is always UB, according to this documentation.

In addition, even just the set_len call can cause UB if we panic immediately after it (and thus try to drop the invalid value).

The new implementation is taken from Vec::push. Hat tip to @guswynn , @doy-materialize, and @petrosagg for talking me through why it was indeed UB, and the latter for also suggesting the Vec::push implementation.

frankmcsherry commented 10 months ago

Discussed offline, but we merged instead #413 which simply removes the unsafe at the cost of some bounds checks. But I do appreciate the attention to sloppiness on my part, and ways to correct it!