PATCH for BUG #18785: Pointer bmr.rel, dereferenced by passing as 1st parameter to function is checked for NULL later
От | Алена Васильева |
---|---|
Тема | PATCH for BUG #18785: Pointer bmr.rel, dereferenced by passing as 1st parameter to function is checked for NULL later |
Дата | |
Msg-id | CABg3sZqO_TVXUcH4NvOqeRFYFb+QzEdQDpKiO_zp=AsJi2QJPw@mail.gmail.com обсуждение исходный текст |
Список | pgsql-hackers |
Hello!
I propose adding an Assert at this point as a way to document the contract between this code and its environment.
This was previously discussed in BUG #18785 in pqsql-bugs
https://www.postgresql.org/message-id/flat/a6oxxee6blexicuark46yydtaqulsjvkrwkri6aic4vbofjxse%404a6j4kuwda7u#c52de413b182d9c42fe1eb34a82871b5
Best regards,
Eugeny Goryachev
Patch for PostgreSQL 16.6:
---
src/backend/storage/buffer/bufmgr.c | 11 +++++++++++
1 file changed, 11 insertions(+)
diff --git a/src/backend/storage/buffer/bufmgr.c b/src/backend/storage/buffer/bufmgr.c
index e066a3f888f..1d3b31f5070 100644
--- a/src/backend/storage/buffer/bufmgr.c
+++ b/src/backend/storage/buffer/bufmgr.c
@@ -895,6 +895,17 @@ ExtendBufferedRelTo(BufferManagerRelation bmr,
bmr.relpersistence = bmr.rel->rd_rel->relpersistence;
}
+ /*
+ * Validate the contract between flags and bmr.rel.
+ *
+ * EB_CREATE_FORK_IF_NEEDED implies we need to take extension lock,
+ * which requires a valid relation. Conversely, if we're skipping
+ * the extension lock (e.g., in recovery), then we must not be creating
+ * a fork here.
+ */
+ Assert(!(flags & EB_CREATE_FORK_IF_NEEDED) || !(flags & EB_SKIP_EXTENSION_LOCK));
+ Assert(bmr.rel != NULL || (flags & EB_SKIP_EXTENSION_LOCK));
+
/*
* If desired, create the file if it doesn't exist. If
* smgr_cached_nblocks[fork] is positive then it must exist, no need for
--
2.42.4
В списке pgsql-hackers по дате отправления: