Opened 17 years ago

Last modified 14 years ago

#777 new bug

crashes with python reference to destroyed objects (e.g exportToWkt() crashes when geom has been deleted)

Reported by: crschmidt Owned by: wonder
Priority: major: does not work as expected Milestone: Version 1.7.0
Component: Python plugins and bindings Version: Trunk
Keywords: Cc:
Must Fix for Release: No Platform: All
Platform Version: Awaiting user input: no

Description

When a feature is destroyed, if it has ownership over a geometry, it deletes that geometry. After that point, if one tries to call functions on the geometry, it will return nulls (Linux) or cause a KERN_PROTECTION_FAILURE (OS X).

This can be reproduced by selecting a feature, then typing the following into the Python console:

iface.activeLayer().selectedFeatures()[0].geometry().exportToWkt()

(Sometimes it requires calling it twice to reproduce the crash -- however, it will never return the correct answer.)

The reason for this appears to be that the feature created when it is pulled out of the list is then destoryed before exportToWkt() is called, taking the geometry with it.

A workaround is to instead call geometryAndOwnership(), which tells the feature to not destroy the geometry.

It seems like this problem may actually be exportGeosToWkb -- functions like wkbType() fail in the same way. It's possible that the mGeometry check at the beginning of these functions needs to move before teh exportGeosToWkb(), or that the exportGeosToWkb() needs to more resilient against being deleted.

Change History (10)

comment:1 by wonder, 17 years ago

Owner: changed from nobody to wonder

The problem here is in python bindings because the scenario seems to be like this:

  1. get feature
  2. store geometry's reference in Python
  3. feature is deleted (together with geometry)
  4. reference in Python still exists, but the object it's pointing to doesn't

I'm trying to find out how to cope with this correctly...

Martin

comment:2 by jef, 16 years ago

see also #1248

comment:3 by lutra, 15 years ago

Hi,

what is the status of this issue?

cheers

comment:4 by jef, 14 years ago

Milestone: Version 1.0.3
Platform: OS XAll
Platform Version: 10.4.10
Summary: exportToWkt() crashes when geom has been deletedcrashes with python reference to destroyed objects (e.g exportToWkt() crashes when geom has been deleted)

see also #2173

comment:5 by jef, 14 years ago

Component: VectorsPython plugins and bindings

comment:6 by pcav, 14 years ago

Milestone: Version 1.4.0

comment:7 by pcav, 14 years ago

Milestone: Version 1.5.0Version 1.6.0

Still true?

comment:8 by wonder, 14 years ago

This haven't been fixed yet

comment:9 by pcav, 14 years ago

Type: defectbug

comment:10 by brushtyler, 14 years ago

No crashes in my Ubuntu 9.04, but I never get the correct results.

I tried wkbType() on the same selected geometry a lot of times and I get different (and also strange) results: 0, 16777216, 7, 187101, 92, 143587, ...

Note: See TracTickets for help on using tickets.