SIGSEGV / Exit 139 when write_iolog used with io_submit_mode=offload
authorHorshack <horshack@live.com>
Thu, 9 Feb 2023 16:03:12 +0000 (11:03 -0500)
committerHorshack <horshack@live.com>
Thu, 9 Feb 2023 16:03:12 +0000 (11:03 -0500)
Segmentation fault when log_io_u() attempts to write an entry to a
user-specified write_iolog file, if the I/O is issued from an offload
thread created by io_submit_mode=offload. Call path:

rate-submit.c::io_workqueue_fn() -> td_io_queue() -> log_io_u(td, io_u)

The log file handle in thread_data->iolog_f opened by init_iolog() is not
being copied to the offload thread's private copy of thread_data, causing a
NULL deference when fprintf() is called to write to the log file.

Fix is to copy the main thread's td->iolog_f to the offload thread's td at
creation time. Seems a bit disjointed to be copying individual fields between
these two structures on an as-needed basis rather than having a mechanism to
replicate the entire structure, or at least replicating the I/O submission
specific fields by moving them into a nested structure that's copied wholesale
in io_workqueue_init_worker_fn() - that way future code changes to the I/O
submission path wont cause the same bug for fields needed by both the inline
and offline submission paths.

Signed-off-by: Adam Horshack (horshack@live.com)
rate-submit.c

index 2fe768c0bea84e785000c782df1b586db57cf42a..3cc17eaa560304b48fc2ec07f163b31fb204b9db 100644 (file)
@@ -154,6 +154,7 @@ static int io_workqueue_init_worker_fn(struct submit_worker *sw)
        dup_files(td, parent);
        td->eo = parent->eo;
        fio_options_mem_dupe(td);
+       td->iolog_f = parent->iolog_f;
 
        if (ioengine_load(td))
                goto err;