Skip to content

PROJ core dumps when setting data directory on specific context and it is not set on global context #1574

@snowman2

Description

@snowman2

pyproj4/pyproj#419

This is a wierd edge case that has taken me some time to track down as the cause has been elusive for quite some time due to the core dumping. However, I believe the symptoms and the solution should help find a solution in PROJ I believe.

In the case where the data directory is not able to be determined by PROJ in the default locations on the global context, it will core dump when attempting to use proj_create with a perfectly valid custom context that has the proper data directory set. However, this does not happen in all instances. It only happens when using the +init= syntax.

For example:

>>> from pyproj import CRS
>>> cc = CRS("+proj=utm +zone=33 +ellps=WGS84 +datum=WGS84 +units=m +no_defs")
>>> cc = CRS(init="epsg:4326")
Segmentation fault (core dumped)

My guess is it has to do with:

PROJ/src/iso19111/c_api.cpp

Lines 437 to 440 in f059b90

// Only connect to proj.db if needed
if (strstr(text, "proj=") == nullptr || strstr(text, "init=") != nullptr) {
getDBcontextNoException(ctx, __FUNCTION__);
}

The fix I applied in pyproj was to set the data directory for the global PROJ context along with the custom context.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions