postgresql/src
Thomas Munro 29ddb548f6 Fix inconsistent out-of-memory error reporting in dsa.c.
Commit 16be2fd1 introduced the flag DSA_ALLOC_NO_OOM to control whether
the DSA allocator would raise an error or return InvalidDsaPointer on
failure to allocate.  One edge case was not handled correctly: if we
fail to allocate an internal "span" object for a large allocation, we
would always return InvalidDsaPointer regardless of the flag; a caller
not expecting that could then dereference a null pointer.

This is a plausible explanation for a one-off report of a segfault.

Remove a redundant pair of braces so that all three stanzas that handle
DSA_ALLOC_NO_OOM match in style, for visual consistency.

While fixing inconsistencies, if FreePageManagerGet() can't supply the
pages that our book-keeping says it should be able to supply, then we
should always report a FATAL error.  Previously we treated that as a
regular allocation failure in one code path, but as a FATAL condition
in another.

Back-patch to 10, where dsa.c landed.

Author: Thomas Munro
Reported-by: Jakub Glapa
Discussion: https://postgr.es/m/CAEepm=2oPqXxyWQ-1o60tpOLrwkw=VpgNXqqF1VN2EyO9zKGQw@mail.gmail.com
2019-02-25 11:11:40 +13:00
..
backend Fix inconsistent out-of-memory error reporting in dsa.c. 2019-02-25 11:11:40 +13:00
bin Provide an extra-float-digits setting for pg_dump / pg_dumpall 2019-02-18 07:37:07 -05:00
common Tolerate EINVAL when calling fsync() on a directory. 2019-02-24 23:50:20 +13:00
fe_utils More unconstify use 2019-02-13 11:50:16 +01:00
include Move estimate_hashagg_tablesize to selfuncs.c, and widen result to double. 2019-02-21 14:59:12 -05:00
interfaces Fix ecpg bugs caused by missing semicolons in the backend grammar. 2019-02-24 12:51:50 -05:00
makefiles Move port-specific parts of with_temp_install to port makefile. 2019-02-04 18:54:56 +00:00
pl More unconstify use 2019-02-13 11:50:16 +01:00
port Make use of compiler builtins and/or assembly for CLZ, CTZ, POPCNT. 2019-02-15 23:22:33 -05:00
template Yet further rethinking of build changes for macOS Mojave. 2018-11-02 18:54:00 -04:00
test Revert "pg_regress: Don't use absolute paths for the diff" 2019-02-23 09:37:25 +01:00
timezone More unconstify use 2019-02-13 11:50:16 +01:00
tools Make use of compiler builtins and/or assembly for CLZ, CTZ, POPCNT. 2019-02-15 23:22:33 -05:00
tutorial SQL comment: remove extra word in heading comment 2019-01-25 18:57:21 -05:00
.gitignore
DEVELOPERS
Makefile Fix partial-build problems introduced by having more generated headers. 2018-04-09 16:42:10 -04:00
Makefile.global.in Revert attempts to use POPCNT etc instructions 2019-02-15 16:32:30 -03:00
Makefile.shlib Ensure static libraries have correct mod time even if ranlib messes it up. 2018-11-29 15:53:44 -05:00
nls-global.mk Replace @postgresql.org with @lists.postgresql.org for mailinglists 2019-01-19 19:06:35 +01:00