Commit 092c6ca
committed
fix: cicada/mvto insert で TupleBody の use-after-move を解消 (#57)
Tuple::init() の 4 引数 overload で受け取る `TupleBody&& body` は本体で
未使用 (`[[maybe_unused]]`) なまま捨てられていた。呼び出し側 (cicada/mvto
の TxExecutor::insert) は newVersionGeneration() で `std::move(body)` した
直後に同じ `body` を再度 `std::move()` して init() に渡しており、典型的な
use-after-move となっていた。
cicada は `INLINE_VERSION_OPT=1` のとき init() 内で `body_ =
std::ref(inline_ver_.body_)` する。inline_ver_.body_ は default-construct
されたままで、insert で挿入したはずの値が消える (データロス)。デフォルト
ビルド (INLINE_VERSION_OPT=0) と mvto は `new_ver->body_` を参照するため
偶然動いていたが、コードスメルとしての use-after-move は残っていた。
Issue #57 の Intent B (推奨案) に従い、init() overload の 4 番目の引数を
削除し、呼び出し側も 3 引数の呼び出しに揃える。これにより:
- 二重 move による use-after-move を除去
- INLINE_VERSION_OPT=1 と =0 で body の所有経路が一致 (`new_ver->body_`)
なお INLINE_VERSION_OPT=1 で insert された tuple の body が
new_ver 経由でアクセスできることは元のコードでも保証されている。1 parent 49475eb commit 092c6ca
4 files changed
Lines changed: 5 additions & 6 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
92 | 92 | | |
93 | 93 | | |
94 | 94 | | |
95 | | - | |
96 | | - | |
| 95 | + | |
| 96 | + | |
97 | 97 | | |
98 | 98 | | |
99 | 99 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
313 | 313 | | |
314 | 314 | | |
315 | 315 | | |
316 | | - | |
| 316 | + | |
317 | 317 | | |
318 | 318 | | |
319 | 319 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
58 | 58 | | |
59 | 59 | | |
60 | 60 | | |
61 | | - | |
62 | | - | |
| 61 | + | |
63 | 62 | | |
64 | 63 | | |
65 | 64 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
167 | 167 | | |
168 | 168 | | |
169 | 169 | | |
170 | | - | |
| 170 | + | |
171 | 171 | | |
172 | 172 | | |
173 | 173 | | |
| |||
0 commit comments