PostGIS standardize_address() May Cause Segment Crash (Segmentation Fault)
search cancel

PostGIS standardize_address() May Cause Segment Crash (Segmentation Fault)

book

Article ID: 428751

calendar_today

Updated On:

Products

VMware Tanzu Data Suite

Issue/Introduction

There is a known issue in PostGIS where the function standardize_address() may cause a Greenplum segment process to crash with a segmentation fault (SIGSEGV) when an overly long and unparseable input string is passed as a parameter.

This issue occurs when the function fails to properly parse the input as a valid address and the input length exceeds the internal buffer limit.


Problem Description

The crash may occur under the following conditions:

  1. The input value cannot be successfully parsed into an address by standardize_address()

  2. The input string is sufficiently long

  3. An internal error buffer overflows

  4. The segment hosting the data terminates unexpectedly


Reproduction Examples

Example 1: Direct Function Call

gpadmin=# SELECT standardize_address('us_lex','us_gaz','us_rules',repeat('x', 200));  -- Input not long enough, no crash
 standardize_address
---------------------
 (,,,,,,,,,,,,,,,)

gpadmin=# SELECT standardize_address('us_lex','us_gaz','us_rules',repeat('x', 300));
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.

Example 2: Function Call on Table Data

CREATE TABLE test_postgis_table (
    street_address TEXT
);

INSERT INTO test_postgis_table
VALUES (repeat('x', 300));
SELECT
    standardize_address(
        'us_lex',
        'us_gaz',
        'us_rules',
        replace(street_address, '@', ' ')
        || ', Boston, MA, 123456'
    )::text
FROM test_postgis_table;

Observed error:

ERROR:  Error on receive from seg1 slice1 10.159.240.162:20001 pid=2637080:
server closed the connection unexpectedly
This probably means the server terminated abnormally
before or while processing the request.

 

Cause

The R&D team has confirmed that this behavior is caused by a known defect in the code. This issue is acknowledged and will be addressed in a future Greenplum release.

Resolution

Workaround

To prevent segment crashes, ensure that problematic rows with excessively long address values are excluded before invoking standardize_address().

Identify problematic rows

SELECT
    length(street_address),
    street_address
FROM test_postgis_table where length(street_address) > 100; 

Example output:

-[ RECORD 1 ]--+---------------------------------------------------------
length         | 300
street_address | xxxxxxxxxxxxxxxxxxxxxxx.......

Mitigation options

  • Remove rows with overly long address values

  • Apply a length check before calling standardize_address()