[geos-devel] possible memory leak in InteriorPointArea

Peter Körner osm-lists at mazdermind.de
Wed Sep 7 17:01:41 EDT 2011


Hi

>> Digging little deeper it seems that it just happens when I pass a
>> invalid polygon into the InteriorPointArea class. It throws an
>>    TopologyException: found non-noded intersection between ...
>>
>> and exists the function before the pointer is freed. This makes me
>> think, if I'm supposed to do additional checks before I pass my
>> polygon to the InteriorPointArea class.
>
> Well, if the object is created by the InteriorPointArea class it
> should be deleted by it before throwing, so it _is_ a bug.
> Could you please file a ticket for this ?
> Best if with a very small example of an invalid polygon...

I have a test case and am willing to file a bug report, but I'm unable 
to submit the form at https://www2.osgeo.org/cgi-bin/ldap_create_user.py 
- it always tells me that the "User Creation Failed" without giving a 
hint if my username does already exists or my password is too complex or 
.. whatever.

Thus I attached the testcase to that email. I ran it like that to see 
the memleak:

peter at spock:~/geos$ g++ -I./src/ -L./src/.libs/ -lgeos 
InteriorPointAreaMemleakTest.cpp -o InteriorPointAreaMemleakTest
peter at spock:~/geos$ LD_LIBRARY_PATH=./src/.libs/ valgrind 
--leak-check=full ./InteriorPointAreaMemleakTest



resulting in that leak log:

==7153== 184 (56 direct, 128 indirect) bytes in 1 blocks are definitely 
lost in loss record 5 of 5
==7153==    at 0x4C28B42: operator new(unsigned long) 
(vg_replace_malloc.c:261)
==7153==    by 0x4EE73F2: 
geos::geom::GeometryFactory::createLineString(geos::geom::CoordinateSequence*) 
const (GeometryFactory.cpp:561)
==7153==    by 0x4ECFBED: 
geos::algorithm::InteriorPointArea::addPolygon(geos::geom::Geometry 
const*) (InteriorPointArea.cpp:93)
==7153==    by 0x400FCE: main (in 
/home/peter/geos/InteriorPointAreaMemleakTest)
==7153==
==7153== LEAK SUMMARY:
==7153==    definitely lost: 56 bytes in 1 blocks
==7153==    indirectly lost: 128 bytes in 4 blocks
==7153==      possibly lost: 0 bytes in 0 blocks
==7153==    still reachable: 0 bytes in 0 blocks
==7153==         suppressed: 0 bytes in 0 blocks


Peter
-------------- next part --------------
A non-text attachment was scrubbed...
Name: InteriorPointAreaMemleakTest.cpp
Type: text/x-c++src
Size: 909 bytes
Desc: not available
Url : http://lists.osgeo.org/pipermail/geos-devel/attachments/20110907/1e243494/InteriorPointAreaMemleakTest.bin


More information about the geos-devel mailing list