Code

#18640 closed Bug (fixed)

django.contrib.gis.gdal.DataSource fields give gibberish or segfault when accessed directly

Reported by: YenTheFirst Owned by: jbronn
Component: GIS Version: 1.4
Severity: Release blocker Keywords:
Cc: Triage Stage: Accepted
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

if you hold a feature in a variable, and access a field, it will give the correct value.

however, if you access a feature's field by layer[<index>][<field_name>], it gives gibberish, or a segfault.

this might be related to https://code.djangoproject.com/ticket/9448. however, given that the ticket was closed, it might be a different issue.

script to reproduce issue:

import os
import django.contrib.gis
from django.contrib.gis.gdal import DataSource
 
GIS_PATH = os.path.dirname(django.contrib.gis.__file__)
CITIES_PATH = os.path.join(GIS_PATH, 'tests/data/cities/cities.shp')
 
ds = DataSource(CITIES_PATH)
layer = ds[0]
feature = layer[0]
field = feature['Name']
 
print "this is valid: %r (%r)" % (field.value, list(field.value))
 
field = layer[0]['Name']
 
print "but this isn't: %r (%r)" % (field.value, list(field.value))

in python, results in segfault.
in ipython:
this is valid: 'Pueblo' (['P', 'u', 'e', 'b', 'l', 'o'])
but this isn't: ':\xd5\xe2=\xb1\xb4\xb9\xb4Q' ([':', '\xd5', '\xe2', '=', '\xb1', '\xb4', '\xb9', '\xb4', 'Q'])

saved as script, results in:
this is valid: 'Pueblo' (['P', 'u', 'e', 'b', 'l', 'o'])
but this isn't: ([])

this is on an ubuntu 11.04, with django 1.4, and gdal 1.7

Attachments (2)

18640-1.diff (4.5 KB) - added by claudep 21 months ago.
Add parent references to GDAL Feature/Field
18640-2.diff (7.4 KB) - added by jbronn 20 months ago.

Download all attachments as: .zip

Change History (6)

Changed 21 months ago by claudep

Add parent references to GDAL Feature/Field

comment:1 Changed 21 months ago by claudep

  • Component changed from Uncategorized to GIS
  • Has patch set
  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset
  • Triage Stage changed from Unreviewed to Accepted
  • Type changed from Uncategorized to Bug

Confirmed. It appears that it is the same type of issue as in #9448. At least, adding references to parent objects seems to solve the problem.

Changed 20 months ago by jbronn

comment:2 Changed 20 months ago by jbronn

  • Owner changed from nobody to jbronn
  • Status changed from new to assigned

Yeah this is a problem. I've updated the implementation, but will need to review more when I get home from the sprints.

comment:3 Changed 20 months ago by jbronn

  • Severity changed from Normal to Release blocker

comment:4 Changed 19 months ago by Claude Paroz <claude@…>

  • Resolution set to fixed
  • Status changed from assigned to closed

In cb9f71dd99f0e524c871830b248cf28fcacd5753:

Fixed #18640 -- Allowed access to GDAL Feature without Datasource

Thanks Justin Bronn for improving my initial patch.

Add Comment

Modify Ticket

Change Properties
<Author field>
Action
as closed
as The resolution will be set. Next status will be 'closed'
The resolution will be deleted. Next status will be 'new'
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.