[postgis-tickets] [PostGIS] #3971: bias in kmeans
PostGIS
trac at osgeo.org
Wed Jan 10 09:10:00 PST 2018
#3971: bias in kmeans
----------------------+---------------------------
Reporter: tilt | Owner: pramsey
Type: defect | Status: closed
Priority: medium | Milestone: PostGIS 2.4.3
Component: postgis | Version: 2.4.x
Resolution: fixed | Keywords:
----------------------+---------------------------
Comment (by Algunenano):
Hi,
I'm hitting a heap-buffer-overflow error because of these changes
{{{
==1977==ERROR: AddressSanitizer: heap-buffer-overflow on address
0x61f000002900 at pc 0x7f9825df18cd bp 0x7fff856d5be0 sp 0x7fff856d5bd0
READ of size 8 at 0x61f000002900 thread T0
#0 0x7f9825df18cc in lwkmeans_pt_distance
/home/raul/dev/public/postgis/liblwgeom/lwkmeans.c:13
#1 0x7f9825df27f0 in lwgeom_cluster_2d_kmeans
/home/raul/dev/public/postgis/liblwgeom/lwkmeans.c:173
#2 0x557ad2966598 in test_kmeans
/home/raul/dev/public/postgis/liblwgeom/cunit/cu_algorithm.c:1339
#3 0x7f9825881087 in run_single_test /tmp/yaourt-tmp-raul/aur-
cunit/src/CUnit-2.1-3/CUnit/Sources/Framework/TestRun.c:991
#4 0x7f98258812bd in run_single_suite /tmp/yaourt-tmp-raul/aur-
cunit/src/CUnit-2.1-3/CUnit/Sources/Framework/TestRun.c:876
#5 0x7f9825881736 in CU_run_all_tests /tmp/yaourt-tmp-raul/aur-
cunit/src/CUnit-2.1-3/CUnit/Sources/Framework/TestRun.c:367
#6 0x557ad29bf35c in main
/home/raul/dev/public/postgis/liblwgeom/cunit/cu_tester.c:173
#7 0x7f982519af49 in __libc_start_main
(/usr/lib/libc.so.6+0x20f49)
#8 0x557ad295c999 in _start
(/home/raul/dev/public/postgis/liblwgeom/cunit/.libs/lt-cu_tester+0x3b999)
}}}
It appears it's passing a `void **` instead of a `void *`, so I've tried
to fix it by changing the line to:
{{{
distances[j] += config.distance_method(config.objs[j],
(Pointer)¢ers_raw[i-1]);
}}}
But that reduces the cluster number from 12 to 7 so it doesn't pass the
test.
--
Ticket URL: <https://trac.osgeo.org/postgis/ticket/3971#comment:12>
PostGIS <http://trac.osgeo.org/postgis/>
The PostGIS Trac is used for bug, enhancement & task tracking, a user and developer wiki, and a view into the subversion code repository of PostGIS project.
More information about the postgis-tickets
mailing list