#32600: GEOS Polygons and Collections (across versions) cause segmentation 
faults
on macOS arm64 (M1)
-------------------------------------+-------------------------------------
     Reporter:  Aapo Rista           |                    Owner:  nobody
         Type:  Bug                  |                   Status:  new
    Component:  GIS                  |                  Version:  dev
     Severity:  Normal               |               Resolution:
     Keywords:  Polygon,             |             Triage Stage:
  MultiPoint, MultiLineString,       |  Unreviewed
  MultiPolygon, Segmentation fault,  |
  GIS, GeoDjango, GEOS, macOS, M1,   |
  arm64                              |
    Has patch:  1                    |      Needs documentation:  0
  Needs tests:  0                    |  Patch needs improvement:  0
Easy pickings:  0                    |                    UI/UX:  0
-------------------------------------+-------------------------------------
Changes (by Brenton Partridge):

 * status:  closed => new
 * cc: Brenton Partridge (added)
 * version:  3.2 => dev
 * keywords:
     MultiPoint, MultiLinestring, MultiPolygon, Segmentation fault, GIS,
     GeoDjango
     =>
     Polygon, MultiPoint, MultiLineString, MultiPolygon, Segmentation
     fault, GIS, GeoDjango, GEOS, macOS, M1, arm64
 * has_patch:  0 => 1
 * resolution:  invalid =>


Comment:

 I can confirm that this is indeed a Django bug, and I was able to
 replicate segfaults on Django's main branch, so it appears the GEOS 3.9
 update in https://code.djangoproject.com/ticket/32544 did not fix this.
 It's also been replicated in e.g.
 https://github.com/libgeos/geos/issues/528.

 It appears that in the current GEOS integration, argument signatures were
 omitted in favor of automatically casting arguments for a few polygon-
 related API calls. While this appears to have worked fine on x86 and x64,
 on macOS arm64 (for native M1 processors), it causes seemingly random data
 to be provided in place of arguments after the first, reliably causing
 segmentation faults whenever a Polygon, MultiPolygon, or MultiLineString
 is constructed. Underlying CFFI internals may be less lenient to
 unspecified arguments in Apple's implementation than on other platforms.
 Moving to explicit signatures works fine, and I see no reason having
 explicit signatures should cause problems on other platforms (though we
 should ensure CI passes).

 I've submitted a PR at https://github.com/django/django/pull/15214.

 All GIS tests now pass, and the changes are fully covered by test_geos.
 The deeper issue in testing is that CI does not run on Apple hardware, so
 it will be difficult to prevent regressions. However, the code changes are
 small and well-documented, and I'd suggest that Apple/arm64 CI will be
 important but not urgent.

 For organizations using older versions of Django, I've also made a monkey-
 patch available at
 https://gist.github.com/bpartridge/26a11b28415d706bfb9993fc28767d68 which
 can be added in any initialization code (or even called from settings.py)
 before Polygon objects are created. When applied in test settings against
 the main branch, all GIS tests pass as well; functionality is identical to
 the PR above.

 PR should be ready for review; happy to make changes as requested! Happy
 holidays - and hopefully this brings some holiday cheer to developers who
 might be seeing segfaults on their newly gifted machines!

-- 
Ticket URL: <https://code.djangoproject.com/ticket/32600#comment:6>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/064.a245674cb678adf28756e22604fe942e%40djangoproject.com.

Reply via email to