Commit 8b47f45
authored
fix: Remove nested async block causing Stacked Borrows violation in PushDecoderStreamState (apache#21663)
## Which issue does this PR close?
- Closes apache#21662.
## Rationale for this change
Miri detects a Stacked Borrows violation in
`PushDecoderStreamState::transition`. A nested `async` block captures
`&mut self` as a single opaque mutable reference. At the `.await` on
`get_byte_ranges`, the future yields, and the `Unique` tag on the borrow
stack is invalidated by a `SharedReadOnly` retag. When the future
resumes, `push_ranges` attempts a two-phase retag through the
now-invalidated tag.
This was found by [Apache DataFusion
Comet](https://github.com/apache/datafusion-comet), which runs Miri in
CI.
## What changes are included in this PR?
Remove the nested `async` block in the `NeedsData` arm of
`PushDecoderStreamState::transition` and inline the IO
(`get_byte_ranges`) and CPU (`push_ranges`) operations as separate
statements. Since `transition` is already an `async fn`, the `.await`
works directly in the loop body. Without the nested block, the compiler
can split the borrows of `self.reader` and `self.decoder` into disjoint
field borrows, keeping the borrow stack valid across the yield point.
Also removes the now-unused `parquet::errors::ParquetError` import.
## Are these changes tested?
Covered by existing parquet reader tests. The original violation was
caught by Miri, which DataFusion does not currently run in CI.
## Are there any user-facing changes?
No.1 parent 7bfa3fb commit 8b47f45
1 file changed
+17
-8
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
75 | 75 | | |
76 | 76 | | |
77 | 77 | | |
78 | | - | |
79 | 78 | | |
80 | 79 | | |
81 | 80 | | |
| |||
1253 | 1252 | | |
1254 | 1253 | | |
1255 | 1254 | | |
1256 | | - | |
1257 | | - | |
1258 | | - | |
1259 | | - | |
1260 | | - | |
1261 | | - | |
1262 | | - | |
| 1255 | + | |
| 1256 | + | |
| 1257 | + | |
| 1258 | + | |
| 1259 | + | |
| 1260 | + | |
| 1261 | + | |
| 1262 | + | |
| 1263 | + | |
| 1264 | + | |
| 1265 | + | |
| 1266 | + | |
| 1267 | + | |
| 1268 | + | |
| 1269 | + | |
| 1270 | + | |
| 1271 | + | |
1263 | 1272 | | |
1264 | 1273 | | |
1265 | 1274 | | |
| |||
0 commit comments