Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Asserting we're not freeing active event #1642

Merged
merged 2 commits into from
May 18, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
7 changes: 5 additions & 2 deletions event.c
Original file line number Diff line number Diff line change
Expand Up @@ -1677,7 +1677,7 @@ event_process_active_single_queue(struct event_base *base,
EVUTIL_ASSERT(activeq != NULL);

for (evcb = TAILQ_FIRST(activeq); evcb; evcb = TAILQ_FIRST(activeq)) {
struct event *ev=NULL;
struct event *ev = NULL;
if (evcb->evcb_flags & EVLIST_INIT) {
ev = event_callback_to_event(evcb);

Expand All @@ -1698,6 +1698,9 @@ event_process_active_single_queue(struct event_base *base,
"closure %d, call %p",
(void *)evcb, evcb->evcb_closure, (void *)evcb->evcb_cb_union.evcb_callback));
}
// We don't want an infinite loop or use of memory after it is freed.
// Hence, for next loop iteration, it is expected that `event_queue_remove_active` or `event_del_nolock_` have removed current event from the queue at this point.
EVUTIL_ASSERT(evcb != TAILQ_FIRST(activeq));
azat marked this conversation as resolved.
Show resolved Hide resolved

if (!(evcb->evcb_flags & EVLIST_INTERNAL))
++count;
Expand Down Expand Up @@ -2572,7 +2575,7 @@ static int
evthread_notify_base_default(struct event_base *base)
{
char buf[1];
int r;
ev_ssize_t r;
buf[0] = (char) 0;
#ifdef _WIN32
r = send(base->th_notify_fd[1], buf, 1, 0);
Expand Down