Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Memory freeing error around of CRS (?) or other encapsulated PROJ C++ code #4361

Closed
mkgrgis opened this issue Dec 24, 2024 · 2 comments
Closed
Labels

Comments

@mkgrgis
Copy link

mkgrgis commented Dec 24, 2024

Hello, PROJ team!

I am C RDBMS developer. We are working on online SpatiaLite ↔ PostGIS data processing in pgspider/sqlite_fdw#96. Both of SpatiaLite and PostGIS uses PROJ and we are observing some problem which is encapsulated for our code, but points to /usr/lib64/libproj.so.15.3.2.

Example of problem

Our problem have image of memory freeing error in PostgreSQL context, see end of
pgspider/sqlite_fdw#96 (comment) and core dump from next message pgspider/sqlite_fdw#96 (comment)

A "Minimal, Complete and Verifiable Example"

We are using C code, borrowed from SpatiaLite and confirmed by SpatiaLite author. See

  1. Add initial SpatiaLite ↔ PostGIS support pgspider/sqlite_fdw#96 (comment)
  2. Add initial SpatiaLite ↔ PostGIS support pgspider/sqlite_fdw#96 (comment)

Also there is tested by SpatiaLite author code
pgspider/sqlite_fdw#96 (comment)

Our code placed at https://github.com/mkgrgis/sqlite_fdw/blob/postgis_2_5_0/sqlite_gis.c , especially https://github.com/mkgrgis/sqlite_fdw/blob/e81617aafeeed42f917d0711e745da745a4222bf/sqlite_gis.c#L225 No direct PROJ usage.

Problem description

Memory freeing error in PostgreSQL context , pointed to some code near CRS C++ destructors and/or UnitOfMeasure. Both of PostGIS and SpatiaLite uses libproj.

Expected Output

No memory freeing error.

Environment Information

Our environment:
Rocky Linux 8.12, Postgres 17.0, Postgis 3.4.2, SpatiaLite 5.0.1
PostgreSQL select regexp_split_to_table(postgis_full_version, '\"\s+')||'"' component from postgis_full_version(); gives

 POSTGIS="3.4.2 c19ce56"
 [EXTENSION] PGSQL="160"
 GEOS="3.10.2-CAPI-1.16.0"
 PROJ="9.0.0 NETWORK_ENABLED=OFF URL_ENDPOINT=https://cdn.proj.org USER_WRITABLE_DIRECTORY=/home/vagrant/.local/share/proj DATABASE_PATH=/usr/local/share/proj/proj.db"
 GDAL="GDAL 3.5.0alpha1, released 2022/99/99"
 LIBXML="2.9.7"
 TOPOLOGY RASTER"
(7 rows)
  • PROJ version (proj) 9.0.0
  • Operation System Information Rocky Linux 8.12

Installation method

@rouault
Copy link
Member

rouault commented Dec 24, 2024

I'm pretty sure the core of the issue is that in the same process you get 2 copies of libproj, one comping from the OS repo, and the one you built. This isn't a PROJ bug but an integration issue.

You could potentially built the non-system PROJ with
CFLAGS="-DPROJ_RENAME_SYMBOLS -O2"
CXXFLAGS="-DPROJ_RENAME_SYMBOLS -DPROJ_INTERNAL_CPP_NAMESPACE -O2"
and make sure those flags are used too when building a library that includes it.

@rouault rouault closed this as completed Dec 24, 2024
@mkgrgis
Copy link
Author

mkgrgis commented Dec 24, 2024

Thanks, @rouault ! We have no experience around such integration bugs. Your answer was very helpful!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants