public inbox for [email protected]
help / color / mirror / Atom feedFrom: Ranier Vilela <[email protected]>
To: Pg Hackers <[email protected]>
Subject: Possible data race on Windows (src/bin/pg_dump/parallel.c)
Date: Mon, 29 Apr 2024 10:16:33 -0300
Message-ID: <CAEudQAqDPXE0imkFrE-YRWr0ezzbZEYQW-dD77eq97Qk+zGesA@mail.gmail.com> (raw)
Hi,
Per Coverity.
CID 1542943: (#1 of 1): Data race condition (MISSING_LOCK)
3. missing_lock: Accessing slot->AH without holding lock signal_info_lock.
Elsewhere, ParallelSlot.AH is written to with signal_info_lock held 1 out
of 1 times (1 of these accesses strongly imply that it is necessary).
The function DisconnectDatabase effectively writes the ParallelSlot.AH.
So the call in the function archive_close_connection:
if (slot->AH)
DisconnectDatabase(&(slot->AH->public));
It should also be protected on Windows, correct?
Patch attached.
best regards,
Ranier Vilela
Attachments:
[application/octet-stream] fix-possible-data-race-windows-parallel.patch (598B, ../CAEudQAqDPXE0imkFrE-YRWr0ezzbZEYQW-dD77eq97Qk+zGesA@mail.gmail.com/3-fix-possible-data-race-windows-parallel.patch)
download | inline diff:
diff --git a/src/bin/pg_dump/parallel.c b/src/bin/pg_dump/parallel.c
index a09247fae4..03c2b8e665 100644
--- a/src/bin/pg_dump/parallel.c
+++ b/src/bin/pg_dump/parallel.c
@@ -366,8 +366,14 @@ archive_close_connection(int code, void *arg)
* fail to detect it because there would be no EOF condition on
* the other end of the pipe.)
*/
+#ifdef WIN32
+ EnterCriticalSection(&signal_info_lock);
+#endif
if (slot->AH)
DisconnectDatabase(&(slot->AH->public));
+#ifdef WIN32
+ LeaveCriticalSection(&signal_info_lock);
+#endif
#ifdef WIN32
closesocket(slot->pipeRevRead);
view thread (2+ messages)
reply
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: [email protected]
Cc: [email protected]
Subject: Re: Possible data race on Windows (src/bin/pg_dump/parallel.c)
In-Reply-To: <CAEudQAqDPXE0imkFrE-YRWr0ezzbZEYQW-dD77eq97Qk+zGesA@mail.gmail.com>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox