[GRASS-dev] [GRASS GIS] #3714: v.out.ogr: segfault with -n

#3714: v.out.ogr: segfault with -n
-------------------------+-------------------------
Reporter: neteler | Owner: grass-dev@…
     Type: defect | Status: new
Priority: normal | Milestone: 7.4.4
Component: Vector | Version: unspecified
Keywords: v.out.ogr | CPU: Unspecified
Platform: Unspecified |
-------------------------+-------------------------
At time -n crashes the command (tested also in G74 and later):

{{{
GRASS 7.7.svn (nc_spm_08):~ > v.out.ogr in=zipcodes_wake type=area
out=filename.shp format=ESRI_Shapefile -n
Segmentation fault (core dumped)
}}}

Debugging with user data (from ML):

{{{
GRASS 7.4.3svn (test_loc_25832):~/grassdata > gdb v.out.ogr
GNU gdb (GDB) Fedora 8.2-5.fc29
Copyright (C) 2018 Free Software Foundation, Inc.
...
Reading symbols from v.out.ogr...done.
(gdb) r in=cur_feature type=area out=filename.shp format=ESRI_Shapefile
output_layer=gebiet -n
Starting program: /home/mneteler/software/grass74/dist.x86_64-pc-linux-
gnu/bin/v.out.ogr in=cur_feature type=area out=filename.shp
format=ESRI_Shapefile output_layer=gebiet -n
...
Program received signal SIGSEGV, Segmentation fault.
Vect_get_num_dblinks (Map=0x7fffffffbb30) at level_two.c:166
166 return (Map->dblnk->n_fields);

}}}

i.e., lib/vector/Vlib/level_two.c

Debugging in trunk with North Carolina dataset:

{{{
GRASS 7.7.svn (nc_spm_08):~ > gdb v.out.ogr
GNU gdb (GDB) Fedora 8.2-5.fc29
Copyright (C) 2018 Free Software Foundation, Inc.
...
(gdb) r in=zipcodes_wake type=area out=filename.shp format=ESRI_Shapefile
-n

(gdb) bt
#0 0x00007ffff7f7cdb4 in Vect_get_num_dblinks () from
/home/mneteler/software/grass77/dist.x86_64-pc-linux-
gnu/lib/libgrass_vector.7.7.svn.so
#1 0x00007ffff7f72d04 in Vect_get_field_number () from
/home/mneteler/software/grass77/dist.x86_64-pc-linux-
gnu/lib/libgrass_vector.7.7.svn.so
#2 0x0000000000404cfe in main ()
}}}

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

#3714: v.out.ogr: segfault with -n
--------------------------+-------------------------
  Reporter: neteler | Owner: grass-dev@…
      Type: defect | Status: closed
  Priority: normal | Milestone: 7.4.4
Component: Vector | Version: unspecified
Resolution: fixed | Keywords: v.out.ogr
       CPU: Unspecified | Platform: Unspecified
--------------------------+-------------------------
Changes (by mmetz):

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

Comment:

In [changeset:"73817" 73817]:
{{{
#!CommitTicketReference repository="" revision="73817"
v.out.ogr: fix #3714, segfault with -n, fix indentation
}}}

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

#3714: v.out.ogr: segfault with -n
--------------------------+-------------------------
  Reporter: neteler | Owner: grass-dev@…
      Type: defect | Status: closed
  Priority: normal | Milestone: 7.4.4
Component: Vector | Version: unspecified
Resolution: fixed | Keywords: v.out.ogr
       CPU: Unspecified | Platform: Unspecified
--------------------------+-------------------------

Comment (by mmetz):

In [changeset:"73818" 73818]:
{{{
#!CommitTicketReference repository="" revision="73818"
v.out.ogr: fix #3714, segfault with -n (backport trunk r73817)
}}}

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

#3714: v.out.ogr: segfault with -n
--------------------------+-------------------------
  Reporter: neteler | Owner: grass-dev@…
      Type: defect | Status: closed
  Priority: normal | Milestone: 7.4.4
Component: Vector | Version: unspecified
Resolution: fixed | Keywords: v.out.ogr
       CPU: Unspecified | Platform: Unspecified
--------------------------+-------------------------

Comment (by mmetz):

In [changeset:"73819" 73819]:
{{{
#!CommitTicketReference repository="" revision="73819"
v.out.ogr: fix #3714, segfault with -n (backport trunk r73817)
}}}

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

#3714: v.out.ogr: segfault with -n
--------------------------+-------------------------
  Reporter: neteler | Owner: grass-dev@…
      Type: defect | Status: closed
  Priority: normal | Milestone: 7.4.4
Component: Vector | Version: unspecified
Resolution: fixed | Keywords: v.out.ogr
       CPU: Unspecified | Platform: Unspecified
--------------------------+-------------------------

Comment (by mmetz):

Replying to [ticket:3714 neteler]:
> At time -n crashes the command (tested also in G74 and later):
>
> {{{
> GRASS 7.7.svn (nc_spm_08):~ > v.out.ogr in=zipcodes_wake type=area
out=filename.shp format=ESRI_Shapefile -n
> Segmentation fault (core dumped)
> }}}

Note that the example is wrong because `output` must be a OGR datasource,
not a OGR layer, and `filename.shp` is a OGR layer. You can specify a OGR
layer name with `output_layer`.

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