Re: Dereference before NULL check (src/backend/storage/ipc/latch.c)
Kyotaro Horiguchi <horikyota.ntt@gmail.com>
From: Kyotaro Horiguchi <horikyota.ntt@gmail.com>
To: thomas.munro@gmail.com
Cc: ranier.vf@gmail.com, pgsql-hackers@lists.postgresql.org
Date: 2020-11-02T11:50:30Z
Lists: pgsql-hackers
Attachments
- repro.diff (text/x-patch) patch
At Mon, 02 Nov 2020 17:25:04 +0900 (JST), Kyotaro Horiguchi <horikyota.ntt@gmail.com> wrote in > I called SetLatch() during WaitLatch(NULL, ) but that doesn't fire > WL_LATCH_SET event for me on Windows. (I got it fired on Linux..) On > Windows, the latch is detected after exiting the WaitLatch() > call. Seems like MyLatch of waiter is different from > peerPGPROC->procLatch. And... an update for Visual Studio broke my > environment... I will investigate this further but everything feel > cumbersome on Windows... I managed to reproduce the issue. FWIW the attached modifies pg_backend_pid() to call "WaitLatch(NULL," and pg_terminate_backend(pid) to SetLatch() to the process latch of the pid. (It's minunderstanding that I could reproduce this on Linux.) Session A: =# select pg_backend_pid(); -- sleeps for 10 seconds. Session B: =# select pg_terminate_backend(A-pid); [11628] LOG: server process (PID 14568) was terminated by exception 0xC0000005 [11628] DETAIL: Failed process was running: select pg_backend_pid(); [11628] HINT: See C include file "ntstatus.h" for a description of the hexadecimal value. [11628] LOG: terminating any other active server processes [2948] WARNING: terminating connection because of crash of another server process 2 With the fix patch, it changes to: [16632] LOG: FALSE LATCH: 0000000000000000 rebards. -- Kyotaro Horiguchi NTT Open Source Software Center
Commits
-
Fix WaitLatch(NULL) on Windows.
- a7e65dc88b6f 14.0 landed