aio: Fix crash potential for pg_aios views due to late state update
Andres Freund <andres@anarazel.de>
aio: Fix crash potential for pg_aios views due to late state update pgaio_io_reclaim() reset the fields in PgAioHandle before updating the state to IDLE or incrementing the generation. For most things that's OK, but for pg_get_aios() it is not - if it copied the PgAioHandle while fields were being reset, we wouldn't detect that and could call pgaio_io_get_target_description() with ioh->target == PGAIO_TID_INVALID, leading to a crash. Fix this issue by incrementing the generation and state earlier, before resetting. Also add an assertion to pgaio_io_get_target_description() for the target to be valid - that'd have made this case a bit easier to debug. While at it, add/update a few related assertions. Author: Alexander Lakhin <exclusion@gmail.com> Discussion: https://postgr.es/m/062daca9-dfad-4750-9da8-b13388301ad9@gmail.com
Files
| Path | Change | +/− |
|---|---|---|
| src/backend/storage/aio/aio.c | modified | +15 −6 |
| src/backend/storage/aio/aio_target.c | modified | +9 −3 |
Discussion
- AIO v2.0 213 messages · 2024-09-01 → 2025-07-29