[GRASS-dev] [GRASS GIS] #3593: Error in v.stream.order add-on, segmentation fault
GRASS GIS
trac at osgeo.org
Sun Sep 16 12:28:40 PDT 2018
#3593: Error in v.stream.order add-on, segmentation fault
--------------------------+---------------------------------
Reporter: jradinger | Owner: grass-dev@…
Type: defect | Status: new
Priority: normal | Milestone:
Component: Addons | Version: svn-releasebranch74
Resolution: | Keywords:
CPU: Unspecified | Platform: Unspecified
--------------------------+---------------------------------
Comment (by mmetz):
Replying to [comment:6 jradinger]:
> I've not yet checked with `valgrind` or `pdb`, but I might have
identified the line that might cause the problem (L390,
https://trac.osgeo.org/grass/browser/grass-
addons/grass7/vector/v.stream.order/v.stream.order.py#L390): This is the
command `v.open(mode="r")`, where `v=VectorTopo('streams',
'test_stream_order')`.
>
> I am not sure if this is a valid way to test but I ran the `v.open()`
command manually within python (within a GRASS session):
> {{{
> from grass.script import core as grass
> from grass.pygrass.vector import VectorTopo
> v = VectorTopo('streams','PERMANENT')
> v.open(mode="r")
> v.close()
> }}}
>
> This causes (not sure if this is a valid approach/related):
> {{{
> Traceback (most recent call last):
> File "<stdin>", line 1, in <module>
> File
"/Applications/GRASS-7.4.1.app/Contents/Resources/etc/python/grass/pygrass/vector/__init__.py",
line 638, in close
> super(VectorTopo, self).close(build=build)
> File
"/Applications/GRASS-7.4.1.app/Contents/Resources/etc/python/grass/pygrass/vector/abstract.py",
line 402, in close
> if self.is_open():
> File
"/Applications/GRASS-7.4.1.app/Contents/Resources/etc/python/grass/pygrass/vector/abstract.py",
line 283, in is_open
> return is_open(self.c_mapinfo)
> File
"/Applications/GRASS-7.4.1.app/Contents/Resources/etc/python/grass/pygrass/vector/abstract.py",
line 21, in is_open
> return (c_mapinfo.contents.open != 0 and
> AttributeError: 'struct_Map_info' object has no attribute 'open'
> }}}
This does not make sense because the struct Map_info does have an
attribute open:
https://trac.osgeo.org/grass/browser/grass/trunk/include/vect/dig_structs.h#L1296
However, I found a problem in pygrass:
https://trac.osgeo.org/grass/browser/grass/trunk/lib/python/pygrass/vector/abstract.py#L77
self.c_mapinfo must be a struct, not a pointer to a struct. This can cause
a segfault because it seems that the memory for self.c_mapinfo has not
been allocated.
--
Ticket URL: <https://trac.osgeo.org/grass/ticket/3593#comment:7>
GRASS GIS <https://grass.osgeo.org>
More information about the grass-dev
mailing list