v1-0001-Fix-crash-in-virtual-file-descriptor-FDDEBUG-code.patch
application/octet-stream
Filename: v1-0001-Fix-crash-in-virtual-file-descriptor-FDDEBUG-code.patch
Type: application/octet-stream
Part: 0
Patch
Format: format-patch
Series: patch v1-0001
Subject: Fix crash in virtual file descriptor FDDEBUG code.
| File | + | − |
|---|---|---|
| src/backend/storage/file/fd.c | 2 | 2 |
From e719e320366c9bde8608b180bcf8a42481c3a89a Mon Sep 17 00:00:00 2001 From: Greg Nancarrow <gregn4422@gmail.com> Date: Tue, 17 Nov 2020 10:43:27 +1100 Subject: [PATCH] Fix crash in virtual file descriptor FDDEBUG code. When virtual file descriptor FDDEBUG code is enabled, a crash occurs within the logging code in Insert(). This results from a NULL "fileName" being passed by PathNameOpenFilePerm(). The correction is to move the Insert() invocation until after fileName is set in the VfdCache entry. --- src/backend/storage/file/fd.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/backend/storage/file/fd.c b/src/backend/storage/file/fd.c index bd72a87..05abcf7 100644 --- a/src/backend/storage/file/fd.c +++ b/src/backend/storage/file/fd.c @@ -1486,8 +1486,6 @@ PathNameOpenFilePerm(const char *fileName, int fileFlags, mode_t fileMode) DO_DB(elog(LOG, "PathNameOpenFile: success %d", vfdP->fd)); - Insert(file); - vfdP->fileName = fnamecopy; /* Saved flags are adjusted to be OK for re-opening file */ vfdP->fileFlags = fileFlags & ~(O_CREAT | O_TRUNC | O_EXCL); @@ -1496,6 +1494,8 @@ PathNameOpenFilePerm(const char *fileName, int fileFlags, mode_t fileMode) vfdP->fdstate = 0x0; vfdP->resowner = NULL; + Insert(file); + return file; } -- 1.8.3.1