Opened 8 years ago

Closed 8 years ago

Last modified 8 years ago

#3659 closed defect (fixed)

Code bug revealed by MinGW64 - crash caused by raster GUC define after CREATE EXTENSION

Reported by: manaeem Owned by: Bborie Park
Priority: medium Milestone: PostGIS 2.2.4
Component: raster Version: 2.3.x
Keywords: Cc:

Description

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.

Attachments (1)

PostGIS_rtpostgis_crash_v1.patch (2.6 KB ) - added by manaeem 8 years ago.

Download all attachments as: .zip

Change History (8)

by manaeem, 8 years ago

comment:1 by manaeem, 8 years ago

Summary: Crash with MinGW64Code bug revealed by MinGW64

comment:2 by robe, 8 years ago

In 15208:

raster GUC - boot_postgis_gdal_enabled_drivers should use TopMemoryContext instead of CurrentMemoryContext
References #3659 for trunk (PostGIS 2.4)

comment:3 by robe, 8 years ago

Milestone: PostGIS 2.3.1PostGIS 2.2.4

comment:4 by robe, 8 years ago

In 15209:

raster GUC - boot_postgis_gdal_enabled_drivers should use TopMemoryContext instead of CurrentMemoryContext
References #3659 for 2.3 (PostGIS 2.3.4) patch provided by manaeem

Last edited 8 years ago by robe (previous) (diff)

comment:5 by robe, 8 years ago

Component: postgisraster
Owner: changed from pramsey to Bborie Park
Summary: Code bug revealed by MinGW64Code bug revealed by MinGW64 - crash caused by raster GUC after CREATE EXTENSION

comment:6 by robe, 8 years ago

Summary: Code bug revealed by MinGW64 - crash caused by raster GUC after CREATE EXTENSIONCode bug revealed by MinGW64 - crash caused by raster GUC define after CREATE EXTENSION

comment:7 by robe, 8 years ago

Resolution: fixed
Status: newclosed

In 15210:

raster GUC - boot_postgis_gdal_enabled_drivers should use TopMemoryContext instead of CurrentMemoryContext
Closes #3659 for 2.2 (PostGIS 2.2.4) patch provided by manaeem

Note: See TracTickets for help on using tickets.