windows crash: during shutdown the IOCP wake signal handle is cleaned up but there might still be a pending event that gets delivered. Make sure we don't try to access the pointer in this situation.

pull/816/head
Brad House 4 months ago
parent 6a1e098917
commit a18a6ad3a1
  1. 7
      src/lib/ares_event_win32.c

@ -791,7 +791,11 @@ static void ares_evsys_win32_event_mod(ares_event_t *event,
static ares_bool_t ares_evsys_win32_process_other_event( static ares_bool_t ares_evsys_win32_process_other_event(
ares_evsys_win32_t *ew, ares_evsys_win32_eventdata_t *ed, size_t i) ares_evsys_win32_t *ew, ares_evsys_win32_eventdata_t *ed, size_t i)
{ {
ares_event_t *event = ed->event; ares_event_t *event;
/* NOTE: do NOT dereference 'ed' if during shutdown as this could be an
* invalid pointer if the signal handle was cleaned up, but there was still a
* pending event! */
if (ew->is_shutdown) { if (ew->is_shutdown) {
CARES_DEBUG_LOG("\t\t** i=%lu, skip non-socket handle during shutdown\n", CARES_DEBUG_LOG("\t\t** i=%lu, skip non-socket handle during shutdown\n",
@ -799,6 +803,7 @@ static ares_bool_t ares_evsys_win32_process_other_event(
return ARES_FALSE; return ARES_FALSE;
} }
event = ed->event;
CARES_DEBUG_LOG("\t\t** i=%lu, ed=%p (data)\n", (unsigned long)i, (void *)ed); CARES_DEBUG_LOG("\t\t** i=%lu, ed=%p (data)\n", (unsigned long)i, (void *)ed);
event->cb(event->e, event->fd, event->data, ARES_EVENT_FLAG_OTHER); event->cb(event->e, event->fd, event->data, ARES_EVENT_FLAG_OTHER);

Loading…
Cancel
Save