[GRASS-dev] [GRASS GIS] #2868: v.in.ogr Segmentation fault

#2868: v.in.ogr Segmentation fault
---------------------------+-------------------------
Reporter: DmitryKolesov | Owner: grass-dev@…
     Type: defect | Status: new
Priority: normal | Milestone: 7.0.3
Component: Default | Version: unspecified
Keywords: | CPU: Unspecified
Platform: Unspecified |
---------------------------+-------------------------
I got segmentation fault in `v.in.ogr` module with `-t` flag. To reproduce
it, type the next lines (in Lat-Lon location):

> g.version -r
GRASS 7.0.3svn (2016)
libgis Revision: 67364
libgis Date: 2015-12-24 18:07:44 +0300

> echo '{"type": "MultiPolygon", "coordinates": [[[[41.16783751473027,
49.18823659816202], [41.17928406367621, 49.19697811717231],
[41.18910195623221, 49.18532946770238], [41.204306122079,
49.16872544901082], [41.19158201698379, 49.1659820458448],
[41.18895894443899, 49.16549865975956], [41.18763568560129,
49.16499058729008], [41.16783751473027, 49.18823659816202]]]]}' >
test.geojson

> v.in.ogr -t input=test.geojson layer=OGRGeoJSON out=tmp --o
  Check if OGR layer <OGRGeoJSON> contains polygons...
  100%
  Importing 1 features (OGR layer <OGRGeoJSON>)...
  100%
  -----------------------------------------------------
  Registering primitives...
  ...
  Number of nodes: 1
  Number of primitives: 2
  Number of points: 0
  Number of lines: 0
  Number of boundaries: 1
  Number of centroids: 1
  Number of areas: 1
  Number of isles: 1

  Segmentation fault (core dumped)

But the map is created:
> v.out.ascii tmp format=wkt
POLYGON((41.16783751 49.18823660, 41.17928406 49.19697812, 41.18910196
49.18532947, 41.20430612 49.16872545, 41.19158202 49.16598205, 41.18895894
49.16549866, 41.18763569 49.16499059, 41.16783751 49.18823660))

PS If I don't use `-t` flag the error doesn't appear.

--
Ticket URL: <https://trac.osgeo.org/grass/ticket/2868&gt;
GRASS GIS <https://grass.osgeo.org>

#2868: v.in.ogr Segmentation fault
----------------------------+---------------------------------
  Reporter: DmitryKolesov | Owner: grass-dev@…
      Type: defect | Status: new
  Priority: normal | Milestone: 7.0.3
Component: Vector | Version: svn-releasebranch70
Resolution: | Keywords: v.in.ogr
       CPU: Unspecified | Platform: Unspecified
----------------------------+---------------------------------
Changes (by neteler):

* keywords: => v.in.ogr
* version: unspecified => svn-releasebranch70
* component: Default => Vector

Old description:

I got segmentation fault in `v.in.ogr` module with `-t` flag. To
reproduce it, type the next lines (in Lat-Lon location):

> g.version -r
GRASS 7.0.3svn (2016)
libgis Revision: 67364
libgis Date: 2015-12-24 18:07:44 +0300

> echo '{"type": "MultiPolygon", "coordinates": [[[[41.16783751473027,
49.18823659816202], [41.17928406367621, 49.19697811717231],
[41.18910195623221, 49.18532946770238], [41.204306122079,
49.16872544901082], [41.19158201698379, 49.1659820458448],
[41.18895894443899, 49.16549865975956], [41.18763568560129,
49.16499058729008], [41.16783751473027, 49.18823659816202]]]]}' >
test.geojson

> v.in.ogr -t input=test.geojson layer=OGRGeoJSON out=tmp --o
Check if OGR layer <OGRGeoJSON> contains polygons...
100%
Importing 1 features (OGR layer <OGRGeoJSON>)...
100%
-----------------------------------------------------
Registering primitives...
...
Number of nodes: 1
Number of primitives: 2
Number of points: 0
Number of lines: 0
Number of boundaries: 1
Number of centroids: 1
Number of areas: 1
Number of isles: 1

Segmentation fault (core dumped)

But the map is created:
> v.out.ascii tmp format=wkt
POLYGON((41.16783751 49.18823660, 41.17928406 49.19697812, 41.18910196
49.18532947, 41.20430612 49.16872545, 41.19158202 49.16598205,
41.18895894 49.16549866, 41.18763569 49.16499059, 41.16783751
49.18823660))

PS If I don't use `-t` flag the error doesn't appear.

New description:

I got segmentation fault in `v.in.ogr` module with `-t` flag. To reproduce
it, type the next lines (in Lat-Lon location):

{{{

> g.version -r
GRASS 7.0.3svn (2016)
libgis Revision: 67364
libgis Date: 2015-12-24 18:07:44 +0300

> echo '{"type": "MultiPolygon", "coordinates": [[[[41.16783751473027,
49.18823659816202], [41.17928406367621, 49.19697811717231],
[41.18910195623221, 49.18532946770238], [41.204306122079,
49.16872544901082], [41.19158201698379, 49.1659820458448],
[41.18895894443899, 49.16549865975956], [41.18763568560129,
49.16499058729008], [41.16783751473027, 49.18823659816202]]]]}' >
test.geojson

> v.in.ogr -t input=test.geojson layer=OGRGeoJSON out=tmp --o
  Check if OGR layer <OGRGeoJSON> contains polygons...
  100%
  Importing 1 features (OGR layer <OGRGeoJSON>)...
  100%
  -----------------------------------------------------
  Registering primitives...
  ...
  Number of nodes: 1
  Number of primitives: 2
  Number of points: 0
  Number of lines: 0
  Number of boundaries: 1
  Number of centroids: 1
  Number of areas: 1
  Number of isles: 1

  Segmentation fault (core dumped)
}}}

But the map is created:

{{{
> v.out.ascii tmp format=wkt
POLYGON((41.16783751 49.18823660, 41.17928406 49.19697812, 41.18910196
49.18532947, 41.20430612 49.16872545, 41.19158202 49.16598205, 41.18895894
49.16549866, 41.18763569 49.16499059, 41.16783751 49.18823660))
}}}

PS If I don't use `-t` flag the error doesn't appear.

--

--
Ticket URL: <https://trac.osgeo.org/grass/ticket/2868#comment:1&gt;
GRASS GIS <https://grass.osgeo.org>

#2868: v.in.ogr Segmentation fault
----------------------------+---------------------------------
  Reporter: DmitryKolesov | Owner: grass-dev@…
      Type: defect | Status: new
  Priority: normal | Milestone: 7.0.3
Component: Vector | Version: svn-releasebranch70
Resolution: | Keywords: v.in.ogr
       CPU: Unspecified | Platform: Unspecified
----------------------------+---------------------------------

Comment (by neteler):

I can confirm this issue on Fedora23, 64bit:

{{{
gdb v.in.ogr
(gdb) r -t input=test.geojson layer=OGRGeoJSON out=tmp --o
...
Number of nodes: 1
Number of primitives: 2
Number of points: 0
Number of lines: 0
Number of boundaries: 1
Number of centroids: 1
Number of areas: 1
Number of isles: 1

Program received signal SIGSEGV, Segmentation fault.
0x00000000004076e1 in main ()
(gdb) bt
#0 0x00000000004076e1 in main ()
(gdb) bt full
#0 0x00000000004076e1 in main ()
No symbol table info available.
}}}

The backtrace is useless, though. Strange.

--
Ticket URL: <http://trac.osgeo.org/grass/ticket/2868#comment:2&gt;
GRASS GIS <https://grass.osgeo.org>

#2868: v.in.ogr Segmentation fault
----------------------------+---------------------------------
  Reporter: DmitryKolesov | Owner: grass-dev@…
      Type: defect | Status: new
  Priority: normal | Milestone: 7.0.3
Component: Vector | Version: svn-releasebranch70
Resolution: | Keywords: v.in.ogr
       CPU: Unspecified | Platform: Unspecified
----------------------------+---------------------------------

Comment (by mlennert):

Try the attached patch: v.in.ogr tried to manipulate a database driver
even though this is only opened if the -t flag is not set.

--
Ticket URL: <https://trac.osgeo.org/grass/ticket/2868#comment:3&gt;
GRASS GIS <https://grass.osgeo.org>

#2868: v.in.ogr Segmentation fault
----------------------------+---------------------------------
  Reporter: DmitryKolesov | Owner: grass-dev@…
      Type: defect | Status: new
  Priority: normal | Milestone: 7.0.3
Component: Vector | Version: svn-releasebranch70
Resolution: | Keywords: v.in.ogr
       CPU: Unspecified | Platform: Unspecified
----------------------------+---------------------------------
Changes (by mlennert):

* Attachment "v_in_ogr_notab.diff" added.

simpler and more complete replacement of original patch

--
Ticket URL: <https://trac.osgeo.org/grass/ticket/2868&gt;
GRASS GIS <https://grass.osgeo.org>

#2868: v.in.ogr Segmentation fault
----------------------------+---------------------------------
  Reporter: DmitryKolesov | Owner: grass-dev@…
      Type: defect | Status: new
  Priority: normal | Milestone: 7.0.3
Component: Vector | Version: svn-releasebranch70
Resolution: | Keywords: v.in.ogr
       CPU: Unspecified | Platform: Unspecified
----------------------------+---------------------------------
Changes (by mlennert):

* Attachment "v_in_ogr_notab.diff" removed.

patch against trunk

--
Ticket URL: <https://trac.osgeo.org/grass/ticket/2868&gt;
GRASS GIS <https://grass.osgeo.org>

#2868: v.in.ogr Segmentation fault
----------------------------+---------------------------------
  Reporter: DmitryKolesov | Owner: grass-dev@…
      Type: defect | Status: new
  Priority: normal | Milestone: 7.0.3
Component: Vector | Version: svn-releasebranch70
Resolution: | Keywords: v.in.ogr
       CPU: Unspecified | Platform: Unspecified
----------------------------+---------------------------------

Comment (by martinl):

Patch tested and applied in trunk as r67591

--
Ticket URL: <https://trac.osgeo.org/grass/ticket/2868#comment:4&gt;
GRASS GIS <https://grass.osgeo.org>

#2868: v.in.ogr Segmentation fault
----------------------------+---------------------------------
  Reporter: DmitryKolesov | Owner: grass-dev@…
      Type: defect | Status: closed
  Priority: normal | Milestone: 7.0.5
Component: Vector | Version: svn-releasebranch70
Resolution: fixed | Keywords: v.in.ogr
       CPU: Unspecified | Platform: Unspecified
----------------------------+---------------------------------
Changes (by martinl):

* status: new => closed
* resolution: => fixed

Comment:

In [changeset:"69226" 69226]:
{{{
#!CommitTicketReference repository="" revision="69226"
v.in.ogr Segmentation fault (fix #2868) - patch by mlennert
}}}

--
Ticket URL: </ticket/2868#comment:8>
GRASS GIS <https://grass.osgeo.org>