commit 90270f794c7f4e1ce2b58c8b5bfdc190df4799b6 from: Stefan Sperling date: Thu Feb 09 16:16:51 2023 UTC fix gotd segfault in libevent while disconnecting clients Sending a DISCONNECT message to the repo process and then killing it and freeing its structure won't work. The message ends up on internal libevent queues and will soon crash because we have freed the memory for the event structre. Sending that message is a leftover from the times when the repo procs were persistent. commit - 3b8fb9520f899be7cb492c652afa0cdce28e350e commit + 90270f794c7f4e1ce2b58c8b5bfdc190df4799b6 blob - 36ce2515faf1ac5c49de622315565ce78955f76b blob + 00d1d81a42f9598ad0cba57a03f07fb868556714 --- gotd/gotd.c +++ gotd/gotd.c @@ -338,13 +338,8 @@ disconnect(struct gotd_client *client) kill_auth_proc(client); kill_session_proc(client); - idisconnect.client_id = client->id; if (proc) { - if (gotd_imsg_compose_event(&proc->iev, - GOTD_IMSG_DISCONNECT, PROC_GOTD, -1, - &idisconnect, sizeof(idisconnect)) == -1) - log_warn("imsg compose DISCONNECT"); - + event_del(&proc->iev.ev); msgbuf_clear(&proc->iev.ibuf.w); close(proc->iev.ibuf.fd); kill_proc(proc, 0); @@ -353,6 +348,7 @@ disconnect(struct gotd_client *client) proc = NULL; } + idisconnect.client_id = client->id; if (gotd_imsg_compose_event(&listen_proc->iev, GOTD_IMSG_DISCONNECT, PROC_GOTD, -1, &idisconnect, sizeof(idisconnect)) == -1)