I am using PostGIS 2.2.3 (http://download.osgeo.org/postgis/source/postgis-2.2.3.tar.gz) with MinGW64, It is failing with "0xC0000005: Access violation reading location 0x0000000029C6AD70" exception.
test=# create extension postgis;
CREATE EXTENSION
test=# select * from pg_settings;
server closed the connection unexpectedly
This probably means the server terminated abnormally
before or while processing the request.
The connection to the server was lost. Attempting reset: Failed.
>? values
0x000000000042cf20 {0x0000000028c80af0 "postgis.gdal_enabled_drivers", 0x0000000029b7bee0 "DISABLE_ALL", ...}
[0]: 0x0000000028c80af0 "postgis.gdal_enabled_drivers"
[1]: 0x0000000029b7bee0 "DISABLE_ALL"
[2]: 0x0000000000000000 <NULL>
[3]: 0x00000001405ae0b8 "Customized Options"
[4]: 0x000000006b806221 "Enabled GDAL drivers."
[5]: 0x000000006b806190 "List of enabled GDAL drivers by short name. To enable/disable all drivers, use 'ENABLE_ALL' or 'DISABLE_ALL' (sets the GDAL_SKIP config option)."
[6]: 0x000000014048d660 "superuser"
[7]: 0x0000000140551274 "string"
[8]: 0x0000000140492ce8 "default"
[9]: 0x0000000000000000 <NULL>
[10]: 0x0000000000000000 <NULL>
[11]: 0x0000000000000000 <NULL>
[12]: 0x0000000000000000 <NULL>
[13]: 0x00000000008a21a0 ""
[14]: 0x0000000000000000 <NULL>
[15]: 0x0000000000000000 <NULL>
[16]: 0x00000000008a21a0 ""
Issue seems reproducible in PostGIS version 2.3 and 2.4 as well. backend process is crashing while processing bootValue define done by PostGIS extension i.e.
raster/rt_pg/rtpostgis.c
DefineCustomStringVariable(
"postgis.gdal_enabled_drivers", /* name */
"Enabled GDAL drivers.", /* short_desc */
"List of enabled GDAL drivers by short name. To enable/disable all drivers, use 'ENABLE_ALL' or 'DISABLE_ALL' (sets the GDAL_SKIP config option).", /* long_desc */
&gdal_enabled_drivers, /* valueAddr */
boot_postgis_gdal_enabled_drivers, /* bootValue */
PGC_SUSET, /* GucContext context */
0, /* int flags */
#if POSTGIS_PGSQL_VERSION >= 91
NULL, /* GucStringCheckHook check_hook */
#endif
rtpg_assignHookGDALEnabledDrivers, /* GucStringAssignHook assign_hook */
NULL /* GucShowHook show_hook */
);
boot_postgis_gdal_enabled_drivers is allocated on CurrentMemoryContext via palloc() in related extension initialization routine (_PG_init), instead it is appropriate to utilize TopMemoryContext instead. PFA patch with it, crash is no more reproducible with it. Thanks.
In 15208: