cyang1/depixelize

Infinite loop or segmentation fault on every input

Opened this issue · 1 comments

Hi, thanks for this repo. Unfortunately, I'm getting segfault or never ending loop on every input...

For input smw_mario_input, program running on 100% CPU and never ends. Here is a Valgrind output

==23787== Memcheck, a memory error detector
==23787== Copyright (C) 2002-2013, and GNU GPL'd, by Julian Seward et al.
==23787== Using Valgrind-3.10.0.SVN and LibVEX; rerun with -h for copyright info
==23787== Command: ./depixelize -o out.svg images/smw_mario_input.png
==23787== 
==23787== Conditional jump or move depends on uninitialised value(s)
==23787==    at 0x6991A28: ippicvGetCpuFeatures (in /usr/local/lib/libopencv_core.so.3.0.0)
==23787==    by 0x68242B2: ippicvStaticInit (in /usr/local/lib/libopencv_core.so.3.0.0)
==23787==    by 0x53039F8: _GLOBAL__sub_I_deriv.cpp (in /usr/local/lib/libopencv_imgproc.so.3.0.0)
==23787==    by 0x4010139: call_init.part.0 (dl-init.c:78)
==23787==    by 0x4010222: _dl_init (dl-init.c:36)
==23787==    by 0x4001309: ??? (in /lib/x86_64-linux-gnu/ld-2.19.so)
==23787==    by 0x3: ???
==23787==    by 0xFFF00025E: ???
==23787==    by 0xFFF00026B: ???
==23787==    by 0xFFF00026E: ???
==23787==    by 0xFFF000276: ???
==23787== 
==23787== Conditional jump or move depends on uninitialised value(s)
==23787==    at 0x6991A28: ippicvGetCpuFeatures (in /usr/local/lib/libopencv_core.so.3.0.0)
==23787==    by 0x68242B2: ippicvStaticInit (in /usr/local/lib/libopencv_core.so.3.0.0)
==23787==    by 0x5303AA8: _GLOBAL__sub_I_sumpixels.cpp (in /usr/local/lib/libopencv_imgproc.so.3.0.0)
==23787==    by 0x4010139: call_init.part.0 (dl-init.c:78)
==23787==    by 0x4010222: _dl_init (dl-init.c:36)
==23787==    by 0x4001309: ??? (in /lib/x86_64-linux-gnu/ld-2.19.so)
==23787==    by 0x3: ???
==23787==    by 0xFFF00025E: ???
==23787==    by 0xFFF00026B: ???
==23787==    by 0xFFF00026E: ???
==23787==    by 0xFFF000276: ???
==23787== 
==23787== Conditional jump or move depends on uninitialised value(s)
==23787==    at 0x6991A28: ippicvGetCpuFeatures (in /usr/local/lib/libopencv_core.so.3.0.0)
==23787==    by 0x68242B2: ippicvStaticInit (in /usr/local/lib/libopencv_core.so.3.0.0)
==23787==    by 0x5303AF8: _GLOBAL__sub_I_imgwarp.cpp (in /usr/local/lib/libopencv_imgproc.so.3.0.0)
==23787==    by 0x4010139: call_init.part.0 (dl-init.c:78)
==23787==    by 0x4010222: _dl_init (dl-init.c:36)
==23787==    by 0x4001309: ??? (in /lib/x86_64-linux-gnu/ld-2.19.so)
==23787==    by 0x3: ???
==23787==    by 0xFFF00025E: ???
==23787==    by 0xFFF00026B: ???
==23787==    by 0xFFF00026E: ???
==23787==    by 0xFFF000276: ???
==23787== 
==23787== Invalid read of size 4
==23787==    at 0x97779A9: ??? (in /usr/lib/x86_64-linux-gnu/libOpenCL.so.1.0.0)
==23787==    by 0x9777F28: ??? (in /usr/lib/x86_64-linux-gnu/libOpenCL.so.1.0.0)
==23787==    by 0x4010139: call_init.part.0 (dl-init.c:78)
==23787==    by 0x4010222: _dl_init (dl-init.c:36)
==23787==    by 0x4014C6F: dl_open_worker (dl-open.c:577)
==23787==    by 0x400FFF3: _dl_catch_error (dl-error.c:187)
==23787==    by 0x40143BA: _dl_open (dl-open.c:661)
==23787==    by 0x8B3902A: dlopen_doit (dlopen.c:66)
==23787==    by 0x400FFF3: _dl_catch_error (dl-error.c:187)
==23787==    by 0x8B3962C: _dlerror_run (dlerror.c:163)
==23787==    by 0x8B390C0: dlopen@@GLIBC_2.2.5 (dlopen.c:87)
==23787==    by 0x66C9A17: (anonymous namespace)::opencl_fn3<58, int, unsigned int, _cl_platform_id**, unsigned int*>::switch_fn(unsigned int, _cl_platform_id**, unsigned int*) (in /usr/local/lib/libopencv_core.so.3.0.0)
==23787==  Address 0x93e7734 is 20 bytes inside a block of size 23 alloc'd
==23787==    at 0x4C2AB80: malloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==23787==    by 0x977796A: ??? (in /usr/lib/x86_64-linux-gnu/libOpenCL.so.1.0.0)
==23787==    by 0x9777F28: ??? (in /usr/lib/x86_64-linux-gnu/libOpenCL.so.1.0.0)
==23787==    by 0x4010139: call_init.part.0 (dl-init.c:78)
==23787==    by 0x4010222: _dl_init (dl-init.c:36)
==23787==    by 0x4014C6F: dl_open_worker (dl-open.c:577)
==23787==    by 0x400FFF3: _dl_catch_error (dl-error.c:187)
==23787==    by 0x40143BA: _dl_open (dl-open.c:661)
==23787==    by 0x8B3902A: dlopen_doit (dlopen.c:66)
==23787==    by 0x400FFF3: _dl_catch_error (dl-error.c:187)
==23787==    by 0x8B3962C: _dlerror_run (dlerror.c:163)
==23787==    by 0x8B390C0: dlopen@@GLIBC_2.2.5 (dlopen.c:87)
==23787==

For another image

commander keen

$ ./depixelize -o out.svg Commander\ Keen.png 
WARNING: Primary, infinite edge...
Segmentation fault

Any idea, what's wrong? Probably, some incompatibilities in shared libraries...

according to the warning (WARNING: Primary, infinite edge...) the voronoi diagram generated an infinity edge.. and program currently doesn't clip these infinite edges.

In SplineOptimizer::initialize() the program loops through all of the generated voronoi edges and creates its own edge data structure with this code:
cur_edge = new Edge(*it);

The constructor for this edge needs a begin point and an end point. However, infinite edges do not have an end point so during construction it tries to access a null vertex which results in a segfault.

I may come up with a solution and post it later today if I can fix it.