Skip to content

fix(c/sedona-gdal): resolve MEMDataset::Create on GDAL 3.13 + use MEMCreate C-API when available#963

Merged
paleolimbot merged 2 commits into
apache:mainfrom
james-willis:jw/gdal-3.13-mem-symbol
Jun 19, 2026
Merged

fix(c/sedona-gdal): resolve MEMDataset::Create on GDAL 3.13 + use MEMCreate C-API when available#963
paleolimbot merged 2 commits into
apache:mainfrom
james-willis:jw/gdal-3.13-mem-symbol

Conversation

@james-willis

@james-willis james-willis commented Jun 15, 2026

Copy link
Copy Markdown
Contributor

I'm not really sure what this does but it makes it so that GDAL 3.13 doesnt break the build/runtime anymore.

I integrated the fix Kristin recommended below as well

Summary (AI-generated)

The GDAL MEM-dataset bridge resolves the MEM Create entry point dynamically in c/sedona-gdal/src/dyn_load.rs. It originally relied solely on the C++ MEMDataset::Create symbol, looked up by its mangled name. That mangling is fragile — it depends on the platform and on the parameters' constness — so GDAL 3.13 changed the final parameter from char** to char const* const* (…GDALDataTypePPc…GDALDataTypePKS1_), the candidate list only had the ≤3.12 name, and the bridge panicked at load time ("Failed to resolve … under any known mangled name"), breaking every GDAL raster op. Each future re-mangling would break it again.

GDAL has since added MEMCreate as a stable, unmangled public C API. This change resolves MEMCreate first and falls back to the mangled MEMDataset::Create only when it is absent (older GDAL), erroring only if neither resolves. Because MEMCreate drops the pszFilename parameter, it gets its own fn-pointer type and call path: create_mem_dataset calls MEMCreate (no filename) when present, otherwise the mangled C++ method with a leading empty filename.

Verified against a local GDAL 3.13.1 install: cargo test -p sedona-gdal --features gdal-sys/bindgen → 102 passed.

GDAL 3.13 changed MEMDataset::Create's final parameter from char** to
char const* const*, which changes the Itanium-ABI mangled symbol name
(…GDALDataTypePPc -> …GDALDataTypePKS1_). The dynamic loader's candidate
list only had the <=3.12 name, so the MEM dataset bridge failed at runtime
with "Failed to resolve MEMDatasetCreate under any known mangled name" on
GDAL 3.13. Add the 3.13 mangled name; pointer constness doesn't affect the
call ABI.
@github-actions github-actions Bot requested a review from paleolimbot June 15, 2026 20:12
@james-willis james-willis marked this pull request as ready for review June 15, 2026 20:20

@paleolimbot paleolimbot left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The const changes the mangling of the C++ name; however, Kristin added this to the C API which I believe was also released in 3.13 ( OSGeo/gdal#14108 ).

This may need a similar change for MSVC mangling, but we can/should probably go straight to the C symbol if it exists (now that there is one).

@Kontinuation

Copy link
Copy Markdown
Member

Each time the constness of pointer parameter changes, the ABI breaks. Fortunatelly the upstream accepted our request of adding MEMCreate as its public C API, so we can first try resolving to MEMCreate. If it fails, we fallback to the ugly C++ mangled name lookup.

@paleolimbot paleolimbot added this to the 0.4.0 milestone Jun 18, 2026
…taset::Create

Resolving MEMDataset::Create by its C++ mangled name is brittle: the mangling
depends on the platform and on parameter constness, so it changed in GDAL 3.13
(char** -> char const* const*) and will change again for future GDAL, panicking
at load time ("Failed to resolve ... under any known mangled name").

GDAL now exports MEMCreate as a stable public C API. Resolve it first — it takes
no filename parameter, so it gets its own fn-pointer type and call path — and
fall back to the mangled MEMDataset::Create only when MEMCreate is absent (older
GDAL). Error only if neither resolves. This keeps the dynamic loader robust
across current and future GDAL versions.

Verified against GDAL 3.13.1 (cargo test -p sedona-gdal --features gdal-sys/bindgen
-> 102 passed).
@james-willis james-willis changed the title fix(c/sedona-gdal): resolve MEMDataset::Create on GDAL 3.13 fix(c/sedona-gdal): resolve MEMDataset::Create on GDAL 3.13 + use MEMCreate C-API when available Jun 18, 2026

@paleolimbot paleolimbot left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I checked with local GDAL 3.13 and specifically checked that the new C symbol was getting used and this works great! Thank you!

@paleolimbot paleolimbot merged commit 3a44973 into apache:main Jun 19, 2026
17 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants