Commit a62f570
authored
VFS::chunked_buffer_io waits for read_task to exit (#5672)
In CI one of the address sanitizer jobs has found an issue with
`VFS::chunked_buffer_io`.
The read task signals the writer by closing the task queue and then
setting `reading = false`:
```
if (offset >= filesize) {
buffer_queue.drain();
reading = false;
break;
}
```
The write task can exit as soon as the read queue is empty and closed:
```
auto buffer_queue_element = buffer_queue.pop_back();
if (!buffer_queue_element.has_value()) {
// Stop writing once the queue is empty (reader finished reading file).
break;
}
```
There is a race condition wherein the read task can close the queue but
stall before updating the `reading` variable. The write task will
observe that the queue is closed, and then exit, and then return, which
invalidates the `reading` variable memory.
This pull request fixes this by waiting for the read task to finish
before returning.
---
TYPE: NO_HISTORY | BUG
DESC: Fix invalid write from `VFS::chunked_buffer_io`1 parent 8eb94d0 commit a62f570
1 file changed
+3
-0
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
430 | 430 | | |
431 | 431 | | |
432 | 432 | | |
| 433 | + | |
433 | 434 | | |
434 | 435 | | |
435 | 436 | | |
| |||
463 | 464 | | |
464 | 465 | | |
465 | 466 | | |
| 467 | + | |
| 468 | + | |
466 | 469 | | |
467 | 470 | | |
468 | 471 | | |
| |||
0 commit comments