correctly free thread_data options at the topmost parent process
authorDenis Pronin <dannftk@yandex.ru>
Thu, 27 Jul 2023 22:26:22 +0000 (01:26 +0300)
committerDenis Pronin <dannftk@yandex.ru>
Fri, 28 Jul 2023 09:40:06 +0000 (12:40 +0300)
for non-threaded mode: since thread_data::eo is a pointer within shared
memory between the topmost fio parent process and its children let the
fio parent process set the pointer to NULL as just it frees its copy of
'eo' as memory previously allocated by means of 'malloc' meaning that
each child and the parent process itself must free it

for threaded mode we leave it as it has always been

also we do not need to check td->io_ops for being able to free td->eo in
 fio_options_free()

Signed-off-by: Denis Pronin <dannftk@yandex.ru>
backend.c
ioengines.c
options.c

index 5f0740395bad36cd9d13c30bf6bb9d871805c785..b21c36640e4c5efb096a5633c849820e49444592 100644 (file)
--- a/backend.c
+++ b/backend.c
@@ -2494,10 +2494,7 @@ reap:
                                                        strerror(ret));
                        } else {
                                pid_t pid;
-                               void *eo;
                                dprint(FD_PROCESS, "will fork\n");
-                               eo = td->eo;
-                               read_barrier();
                                pid = fork();
                                if (!pid) {
                                        int ret;
@@ -2506,7 +2503,6 @@ reap:
                                        _exit(ret);
                                } else if (__td_index == fio_debug_jobno)
                                        *fio_debug_jobp = pid;
-                               free(eo);
                                free(fd);
                                fd = NULL;
                        }
index 361727250eb70ff0932e899d8f31e98ddeaecba6..fd8c9d1a65742543a2ea054eebc0007fd5099343 100644 (file)
@@ -238,7 +238,8 @@ void free_ioengine(struct thread_data *td)
        if (td->eo && td->io_ops->options) {
                options_free(td->io_ops->options, td->eo);
                free(td->eo);
-               td->eo = NULL;
+               if (td->o.use_thread)
+                       td->eo = NULL;
        }
 
        if (td->io_ops->dlhandle) {
index 48aa0d7b1ccaf2d7a8041a2b383bafdf31ca7a5f..9432a0fbdfaa94891fe9dc4af01ca611c57c7227 100644 (file)
--- a/options.c
+++ b/options.c
@@ -5829,9 +5829,9 @@ void fio_options_free(struct thread_data *td)
        options_free(fio_options, &td->o);
        if (td->eo && td->io_ops && td->io_ops->options) {
                options_free(td->io_ops->options, td->eo);
-               free(td->eo);
-               td->eo = NULL;
        }
+       free(td->eo);
+       td->eo = NULL;
 }
 
 void fio_dump_options_free(struct thread_data *td)