Opened 2 years ago

Closed 2 years ago

Last modified 6 months ago

#27472 closed Bug (fixed)

GEOSGeometry('POINT EMPTY').ogr crashes

Reported by: Sergey Fedoseev Owned by: Sergey Fedoseev
Component: GIS Version: 1.8
Severity: Normal Keywords:
Cc: Triage Stage: Ready for checkin
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no


In [1]: from django.contrib.gis.geos import GEOSGeometry

In [2]: GEOSGeometry('POINT EMPTY').ogr
No handlers could be found for logger "django.contrib.gis"
GEOSException                             Traceback (most recent call last)
<ipython-input-2-2913b5e786ad> in <module>()
----> 1 GEOSGeometry('POINT EMPTY').ogr

/home/sergey/dev/django/django/contrib/gis/geos/geometry.pyc in ogr(self)
    484             except gdal.SRSException:
    485                 pass
--> 486         return gdal.OGRGeometry(self.wkb)
    488     @property

/home/sergey/dev/django/django/contrib/gis/geos/geometry.pyc in wkb(self)
    450         `ewkb` property instead.
    451         """
--> 452         return wkb_w(3 if self.hasz else 2).write(self)
    454     @property

/home/sergey/dev/django/django/contrib/gis/geos/prototypes/io.pyc in write(self, geom)
    227     def write(self, geom):
    228         "Returns the WKB representation of the given geometry."
--> 229         return six.memoryview(wkb_writer_write(self.ptr, geom.ptr, byref(c_size_t())))
    231     def write_hex(self, geom):

/home/sergey/dev/django/django/contrib/gis/geos/libgeos.pyc in __call__(self, *args, **kwargs)
    155         if self.func is None:
    156             self.func = self.get_func(*self.args, **self.kwargs)
--> 157         return self.func(*args, **kwargs)
    159     def get_func(self, *args, **kwargs):

/home/sergey/dev/django/django/contrib/gis/geos/prototypes/threadsafe.pyc in __call__(self, *args)
     54             # Call the threaded GEOS routine with pointer of the context handle
     55             # as the first argument.
---> 56             return self.cfunc(self.thread_context.handle.ptr, *args)
     57         else:
     58             return self.cfunc(*args)

/home/sergey/dev/django/django/contrib/gis/geos/prototypes/errcheck.pyc in check_sized_string(result, func, cargs)
     60     """
     61     if not result:
---> 62         raise GEOSException('Invalid string pointer returned by GEOS C function "%s"' % func.__name__)
     63     # A c_size_t object is passed in by reference for the second
     64     # argument on these routines, and its needed to determine the

GEOSException: Invalid string pointer returned by GEOS C function "GEOSWKBWriter_write_r"

The cause of this problem is that empty points couldn't be represented in WKB.
There are similar crashes in the other places. I'm not sure if individual tickets should be created or all fixes should be done within the bounds of this ticket.

Change History (8)

comment:1 Changed 2 years ago by Sergey Fedoseev

Owner: changed from nobody to Sergey Fedoseev
Status: newassigned

comment:2 Changed 2 years ago by Tim Graham

Triage Stage: UnreviewedAccepted

I think however you want to provide fixes will be fine. Perhaps multiple commits referencing the same ticket would be fine.

comment:3 Changed 2 years ago by Sergey Fedoseev

Has patch: set

comment:4 Changed 2 years ago by Tim Graham

Triage Stage: AcceptedReady for checkin

comment:5 Changed 2 years ago by Tim Graham <timograham@…>

In 65a1f323:

Refs #27472 -- Fixed GEOSGeometry('POINT EMPTY').ogr crash.

comment:6 Changed 2 years ago by Tim Graham <timograham@…>

In a413ef21:

Refs #27472 -- Fixed OGRGeometry('POINT EMPTY').geos crash.

comment:7 Changed 2 years ago by Tim Graham <timograham@…>

Resolution: fixed
Status: assignedclosed

In 9b79281:

Fixed #27472 -- Fixed GEOSGeometry('POINT EMPTY').transform crash.

comment:8 Changed 6 months ago by Tim Graham <timograham@…>

In 3411c555:

Refs #27472 -- Fixed crash during pickling of empty GEOS point.

Note: See TracTickets for help on using tickets.
Back to Top