c++ - Uninitialised value in cmp function qsort -
i'm trying understand what's wrong code:
int mycompare( const void * v1, const void * v2 ){ const int * f1 = static_cast<const int *>(v1); const int * f2 = static_cast<const int *>(v2); if( f1[ 0 ] < f2[ 0 ] ) return -1; if( f1[ 0 ] > f2[ 0 ] ) return +1; return 0; }
this comparator function qsort work's fine when i've profiled valgrind have message in strings conditional jump or move depends on uninitialised value(s)
if( f1[ 0 ] < f2[ 0 ] ) return -1; if( f1[ 0 ] > f2[ 0 ] ) return +1;
qsort calling here
valgrind output
==25053== conditional jump or move depends on uninitialised value(s) ==25053== @ 0x66474cb: msort_with_tmp.part.0 (msort.c:83) ==25053== 0x6647221: msort_with_tmp.part.0 (msort.c:45) ==25053== 0x6647221: msort_with_tmp.part.0 (msort.c:45) ==25053== 0x664777b: qsort_r (msort.c:45) ==25053== 0x40d002: owopenclsolver::_runsort(owconfigprorerty*)(owopenclsolver.cpp:473) ==25053== 0x4114db: owphysicsfluidsimulator::simulationstep(bool) (owphysicsfluidsimulator.cpp:186) ==25053== 0x412fbc: run(int, char**, bool) (owworldsimulation.cpp:919) ==25053== 0x4058d4: main (main.cpp:95) ==25053== uninitialised value created client request ==25053== @ 0xa6af9f8: ??? (in /usr/lib/libamdocl64.so) ==25053== 0xa69bf40: ??? (in /usr/lib/libamdocl64.so) ==25053== 0xa3dcb0f: ??? (in /usr/lib/libamdocl64.so) ==25053== 0xa42deca: ??? (in /usr/lib/libamdocl64.so) ==25053== 0xa37e03f: ??? (in /usr/lib/libamdocl64.so) ==25053== 0xa3558d0: ??? (in /usr/lib/libamdocl64.so)enter code here ==25053== 0xa35a1c1: ??? (in /usr/lib/libamdocl64.so) ==25053== 0xa35a2ec: ??? (in /usr/lib/libamdocl64.so) ==25053== 0xa32972d: ??? (in /usr/lib/libamdocl64.so) ==25053== 0xa2d095e: ??? (in /usr/lib/libamdocl64.so) ==25053== 0xa337aeb: ??? (in /usr/lib/libamdocl64.so) ==25053== 0x6bdd181: start_thread (pthread_create.c:312)
update
actually in class owopenclsolver i'm using sort function have no 1 places buffer _particleindex(buffer sort than) initializing explicitly initialization going in function copy_buffer_from_device copying data opencl device host programm buffer. may problem in valgrind doesn't think _particleindex isn't init when function using it.
valgrind traces memory reads , writes , think here it's telling function happened called @ least 1 pointer memory that's never been written to, of moment of call.
Comments
Post a Comment