Opened 10 years ago

Closed 10 years ago

#2949 closed defect (fixed)

Memory leaks test_mindistance2d_tolerance

Reported by: strk Owned by: pramsey
Priority: blocker Milestone: PostGIS 2.1.5
Component: postgis Version: 2.1.x
Keywords: history Cc:

Description

Valgrind reports leaks in the mindistance2d tester

==1146== HEAP SUMMARY:                                                          
==1146==     in use at exit: 17,024 bytes in 146 blocks                         
==1146==   total heap usage: 64,242 allocs, 64,096 frees, 4,456,055 bytes allocated
==1146==                                                                        
==1146== 120 (32 direct, 88 indirect) bytes in 1 blocks are definitely lost in loss record 83 of 114
==1146==    at 0x4C2AB80: malloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==1146==    by 0x4E58D19: lwcircstring_construct (lwcircstring.c:52)            
==1146==    by 0x4E63344: wkt_parser_circularstring_new (lwin_wkt.c:394)        
==1146==    by 0x4E605CF: wkt_yyparse (lwin_wkt_parse.y:443)                    
==1146==    by 0x4E6136D: lwgeom_parse_wkt (lwin_wkt_parse.y:68)                
==1146==    by 0x4E64165: lwgeom_from_wkt (lwin_wkt.c:848)                      
==1146==    by 0x4181A5: do_type_test (cu_force_sfs.c:42)                       
==1146==    by 0x418242: test_sqlmm (cu_force_sfs.c:54)                         
==1146==    by 0x50A3C99: ??? (in /usr/lib/libcunit.so.1.0.1)                   
==1146==    by 0x50A3F27: ??? (in /usr/lib/libcunit.so.1.0.1)                   
==1146==    by 0x50A42A5: CU_run_all_tests (in /usr/lib/libcunit.so.1.0.1)      
==1146==    by 0x40550F: main (cu_tester.c:144)                                 
==1146==                                                                        
==1146== 144 (8 direct, 136 indirect) bytes in 1 blocks are definitely lost in loss record 86 of 114
==1146==    at 0x4C2AB80: malloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==1146==    by 0x4E597B1: lwcurvepoly_construct_from_lwpoly (lwcurvepoly.c:50)  
==1146==    by 0x4E4E6EE: lw_dist2d_poly_curvepoly (measures.c:906)             
==1146==    by 0x4E4DE5C: lw_dist2d_recursive (measures.c:345)                  
==1146==    by 0x4E4E1D6: lwgeom_mindistance2d_tolerance (measures.c:205)       
==1146==    by 0x414241: do_test_mindistance2d_tolerance (cu_measures.c:55)     
==1146==    by 0x4145C7: test_mindistance2d_tolerance (cu_measures.c:166)       
==1146==    by 0x50A3C99: ??? (in /usr/lib/libcunit.so.1.0.1)                   
==1146==    by 0x50A3F27: ??? (in /usr/lib/libcunit.so.1.0.1)                   
==1146==    by 0x50A42A5: CU_run_all_tests (in /usr/lib/libcunit.so.1.0.1)      
==1146==    by 0x40550F: main (cu_tester.c:144)                  
==1146==                                                                        
==1146== 144 (8 direct, 136 indirect) bytes in 1 blocks are definitely lost in loss record 87 of 114
==1146==    at 0x4C2AB80: malloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==1146==    by 0x4E597B1: lwcurvepoly_construct_from_lwpoly (lwcurvepoly.c:50)  
==1146==    by 0x4E4E6EE: lw_dist2d_poly_curvepoly (measures.c:906)             
==1146==    by 0x4E4DE5C: lw_dist2d_recursive (measures.c:345)                  
==1146==    by 0x4E4E1D6: lwgeom_mindistance2d_tolerance (measures.c:205)       
==1146==    by 0x414241: do_test_mindistance2d_tolerance (cu_measures.c:55)     
==1146==    by 0x4145DF: test_mindistance2d_tolerance (cu_measures.c:167)       
==1146==    by 0x50A3C99: ??? (in /usr/lib/libcunit.so.1.0.1)                   
==1146==    by 0x50A3F27: ??? (in /usr/lib/libcunit.so.1.0.1)                   
==1146==    by 0x50A42A5: CU_run_all_tests (in /usr/lib/libcunit.so.1.0.1)      
==1146==    by 0x40550F: main (cu_tester.c:144)                                 
==1146==                                                                        
==1146== 144 (8 direct, 136 indirect) bytes in 1 blocks are definitely lost in loss record 88 of 114
==1146==    at 0x4C2AB80: malloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==1146==    by 0x4E597B1: lwcurvepoly_construct_from_lwpoly (lwcurvepoly.c:50)  
==1146==    by 0x4E4E6EE: lw_dist2d_poly_curvepoly (measures.c:906)             
==1146==    by 0x4E4DE5C: lw_dist2d_recursive (measures.c:345)                  
==1146==    by 0x4E4E1D6: lwgeom_mindistance2d_tolerance (measures.c:205)       
==1146==    by 0x414241: do_test_mindistance2d_tolerance (cu_measures.c:55)     
==1146==    by 0x414647: test_mindistance2d_tolerance (cu_measures.c:180)       
==1146==    by 0x50A3C99: ??? (in /usr/lib/libcunit.so.1.0.1)                   
==1146==    by 0x50A3F27: ??? (in /usr/lib/libcunit.so.1.0.1)                   
==1146==    by 0x50A42A5: CU_run_all_tests (in /usr/lib/libcunit.so.1.0.1)      
==1146==    by 0x40550F: main (cu_tester.c:144)                  
==1146==                                                                        
==1146== 144 (8 direct, 136 indirect) bytes in 1 blocks are definitely lost in loss record 89 of 114
==1146==    at 0x4C2AB80: malloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==1146==    by 0x4E597B1: lwcurvepoly_construct_from_lwpoly (lwcurvepoly.c:50)  
==1146==    by 0x4E4E6EE: lw_dist2d_poly_curvepoly (measures.c:906)             
==1146==    by 0x4E4DE5C: lw_dist2d_recursive (measures.c:345)                  
==1146==    by 0x4E4E1D6: lwgeom_mindistance2d_tolerance (measures.c:205)       
==1146==    by 0x414241: do_test_mindistance2d_tolerance (cu_measures.c:55)     
==1146==    by 0x4146C3: test_mindistance2d_tolerance (cu_measures.c:185)       
==1146==    by 0x50A3C99: ??? (in /usr/lib/libcunit.so.1.0.1)                   
==1146==    by 0x50A3F27: ??? (in /usr/lib/libcunit.so.1.0.1)                   
==1146==    by 0x50A42A5: CU_run_all_tests (in /usr/lib/libcunit.so.1.0.1)      
==1146==    by 0x40550F: main (cu_tester.c:144)                                 
==1146==                                                                        
==1146== 216 (8 direct, 208 indirect) bytes in 1 blocks are definitely lost in loss record 90 of 114
==1146==    at 0x4C2AB80: malloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==1146==    by 0x4E597B1: lwcurvepoly_construct_from_lwpoly (lwcurvepoly.c:50)  
==1146==    by 0x4E4E6EE: lw_dist2d_poly_curvepoly (measures.c:906)             
==1146==    by 0x4E4DE5C: lw_dist2d_recursive (measures.c:345)                  
==1146==    by 0x4E4E1D6: lwgeom_mindistance2d_tolerance (measures.c:205)       
==1146==    by 0x414241: do_test_mindistance2d_tolerance (cu_measures.c:55)     
==1146==    by 0x4145AF: test_mindistance2d_tolerance (cu_measures.c:165)       
==1146==    by 0x50A3C99: ??? (in /usr/lib/libcunit.so.1.0.1)                   
==1146==    by 0x50A3F27: ??? (in /usr/lib/libcunit.so.1.0.1)                   
==1146==    by 0x50A42A5: CU_run_all_tests (in /usr/lib/libcunit.so.1.0.1)      
==1146==    by 0x40550F: main (cu_tester.c:144)
==1146==                                                                        
==1146== 216 (8 direct, 208 indirect) bytes in 1 blocks are definitely lost in loss record 91 of 114
==1146==    at 0x4C2AB80: malloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==1146==    by 0x4E597B1: lwcurvepoly_construct_from_lwpoly (lwcurvepoly.c:50)  
==1146==    by 0x4E4E6EE: lw_dist2d_poly_curvepoly (measures.c:906)             
==1146==    by 0x4E4DE5C: lw_dist2d_recursive (measures.c:345)                  
==1146==    by 0x4E4E1D6: lwgeom_mindistance2d_tolerance (measures.c:205)       
==1146==    by 0x414241: do_test_mindistance2d_tolerance (cu_measures.c:55)     
==1146==    by 0x41462F: test_mindistance2d_tolerance (cu_measures.c:179)       
==1146==    by 0x50A3C99: ??? (in /usr/lib/libcunit.so.1.0.1)                   
==1146==    by 0x50A3F27: ??? (in /usr/lib/libcunit.so.1.0.1)                   
==1146==    by 0x50A42A5: CU_run_all_tests (in /usr/lib/libcunit.so.1.0.1)      
==1146==    by 0x40550F: main (cu_tester.c:144)                                 
==1146==                                                                        
==1146== 216 (8 direct, 208 indirect) bytes in 1 blocks are definitely lost in loss record 92 of 114
==1146==    at 0x4C2AB80: malloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==1146==    by 0x4E597B1: lwcurvepoly_construct_from_lwpoly (lwcurvepoly.c:50)  
==1146==    by 0x4E4E6EE: lw_dist2d_poly_curvepoly (measures.c:906)             
==1146==    by 0x4E4DE5C: lw_dist2d_recursive (measures.c:345)                  
==1146==    by 0x4E4E1D6: lwgeom_mindistance2d_tolerance (measures.c:205)       
==1146==    by 0x414241: do_test_mindistance2d_tolerance (cu_measures.c:55)     
==1146==    by 0x41465F: test_mindistance2d_tolerance (cu_measures.c:181)       
==1146==    by 0x50A3C99: ??? (in /usr/lib/libcunit.so.1.0.1)                   
==1146==    by 0x50A3F27: ??? (in /usr/lib/libcunit.so.1.0.1)                   
==1146==    by 0x50A42A5: CU_run_all_tests (in /usr/lib/libcunit.so.1.0.1)      
==1146==    by 0x40550F: main (cu_tester.c:144)
==1146==                                                                        
==1146== 216 (8 direct, 208 indirect) bytes in 1 blocks are definitely lost in loss record 93 of 114
==1146==    at 0x4C2AB80: malloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==1146==    by 0x4E597B1: lwcurvepoly_construct_from_lwpoly (lwcurvepoly.c:50)  
==1146==    by 0x4E4E6EE: lw_dist2d_poly_curvepoly (measures.c:906)             
==1146==    by 0x4E4DE5C: lw_dist2d_recursive (measures.c:345)                  
==1146==    by 0x4E4E1D6: lwgeom_mindistance2d_tolerance (measures.c:205)       
==1146==    by 0x414241: do_test_mindistance2d_tolerance (cu_measures.c:55)     
==1146==    by 0x414677: test_mindistance2d_tolerance (cu_measures.c:182)       
==1146==    by 0x50A3C99: ??? (in /usr/lib/libcunit.so.1.0.1)                   
==1146==    by 0x50A3F27: ??? (in /usr/lib/libcunit.so.1.0.1)                   
==1146==    by 0x50A42A5: CU_run_all_tests (in /usr/lib/libcunit.so.1.0.1)      
==1146==    by 0x40550F: main (cu_tester.c:144)                                 
==1146==                                                                        
==1146== 216 (8 direct, 208 indirect) bytes in 1 blocks are definitely lost in loss record 94 of 114
==1146==    at 0x4C2AB80: malloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==1146==    by 0x4E597B1: lwcurvepoly_construct_from_lwpoly (lwcurvepoly.c:50)  
==1146==    by 0x4E4E6EE: lw_dist2d_poly_curvepoly (measures.c:906)             
==1146==    by 0x4E4DE5C: lw_dist2d_recursive (measures.c:345)                  
==1146==    by 0x4E4E1D6: lwgeom_mindistance2d_tolerance (measures.c:205)       
==1146==    by 0x414241: do_test_mindistance2d_tolerance (cu_measures.c:55)     
==1146==    by 0x414693: test_mindistance2d_tolerance (cu_measures.c:183)       
==1146==    by 0x50A3C99: ??? (in /usr/lib/libcunit.so.1.0.1)                   
==1146==    by 0x50A3F27: ??? (in /usr/lib/libcunit.so.1.0.1)                   
==1146==    by 0x50A42A5: CU_run_all_tests (in /usr/lib/libcunit.so.1.0.1)      
==1146==    by 0x40550F: main (cu_tester.c:144) 
==1146==                                                                        
==1146== 216 (8 direct, 208 indirect) bytes in 1 blocks are definitely lost in loss record 95 of 114
==1146==    at 0x4C2AB80: malloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==1146==    by 0x4E597B1: lwcurvepoly_construct_from_lwpoly (lwcurvepoly.c:50)  
==1146==    by 0x4E4E6EE: lw_dist2d_poly_curvepoly (measures.c:906)             
==1146==    by 0x4E4DE5C: lw_dist2d_recursive (measures.c:345)                  
==1146==    by 0x4E4E1D6: lwgeom_mindistance2d_tolerance (measures.c:205)       
==1146==    by 0x414241: do_test_mindistance2d_tolerance (cu_measures.c:55)     
==1146==    by 0x4146AB: test_mindistance2d_tolerance (cu_measures.c:184)       
==1146==    by 0x50A3C99: ??? (in /usr/lib/libcunit.so.1.0.1)                   
==1146==    by 0x50A3F27: ??? (in /usr/lib/libcunit.so.1.0.1)                   
==1146==    by 0x50A42A5: CU_run_all_tests (in /usr/lib/libcunit.so.1.0.1)      
==1146==    by 0x40550F: main (cu_tester.c:144)                                 
==1146==                                                                        
==1146== 216 (8 direct, 208 indirect) bytes in 1 blocks are definitely lost in loss record 96 of 114
==1146==    at 0x4C2AB80: malloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==1146==    by 0x4E597B1: lwcurvepoly_construct_from_lwpoly (lwcurvepoly.c:50)  
==1146==    by 0x4E4E6EE: lw_dist2d_poly_curvepoly (measures.c:906)             
==1146==    by 0x4E4DE5C: lw_dist2d_recursive (measures.c:345)                  
==1146==    by 0x4E4E1D6: lwgeom_mindistance2d_tolerance (measures.c:205)       
==1146==    by 0x414241: do_test_mindistance2d_tolerance (cu_measures.c:55)     
==1146==    by 0x4146DF: test_mindistance2d_tolerance (cu_measures.c:186)       
==1146==    by 0x50A3C99: ??? (in /usr/lib/libcunit.so.1.0.1)                   
==1146==    by 0x50A3F27: ??? (in /usr/lib/libcunit.so.1.0.1)                   
==1146==    by 0x50A42A5: CU_run_all_tests (in /usr/lib/libcunit.so.1.0.1)      
==1146==    by 0x40550F: main (cu_tester.c:144)

I hadn't tested 2.1

Change History (3)

comment:1 by strk, 10 years ago

Milestone: PostGIS 2.2.0PostGIS 2.1.5
Version: trunk2.1.x

2.1.x branch is also affected (as of r13011), 2.0.x branch is not (as of r12970)

comment:2 by strk, 10 years ago

Priority: mediumblocker

The problem is with lwcurvepoly_construct_from_lwpoly, partially allocating new memory (for "rings") and partially copying pointer from input memory (bbox). Cloning the box and using lwgeom_release from the callers fixes it.

Committed as 13021 in trunk (2.2.0) and r13022 in 2.1 branch (2.1.5)

comment:3 by strk, 10 years ago

Keywords: history added
Resolution: fixed
Status: newclosed
Note: See TracTickets for help on using tickets.