[GRASS-dev] Re: [GDAL] #2537: gdal.Open() and ogr.Open() GRASS data does not close projection files properly.

GDAL trac at osgeo.org
Wed Aug 27 15:48:15 EDT 2008


#2537: gdal.Open()  and ogr.Open() GRASS data does not close projection files
properly.
-------------------------+--------------------------------------------------
 Reporter:  cgsbob       |        Owner:  warmerdam
     Type:  defect       |       Status:  closed   
 Priority:  normal       |    Milestone:  1.6.0    
Component:  GDAL_Raster  |      Version:  svn-trunk
 Severity:  critical     |   Resolution:  fixed    
 Keywords:  grass        |  
-------------------------+--------------------------------------------------
Changes (by rouault):

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

Comment:

 I've commited in r15235 the call to Vect_close() in the destructor for
 OGRGRASSDataSource. I've verified that it closes the filed descriptors
 that were opened with the previous version, however there are still huge
 memory leaks (worse than for the GDAL part I think).

 See :

 {{{
 ==32276== ERROR SUMMARY: 13 errors from 5 contexts (suppressed: 159 from
 1)
 ==32276== malloc/free: in use at exit: 140,837 bytes in 2,746 blocks.
 ==32276== malloc/free: 5,366 allocs, 2,620 frees, 464,954 bytes allocated.
 ==32276== For counts of detected errors, rerun with: -v
 ==32276== searching for pointers to 2,746 not-freed blocks.
 ==32276== checked 5,339,516 bytes.
 ==32276==
 ==32276==
 ==32276== 17 bytes in 1 blocks are definitely lost in loss record 7 of 37
 ==32276==    at 0x4022765: malloc (vg_replace_malloc.c:149)
 ==32276==    by 0x610FC47: vasprintf (in /lib/tls/i686/cmov/libc-2.6.1.so)
 ==32276==    by 0x7312D02: G_vasprintf (asprintf.c:61)
 ==32276==    by 0x7312D39: G_asprintf (asprintf.c:122)
 ==32276==    by 0x73825D7: GPJ_grass_to_osr (convert.c:200)
 ==32276==    by 0x7381E57: GPJ_grass_to_wkt (convert.c:59)
 ==32276==    by 0x5245CE5: OGRGRASSLayer::OGRGRASSLayer(int, Map_info*)
 (ogrgrasslayer.cpp:204)
 ==32276==    by 0x5242A5E: OGRGRASSDataSource::Open(char const*, int, int,
 int) (ogrgrassdatasource.cpp:210)
 ==32276==    by 0x5242147: OGRGRASSDriver::Open(char const*, int)
 (ogrgrassdriver.cpp:61)
 ==32276==    by 0x4B05859: OGRSFDriverRegistrar::Open(char const*, int,
 OGRSFDriver**) (ogrsfdriverregistrar.cpp:205)
 ==32276==    by 0x804BA1F: main (ogrinfo.cpp:173)
 ==32276==
 ==32276==
 ==32276== 156 (36 direct, 120 indirect) bytes in 1 blocks are definitely
 lost in loss record 16 of 37
 ==32276==    at 0x4022765: malloc (vg_replace_malloc.c:149)
 ==32276==    by 0x61939B2: (within /lib/tls/i686/cmov/libc-2.6.1.so)
 ==32276==    by 0x6194208: __nss_database_lookup (in
 /lib/tls/i686/cmov/libc-2.6.1.so)
 ==32276==    by 0x7599FDB: ???
 ==32276==    by 0x759B11C: ???
 ==32276==    by 0x6140EEB: getpwuid_r (in
 /lib/tls/i686/cmov/libc-2.6.1.so)
 ==32276==    by 0x614089D: getpwuid (in /lib/tls/i686/cmov/libc-2.6.1.so)
 ==32276==    by 0x734E9EC: G_whoami (whoami.c:70)
 ==32276==    by 0x73E1CCC: Vect__init_head (init_head.c:44)
 ==32276==    by 0x73ECC31: Vect__open_old (open.c:145)
 ==32276==    by 0x73ED837: Vect_open_old (open.c:412)
 ==32276==    by 0x5242969: OGRGRASSDataSource::Open(char const*, int, int,
 int) (ogrgrassdatasource.cpp:190)
 ==32276==
 ==32276==
 ==32276== 72 bytes in 1 blocks are possibly lost in loss record 19 of 37
 ==32276==    at 0x4022765: malloc (vg_replace_malloc.c:149)
 ==32276==    by 0x7446B2E: dig_alloc_line (struct_alloc.c:114)
 ==32276==    by 0x7440D75: dig_Rd_P_line (plus_struct.c:166)
 ==32276==    by 0x743DEF3: dig_load_plus (plus.c:302)
 ==32276==    by 0x73EE3B3: Vect_open_topo (open.c:748)
 ==32276==    by 0x73ED0F8: Vect__open_old (open.c:228)
 ==32276==    by 0x73ED837: Vect_open_old (open.c:412)
 ==32276==    by 0x5242969: OGRGRASSDataSource::Open(char const*, int, int,
 int) (ogrgrassdatasource.cpp:190)
 ==32276==    by 0x5242147: OGRGRASSDriver::Open(char const*, int)
 (ogrgrassdriver.cpp:61)
 ==32276==    by 0x4B05859: OGRSFDriverRegistrar::Open(char const*, int,
 OGRSFDriver**) (ogrsfdriverregistrar.cpp:205)
 ==32276==    by 0x804BA1F: main (ogrinfo.cpp:173)
 ==32276==
 ==32276==
 ==32276== 476 bytes in 1 blocks are possibly lost in loss record 23 of 37
 ==32276==    at 0x4022765: malloc (vg_replace_malloc.c:149)
 ==32276==    by 0x744D049: RTreeNewNode (node.c:49)
 ==32276==    by 0x744C22E: RTreeNewIndex (index.c:29)
 ==32276==    by 0x7444DF4: dig_spidx_init (spindex.c:36)
 ==32276==    by 0x743D964: dig_init_plus (plus.c:94)
 ==32276==    by 0x73ECC42: Vect__open_old (open.c:146)
 ==32276==    by 0x73ED837: Vect_open_old (open.c:412)
 ==32276==    by 0x5242969: OGRGRASSDataSource::Open(char const*, int, int,
 int) (ogrgrassdatasource.cpp:190)
 ==32276==    by 0x5242147: OGRGRASSDriver::Open(char const*, int)
 (ogrgrassdriver.cpp:61)
 ==32276==    by 0x4B05859: OGRSFDriverRegistrar::Open(char const*, int,
 OGRSFDriver**) (ogrsfdriverregistrar.cpp:205)
 ==32276==    by 0x804BA1F: main (ogrinfo.cpp:173)
 ==32276==
 ==32276==
 ==32276== 3,332 bytes in 7 blocks are definitely lost in loss record 29 of
 37
 ==32276==    at 0x4022765: malloc (vg_replace_malloc.c:149)
 ==32276==    by 0x744D049: RTreeNewNode (node.c:49)
 ==32276==    by 0x744C22E: RTreeNewIndex (index.c:29)
 ==32276==    by 0x7444E04: dig_spidx_init (spindex.c:37)
 ==32276==    by 0x743D964: dig_init_plus (plus.c:94)
 ==32276==    by 0x73ECC42: Vect__open_old (open.c:146)
 ==32276==    by 0x73ED837: Vect_open_old (open.c:412)
 ==32276==    by 0x5242969: OGRGRASSDataSource::Open(char const*, int, int,
 int) (ogrgrassdatasource.cpp:190)
 ==32276==    by 0x5242147: OGRGRASSDriver::Open(char const*, int)
 (ogrgrassdriver.cpp:61)
 ==32276==    by 0x4B05859: OGRSFDriverRegistrar::Open(char const*, int,
 OGRSFDriver**) (ogrsfdriverregistrar.cpp:205)
 ==32276==    by 0x804BA1F: main (ogrinfo.cpp:173)
 ==32276==
 ==32276==
 ==32276== 11,695 (1,903 direct, 9,792 indirect) bytes in 17 blocks are
 definitely lost in loss record 31 of 37
 ==32276==    at 0x4022765: malloc (vg_replace_malloc.c:149)
 ==32276==    by 0x7310CF1: G_malloc (alloc.c:41)
 ==32276==    by 0x743A5E9: dig_cidx_init (cindex.c:35)
 ==32276==    by 0x743D96F: dig_init_plus (plus.c:95)
 ==32276==    by 0x73ECC42: Vect__open_old (open.c:146)
 ==32276==    by 0x73ED837: Vect_open_old (open.c:412)
 ==32276==    by 0x5242969: OGRGRASSDataSource::Open(char const*, int, int,
 int) (ogrgrassdatasource.cpp:190)
 ==32276==    by 0x5242147: OGRGRASSDriver::Open(char const*, int)
 (ogrgrassdriver.cpp:61)
 ==32276==    by 0x4B05859: OGRSFDriverRegistrar::Open(char const*, int,
 OGRSFDriver**) (ogrsfdriverregistrar.cpp:205)
 ==32276==    by 0x804BA1F: main (ogrinfo.cpp:173)
 ==32276==
 ==32276==
 ==32276== 108,952 (5,260 direct, 103,692 indirect) bytes in 4 blocks are
 definitely lost in loss record 32 of 37
 ==32276==    at 0x4022765: malloc (vg_replace_malloc.c:149)
 ==32276==    by 0x40227EF: realloc (vg_replace_malloc.c:306)
 ==32276==    by 0x7446AD3: dig_alloc_nodes (struct_alloc.c:99)
 ==32276==    by 0x743DE38: dig_load_plus (plus.c:290)
 ==32276==    by 0x73EE3B3: Vect_open_topo (open.c:748)
 ==32276==    by 0x73ED0F8: Vect__open_old (open.c:228)
 ==32276==    by 0x73ED837: Vect_open_old (open.c:412)
 ==32276==    by 0x5242969: OGRGRASSDataSource::Open(char const*, int, int,
 int) (ogrgrassdatasource.cpp:190)
 ==32276==    by 0x5242147: OGRGRASSDriver::Open(char const*, int)
 (ogrgrassdriver.cpp:61)
 ==32276==    by 0x4B05859: OGRSFDriverRegistrar::Open(char const*, int,
 OGRSFDriver**) (ogrsfdriverregistrar.cpp:205)
 ==32276==    by 0x804BA1F: main (ogrinfo.cpp:173)
 ==32276==
 ==32276== LEAK SUMMARY:
 ==32276==    definitely lost: 10,548 bytes in 30 blocks.
 ==32276==    indirectly lost: 113,604 bytes in 2,608 blocks.
 ==32276==      possibly lost: 548 bytes in 2 blocks.
 ==32276==    still reachable: 16,137 bytes in 106 blocks.
 ==32276==         suppressed: 0 bytes in 0 blocks.
 ==32276== Reachable blocks (those to which a pointer was found) are not
 shown.
 ==32276== To see them, rerun with: --leak-check=full --show-reachable=yes
 }}}

 In that state of the GRASS librairies, it can be used one time per
 process, and not in a loop of thousands of iterations.

 I close the bug, as the remaining issues are no more in the GDAL/OGR part.

-- 
Ticket URL: <http://trac.osgeo.org/gdal/ticket/2537#comment:14>
GDAL <http://trac.osgeo.org/gdal/>
Geospatial Data Abstraction Library is a translator library for raster and vector geospatial data formats.


More information about the grass-dev mailing list