Skip to content

Commit 4113f74

Browse files
authored
Merge pull request #4570 from garlick/issue#4564
broker: fix use-after-free segfault
2 parents 5380875 + cace924 commit 4113f74

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

src/broker/module.c

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -379,6 +379,15 @@ static void module_destroy (module_t *p)
379379
if (p->t) {
380380
if ((e = pthread_join (p->t, &res)) != 0)
381381
log_errn_exit (e, "pthread_cancel");
382+
if (p->status != FLUX_MODSTATE_EXITED) {
383+
/* Calls broker.c module_status_cb() => service_remove_byuuid()
384+
* and releases a reference on 'p'. Without this, disconnect
385+
* requests sent when other modules are destroyed can still find
386+
* this service name and trigger a use-after-free segfault.
387+
* See also: flux-framework/flux-core#4564.
388+
*/
389+
module_set_status (p, FLUX_MODSTATE_EXITED);
390+
}
382391
}
383392

384393
/* Send disconnect messages to services used by this module.

0 commit comments

Comments
 (0)