Skip to content

FIX: prevent crash on read nonlinear types from WKB/WKT#2160

Merged
mwtoews merged 3 commits intoshapely:mainfrom
brendan-ward:issue2159
Oct 17, 2024
Merged

FIX: prevent crash on read nonlinear types from WKB/WKT#2160
mwtoews merged 3 commits intoshapely:mainfrom
brendan-ward:issue2159

Conversation

@brendan-ward
Copy link
Copy Markdown
Collaborator

@brendan-ward brendan-ward commented Sep 28, 2024

Resolves #2159

GEOS 3.13 added support for reading nonlinear types (CircularString, CompoundCurve, MultiCurve, CurvePolygon, MultiSurface) from WKB / WKT, but these types do not exist within the shapely geometry type registry, or are they likely handled correctly in various functions where we are using conditional statements on geometry type ID. The crash is due to attempting to look up the type by index in the type registry and hitting an out-of-bounds error.

Until nonlinear types can be added more comprehensively, this prevents constructing nonlinear types after reading from WKB / WKT (when supported by GEOS) so that we don't run into crashes or unexpected behavior elsewhere in the codebase.

This adds WKT / WKB test cases from the GEOS test suite that are known to work with GEOS >= 3.13.

This should get backported to other supported versions of Shapely that would get compiled against GEOS 3.13.

@coveralls
Copy link
Copy Markdown

Pull Request Test Coverage Report for Build 11084401797

Details

  • 0 of 0 changed or added relevant lines in 0 files are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage increased (+0.3%) to 87.857%

Totals Coverage Status
Change from base Build 11009489119: 0.3%
Covered Lines: 2612
Relevant Lines: 2973

💛 - Coveralls

@jorisvandenbossche
Copy link
Copy Markdown
Member

This should get backported to other supported versions of Shapely that would get compiled against GEOS 3.13.

In practice that already happened for conda-forge (the latest shapely release was rebuilt for GEOS 3.13). I don't know if this is worth doing another 2.0.7 release, or otherwise we could also add this patch in the conda-forge recipe to fix those binaries that way (someone manually building shapely with latest GEOS of course still can run in that issue)

Copy link
Copy Markdown
Member

@jorisvandenbossche jorisvandenbossche left a comment

Choose a reason for hiding this comment

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

Thanks!

@brendan-ward
Copy link
Copy Markdown
Collaborator Author

also add this patch in the conda-forge recipe

I don't know what is involved there, but that is indeed probably the main place to fix. So long as this goes in before wheels get built with 3.13, that is probably sufficient outside of conda-forge.

Copy link
Copy Markdown
Member

@mwtoews mwtoews left a comment

Choose a reason for hiding this comment

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

Thanks, this is a good fix for now.

@mwtoews mwtoews merged commit 3873635 into shapely:main Oct 17, 2024
jorisvandenbossche pushed a commit that referenced this pull request Jan 30, 2025
@theroggy theroggy added this to the 2.1 milestone Feb 20, 2025
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.

from_wkt and from_wkb crash on MULTISURFACE input

5 participants