avoid_segv_on_firing_latch_we_re_not_waiting_on_on_win32.patch
text/x-patch
Filename: avoid_segv_on_firing_latch_we_re_not_waiting_on_on_win32.patch
Type: text/x-patch
Part: 0
Patch
Format: unified
| File | + | − |
|---|---|---|
| src/backend/storage/ipc/latch.c | 5 | 1 |
diff --git a/src/backend/storage/ipc/latch.c b/src/backend/storage/ipc/latch.c
index 24d44c982d..318261962e 100644
--- a/src/backend/storage/ipc/latch.c
+++ b/src/backend/storage/ipc/latch.c
@@ -1835,7 +1835,11 @@ WaitEventSetWaitBlock(WaitEventSet *set, int cur_timeout,
if (cur_event->events == WL_LATCH_SET)
{
- if (!ResetEvent(set->latch->event))
+ /*
+ * We cannot use set->latch->event to reset the fired event if we
+ * actually aren't waiting on this latch now.
+ */
+ if (!ResetEvent(set->handles[cur_event->pos + 1]))
elog(ERROR, "ResetEvent failed: error code %lu", GetLastError());
if (set->latch && set->latch->is_set)