[GRASS-dev] Re: [GRASS GIS] #175: v.to.rast labelcol= SegFault

GRASS GIS trac at osgeo.org
Wed Jun 18 09:03:58 EDT 2008


#175: v.to.rast labelcol= SegFault
----------------------+-----------------------------------------------------
  Reporter:  hamish   |       Owner:  grass-dev at lists.osgeo.org
      Type:  defect   |      Status:  new                      
  Priority:  major    |   Milestone:  6.4.0                    
 Component:  default  |     Version:  unspecified              
Resolution:           |    Keywords:  v.to.rast                
----------------------+-----------------------------------------------------
Comment (by hamish):

 perhaps a red herring:

 in gdb frame # 2 the raster cat source string is:
 {{{
   s=0x808c450 "\"NO DATA\""
 }}}

 note this is raster category 0. The vector map version of "fields" has a
 cat 0, so maybe that's legal, albeit uncommon, vector cat value.



 but more to the point, this is where/why it SegFaults:

 lib/db/dbmi_client/select.c
 {{{
   if ( count == 0 ) db_copy_value ( val, value );
   // ie copy(destination, source)
 }}}

 the destination memory address (val->s->string) is out of bounds. nalloc
 is 48, which seems ok.


 that variable is created in v.to.rast/support.c line 296 with:
   dbValue value;
 and then passed to db_select_value().

 dbValue is defined in include/dbmi.h:
 {{{
  typedef struct _db_value {
     char       isNull;
     int        i;
     double     d;
     dbString   s;
     dbDateTime t;
  } dbValue;
 ...
  typedef struct _db_string {
     char *string;
     int nalloc;
  } dbString;
 }}}


 so that dbString is being used as a target without having been malloc'd
 first? I am not sure where s->nalloc=48 gets set, that's a bit of a
 mystery to me.


 Hamish

-- 
Ticket URL: <http://trac.osgeo.org/grass/ticket/175#comment:3>
GRASS GIS <http://grass.osgeo.org>


More information about the grass-dev mailing list