zlib_IPP segmentation fault

zlib_IPP segmentation fault

Hi,

I have tried intel zlib_ipp patches on zlib zlib-1.2.8 using 2017 intel compilers. I made a small test program to deflate data. This small program runs correctly when I use the normal zlib-1.2.8 library. However using the intel zlib ipp patches, my test program gives a segmentation fault. I use valgrind to debug, however I don't quit understand what the problem is. To my understanding this issues comes from the libippdc.so library. Is this a known issue ? Is it possible to workaround this issue. See here below how I build the zlib patched library and the valgrint output.

Building zlib IPP patched library

source /opt/intel/compilers_and_libraries_2017.1.132/linux/bin/compilervars.sh intel64
export CFLAGS="-m64 -DWITH_IPP -I$IPPROOT/include"
export LDFLAGS="-L$IPPROOT/lib/intel64 -lippdc -lipps -lippcore"
export CC=icc
./configure
make shared

ldd libz.so
        linux-vdso.so.1 =>  (0x00007fffcfdb9000)
        libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007f4443401000)
        libippdc.so => /opt/intel/compilers_and_libraries_2017.1.132/linux/ipp/lib/intel64/libippdc.so (0x00007f44431fb000)
        libipps.so => /opt/intel/compilers_and_libraries_2017.1.132/linux/ipp/lib/intel64/libipps.so (0x00007f4442fb5000)
        libippcore.so => /opt/intel/compilers_and_libraries_2017.1.132/linux/ipp/lib/intel64/libippcore.so (0x00007f4442da8000)
        libimf.so => /opt/intel/compilers_and_libraries_2017.1.132/linux/compiler/lib/intel64/libimf.so (0x00007f44428bc000)
        libsvml.so => /opt/intel/compilers_and_libraries_2017.1.132/linux/compiler/lib/intel64/libsvml.so (0x00007f44419b1000)
        libirng.so => /opt/intel/compilers_and_libraries_2017.1.132/linux/compiler/lib/intel64/libirng.so (0x00007f444163b000)
        libm.so.6 => /lib/x86_64-linux-gnu/libm.so.6 (0x00007f4441332000)
        libgcc_s.so.1 => /lib/x86_64-linux-gnu/libgcc_s.so.1 (0x00007f444111c000)
        libintlc.so.5 => /opt/intel/compilers_and_libraries_2017.1.132/linux/compiler/lib/intel64/libintlc.so.5 (0x00007f4440eb1000)
        libdl.so.2 => /lib/x86_64-linux-gnu/libdl.so.2 (0x00007f4440cad000)
        /lib64/ld-linux-x86-64.so.2 (0x0000558e8e92a000)

Compress function in my test program

void compress( const char* source,
                           std::vector<char>& compressedData,
                           int sourceSize,
                           int level,
                           int window_bits,
                           int mem_level )
{
    const uint32_t buffersize = 131072; // 128 * 1024
    unsigned char buffer[buffersize];

    for(unsigned int i =0; i < buffersize; i++)
         buffer[i] = 0;

    compressedData.clear();

    // deflate
    // zlib struct
    z_stream defstream;
    defstream.zalloc = Z_NULL;
    defstream.zfree = Z_NULL;
    defstream.opaque = Z_NULL;

    deflateInit2( &defstream, level, Z_DEFLATED, window_bits, mem_level, Z_FIXED );

    defstream.next_in = (Bytef *) source;
    defstream.avail_in = sourceSize;
    uint64_t have;

    do
    {
        defstream.avail_out = buffersize;
        defstream.next_out = buffer;
        deflate( &defstream, Z_FINISH );
        have = buffersize - defstream.avail_out;
        compressedData.insert( compressedData.end(), buffer, buffer + have );
    }
    while (defstream.avail_out == 0);

    deflateEnd( &defstream );

 }

Building my test program

icpc TestMain.c -g -o TestMain -I.. -L.. -lz -std=c++11

Running the test program with valgrind output:

valgrind -v --tool=memcheck --leak-check=full --show-leak-kinds=all --leak-resolution=high ./TestMain

==42487== Memcheck, a memory error detector
==42487== Copyright (C) 2002-2015, and GNU GPL'd, by Julian Seward et al.
==42487== Using Valgrind-3.11.0 and LibVEX; rerun with -h for copyright info
==42487== Command: ./TestMain
==42487==
--42487-- Valgrind options:
--42487--    -v
--42487--    --tool=memcheck
--42487--    --leak-check=full
--42487--    --show-leak-kinds=all
--42487--    --leak-resolution=high
--42487-- Contents of /proc/version:
--42487--   Linux version 4.4.0-47-generic (buildd@lcy01-03) (gcc version 5.4.0 20160609 (Ubuntu 5.4.0-6ubuntu1~16.04.2) ) #68-Ubuntu SMP Wed Oct 26 19:39:52 UTC 2016
--42487--
--42487-- Arch and hwcaps: AMD64, LittleEndian, amd64-cx16-lzcnt-rdtscp-sse3-avx-avx2-bmi
--42487-- Page sizes: currently 4096, max supported 4096
--42487-- Valgrind library directory: /usr/lib/valgrind
--42487-- Reading syms from /home/martijn/zlib-1.2.8/TEST/TestMain
--42487-- Reading syms from /lib/x86_64-linux-gnu/ld-2.23.so
--42487--   Considering /lib/x86_64-linux-gnu/ld-2.23.so ..
--42487--   .. CRC mismatch (computed 9bc477cd wanted 3da2f12a)
--42487--   Considering /usr/lib/debug/lib/x86_64-linux-gnu/ld-2.23.so ..
--42487--   .. CRC is valid
--42487-- Reading syms from /usr/lib/valgrind/memcheck-amd64-linux
--42487--   Considering /usr/lib/valgrind/memcheck-amd64-linux ..
--42487--   .. CRC mismatch (computed eea41ea9 wanted 2009db78)
--42487--    object doesn't have a symbol table
--42487--    object doesn't have a dynamic symbol table
--42487-- Scheduler: using generic scheduler lock implementation.
--42487-- Reading suppressions file: /usr/lib/valgrind/default.supp
==42487== embedded gdbserver: reading from /tmp/vgdb-pipe-from-vgdb-to-42487-by-martijn-on-???
==42487== embedded gdbserver: writing to   /tmp/vgdb-pipe-to-vgdb-from-42487-by-martijn-on-???
==42487== embedded gdbserver: shared mem   /tmp/vgdb-pipe-shared-mem-vgdb-42487-by-martijn-on-???
==42487==
==42487== TO CONTROL THIS PROCESS USING vgdb (which you probably
==42487== don't want to do, unless you know exactly what you're doing,
==42487== or are doing some strange experiment):
==42487==   /usr/lib/valgrind/../../bin/vgdb --pid=42487 ...command...
==42487==
==42487== TO DEBUG THIS PROCESS USING GDB: start GDB like this
==42487==   /path/to/gdb ./TestMain
==42487== and then give GDB the following command
==42487==   target remote | /usr/lib/valgrind/../../bin/vgdb --pid=42487
==42487== --pid is optional if only one valgrind process is running
==42487==
--42487-- REDIR: 0x401cf90 (ld-linux-x86-64.so.2:strlen) redirected to 0x3809e181 (???)
--42487-- Reading syms from /usr/lib/valgrind/vgpreload_core-amd64-linux.so
--42487--   Considering /usr/lib/valgrind/vgpreload_core-amd64-linux.so ..
--42487--   .. CRC mismatch (computed 2567ccf6 wanted 49420590)
--42487--    object doesn't have a symbol table
--42487-- Reading syms from /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so
--42487--   Considering /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so ..
--42487--   .. CRC mismatch (computed 0e27c9a8 wanted ac585421)
--42487--    object doesn't have a symbol table
==42487== WARNING: new redirection conflicts with existing -- ignoring it
--42487--     old: 0x0401cf90 (strlen              ) R-> (0000.0) 0x3809e181 ???
--42487--     new: 0x0401cf90 (strlen              ) R-> (2007.0) 0x04c31020 strlen
--42487-- REDIR: 0x401b8e0 (ld-linux-x86-64.so.2:index) redirected to 0x4c30bc0 (index)
--42487-- REDIR: 0x401bb00 (ld-linux-x86-64.so.2:strcmp) redirected to 0x4c320d0 (strcmp)
--42487-- REDIR: 0x401dcf0 (ld-linux-x86-64.so.2:mempcpy) redirected to 0x4c35270 (mempcpy)
--42487-- Reading syms from /home/martijn/zlib-1.2.8/libz.so.1.2.8
--42487-- Reading syms from /usr/lib/x86_64-linux-gnu/libstdc++.so.6.0.21
--42487--   Considering /usr/lib/x86_64-linux-gnu/libstdc++.so.6.0.21 ..
--42487--   .. CRC mismatch (computed 834c912e wanted c67ab13d)
--42487--    object doesn't have a symbol table
--42487-- Reading syms from /lib/x86_64-linux-gnu/libm-2.23.so
--42487--   Considering /lib/x86_64-linux-gnu/libm-2.23.so ..
--42487--   .. CRC mismatch (computed 8bd88005 wanted 32b88176)
--42487--   Considering /usr/lib/debug/lib/x86_64-linux-gnu/libm-2.23.so ..
--42487--   .. CRC is valid
--42487-- Reading syms from /lib/x86_64-linux-gnu/libgcc_s.so.1
--42487--   Considering /lib/x86_64-linux-gnu/libgcc_s.so.1 ..
--42487--   .. CRC mismatch (computed b9a68419 wanted 29d51b00)
--42487--    object doesn't have a symbol table
--42487-- Reading syms from /lib/x86_64-linux-gnu/libc-2.23.so
--42487--   Considering /lib/x86_64-linux-gnu/libc-2.23.so ..
--42487--   .. CRC mismatch (computed b2979fac wanted 1affc958)
--42487--   Considering /usr/lib/debug/lib/x86_64-linux-gnu/libc-2.23.so ..
--42487--   .. CRC is valid
--42487-- Reading syms from /lib/x86_64-linux-gnu/libdl-2.23.so
--42487--   Considering /lib/x86_64-linux-gnu/libdl-2.23.so ..
--42487--   .. CRC mismatch (computed cf3e24b0 wanted fd1ac2a8)
--42487--   Considering /usr/lib/debug/lib/x86_64-linux-gnu/libdl-2.23.so ..
--42487--   .. CRC is valid
--42487-- Reading syms from /opt/intel/compilers_and_libraries_2017.1.132/linux/ipp/lib/intel64_lin/libippdc.so
--42487-- Reading syms from /opt/intel/compilers_and_libraries_2017.1.132/linux/ipp/lib/intel64_lin/libipps.so
--42487-- Reading syms from /opt/intel/compilers_and_libraries_2017.1.132/linux/ipp/lib/intel64_lin/libippcore.so
--42487-- Reading syms from /opt/intel/compilers_and_libraries_2017.1.132/linux/compiler/lib/intel64_lin/libimf.so
--42487-- Reading syms from /opt/intel/compilers_and_libraries_2017.1.132/linux/compiler/lib/intel64_lin/libsvml.so
--42487-- Reading syms from /opt/intel/compilers_and_libraries_2017.1.132/linux/compiler/lib/intel64_lin/libirng.so
--42487-- Reading syms from /opt/intel/compilers_and_libraries_2017.1.132/linux/compiler/lib/intel64_lin/libintlc.so.5
--42487-- REDIR: 0x5983a00 (libc.so.6:strcasecmp) redirected to 0x4a286f0 (_vgnU_ifunc_wrapper)
--42487-- REDIR: 0x597f280 (libc.so.6:strcspn) redirected to 0x4a286f0 (_vgnU_ifunc_wrapper)
--42487-- REDIR: 0x5985cf0 (libc.so.6:strncasecmp) redirected to 0x4a286f0 (_vgnU_ifunc_wrapper)
--42487-- REDIR: 0x59816f0 (libc.so.6:strpbrk) redirected to 0x4a286f0 (_vgnU_ifunc_wrapper)
--42487-- REDIR: 0x5981a80 (libc.so.6:strspn) redirected to 0x4a286f0 (_vgnU_ifunc_wrapper)
--42487-- REDIR: 0x598314b (libc.so.6:memcpy@GLIBC_2.2.5) redirected to 0x4a286f0 (_vgnU_ifunc_wrapper)
--42487-- REDIR: 0x59831b0 (libc.so.6:memset) redirected to 0x4a286f0 (_vgnU_ifunc_wrapper)
--42487-- REDIR: 0x597fae0 (libc.so.6:strncat) redirected to 0x4a286f0 (_vgnU_ifunc_wrapper)
--42487-- REDIR: 0x5982630 (libc.so.6:strstr) redirected to 0x4a286f0 (_vgnU_ifunc_wrapper)
--42487-- REDIR: 0x597d880 (libc.so.6:strcat) redirected to 0x4a286f0 (_vgnU_ifunc_wrapper)
--42487-- REDIR: 0x597da80 (libc.so.6:index) redirected to 0x4a286f0 (_vgnU_ifunc_wrapper)
--42487-- REDIR: 0x597dcd0 (libc.so.6:strcmp) redirected to 0x4a286f0 (_vgnU_ifunc_wrapper)
--42487-- REDIR: 0x5982bb0 (libc.so.6:bcmp) redirected to 0x4a286f0 (_vgnU_ifunc_wrapper)
--42487-- REDIR: 0x59813c0 (libc.so.6:strncpy) redirected to 0x4a286f0 (_vgnU_ifunc_wrapper)
--42487-- REDIR: 0x5981400 (libc.so.6:rindex) redirected to 0x4c308a0 (rindex)
--42487-- REDIR: 0x5a0a440 (libc.so.6:__strcpy_chk) redirected to 0x4c34e10 (__strcpy_chk)
--42487-- REDIR: 0x5978130 (libc.so.6:malloc) redirected to 0x4c2db20 (malloc)
--42487-- REDIR: 0x5978d10 (libc.so.6:calloc) redirected to 0x4c2faa0 (calloc)
--42487-- Reading syms from /opt/intel/compilers_and_libraries_2017.1.132/linux/ipp/lib/intel64_lin/libippsl9.so
--42487-- Reading syms from /opt/intel/compilers_and_libraries_2017.1.132/linux/ipp/lib/intel64_lin/libippdcl9.so
--42487-- REDIR: 0x597f720 (libc.so.6:strlen) redirected to 0x4c30f60 (strlen)
--42487-- REDIR: 0x5982bf0 (libc.so.6:__GI_memcmp) redirected to 0x4c33b90 (__GI_memcmp)
--42487-- REDIR: 0x5993570 (libc.so.6:__strcmp_sse2_unaligned) redirected to 0x4c31f90 (strcmp)
--42487-- REDIR: 0x5a623f0 (libc.so.6:__memcmp_sse4_1) redirected to 0x4c33cd0 (__memcmp_sse4_1)
Start read file
--42487-- REDIR: 0x50e0e60 (libstdc++.so.6:operator new(unsigned long)) redirected to 0x4c2e080 (operator new(unsigned long))
--42487-- REDIR: 0x59883f0 (libc.so.6:memcpy@@GLIBC_2.14) redirected to 0x4a286f0 (_vgnU_ifunc_wrapper)
--42487-- REDIR: 0x5a41e60 (libc.so.6:__memcpy_avx_unaligned) redirected to 0x4c324a0 (memcpy@@GLIBC_2.14)
--42487-- REDIR: 0x5a66930 (libc.so.6:__memset_avx2) redirected to 0x4c344c0 (memset)
--42487-- REDIR: 0x5982060 (libc.so.6:__GI_strstr) redirected to 0x4c354d0 (__strstr_sse2)
--42487-- REDIR: 0x50e0f10 (libstdc++.so.6:operator new[](unsigned long)) redirected to 0x4c2e7a0 (operator new[](unsigned long))
==42487== Warning: set address range perms: large range [0x395d8040, 0x85211ec8) (undefined)
==42487== Warning: set address range perms: large range [0x395d8040, 0x85211ec8) (defined)
--42487-- REDIR: 0x50def40 (libstdc++.so.6:operator delete[](void*)) redirected to 0x4c2f6e0 (operator delete[](void*))
--42487-- REDIR: 0x59784f0 (libc.so.6:free) redirected to 0x4c2ed80 (free)
--42487-- REDIR: 0x50def10 (libstdc++.so.6:operator delete(void*)) redirected to 0x4c2f1e0 (operator delete(void*))
--42487-- REDIR: 0x59833b0 (libc.so.6:__GI_mempcpy) redirected to 0x4c34fa0 (__GI_mempcpy)
Finish read file
Uncompressed size: 1271111304 [bytes]
==42487== Conditional jump or move depends on uninitialised value(s)
==42487==    at 0x4E3DC39: deflate (in /home/martijn/zlib-1.2.8/libz.so.1.2.8)
==42487==    by 0x40276C: compress(char const*, std::vector<char, std::allocator<char> >&, int, int, int, int) (TestMain.c:62)
==42487==    by 0x402BFB: main (TestMain.c:100)
==42487==
==42487== Conditional jump or move depends on uninitialised value(s)
==42487==    at 0x4E3DC42: deflate (in /home/martijn/zlib-1.2.8/libz.so.1.2.8)
==42487==    by 0x40276C: compress(char const*, std::vector<char, std::allocator<char> >&, int, int, int, int) (TestMain.c:62)
==42487==    by 0x402BFB: main (TestMain.c:100)
==42487==
--42487-- REDIR: 0x405ab0 (NONE:_intel_fast_memcpy) redirected to 0x4c337c0 (_intel_fast_memcpy)
==42487== Conditional jump or move depends on uninitialised value(s)
==42487==    at 0x8A21B06: l9_ippsDeflateLZ77Fast_8u (in /opt/intel/compilers_and_libraries_2017.1.132/linux/ipp/lib/intel64_lin/libippdcl9.so)
==42487==    by 0x4E3F8D2: deflate_common (in /home/martijn/zlib-1.2.8/libz.so.1.2.8)
==42487==    by 0x4E3DC51: deflate (in /home/martijn/zlib-1.2.8/libz.so.1.2.8)
==42487==    by 0x40276C: compress(char const*, std::vector<char, std::allocator<char> >&, int, int, int, int) (TestMain.c:62)
==42487==    by 0x402BFB: main (TestMain.c:100)
==42487==
Compressed size: 59666141 [bytes]
--42487-- REDIR: 0x598a760 (libc.so.6:strchrnul) redirected to 0x4c34da0 (strchrnul)
--42487-- REDIR: 0x5988470 (libc.so.6:__GI_memcpy) redirected to 0x4c32b00 (__GI_memcpy)
--42487-- REDIR: 0x5982860 (libc.so.6:memchr) redirected to 0x4c32170 (memchr)
Duration: 42.2832
==42487== Use of uninitialised value of size 8
==42487==    at 0x8A21A28: l9_ippsDeflateLZ77Fast_8u (in /opt/intel/compilers_and_libraries_2017.1.132/linux/ipp/lib/intel64_lin/libippdcl9.so)
==42487==    by 0x4E3F8D2: deflate_common (in /home/martijn/zlib-1.2.8/libz.so.1.2.8)
==42487==    by 0x4E3DC51: deflate (in /home/martijn/zlib-1.2.8/libz.so.1.2.8)
==42487==    by 0x40276C: compress(char const*, std::vector<char, std::allocator<char> >&, int, int, int, int) (TestMain.c:62)
==42487==    by 0x402BFB: main (TestMain.c:100)
==42487==
==42487== Use of uninitialised value of size 8
==42487==    at 0x8A21A2C: l9_ippsDeflateLZ77Fast_8u (in /opt/intel/compilers_and_libraries_2017.1.132/linux/ipp/lib/intel64_lin/libippdcl9.so)
==42487==    by 0x4E3F8D2: deflate_common (in /home/martijn/zlib-1.2.8/libz.so.1.2.8)
==42487==    by 0x4E3DC51: deflate (in /home/martijn/zlib-1.2.8/libz.so.1.2.8)
==42487==    by 0x40276C: compress(char const*, std::vector<char, std::allocator<char> >&, int, int, int, int) (TestMain.c:62)
==42487==    by 0x402BFB: main (TestMain.c:100)
==42487==
==42487== Invalid read of size 4
==42487==    at 0x8A21A2C: l9_ippsDeflateLZ77Fast_8u (in /opt/intel/compilers_and_libraries_2017.1.132/linux/ipp/lib/intel64_lin/libippdcl9.so)
==42487==    by 0x4E3F8D2: deflate_common (in /home/martijn/zlib-1.2.8/libz.so.1.2.8)
==42487==    by 0x4E3DC51: deflate (in /home/martijn/zlib-1.2.8/libz.so.1.2.8)
==42487==    by 0x40276C: compress(char const*, std::vector<char, std::allocator<char> >&, int, int, int, int) (TestMain.c:62)
==42487==    by 0x402BFB: main (TestMain.c:100)
==42487==  Address 0xb05be139 is not stack'd, malloc'd or (recently) free'd
==42487==
==42487==
==42487== Process terminating with default action of signal 11 (SIGSEGV)
==42487==  Access not within mapped region at address 0xB05BE139
==42487==    at 0x8A21A2C: l9_ippsDeflateLZ77Fast_8u (in /opt/intel/compilers_and_libraries_2017.1.132/linux/ipp/lib/intel64_lin/libippdcl9.so)
==42487==    by 0x4E3F8D2: deflate_common (in /home/martijn/zlib-1.2.8/libz.so.1.2.8)
==42487==    by 0x4E3DC51: deflate (in /home/martijn/zlib-1.2.8/libz.so.1.2.8)
==42487==    by 0x40276C: compress(char const*, std::vector<char, std::allocator<char> >&, int, int, int, int) (TestMain.c:62)
==42487==    by 0x402BFB: main (TestMain.c:100)
==42487==  If you believe this happened as a result of a stack
==42487==  overflow in your program's main thread (unlikely but
==42487==  possible), you can try to increase the size of the
==42487==  main thread stack using the --main-stacksize= flag.
==42487==  The main thread stack size used in this run was 8388608.
==42487==
==42487== HEAP SUMMARY:
==42487==     in use at exit: 1,338,525,031 bytes in 14 blocks
==42487==   total heap usage: 31 allocs, 17 frees, 1,405,745,029 bytes allocated
==42487==
==42487== Searching for pointers to 14 not-freed blocks
==42487== Checked 1,331,772,208 bytes
==42487==
==42487== 22 bytes in 1 blocks are still reachable in loss record 1 of 14
==42487==    at 0x4C2E0EF: operator new(unsigned long) (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==42487==    by 0x404897: void std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::_M_construct<char const*>(char const*, char const*, std::forward_iterator_tag) (basic_string.tcc:223)
==42487==    by 0x5174C4B: std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::basic_string(char const*, std::allocator<char> const&) (in /usr/lib/x86_64-linux-gnu/libstdc++.so.6.0.21)
==42487==    by 0x4028DE: main (TestMain.c:80)
==42487==
==42487== 72 bytes in 1 blocks are still reachable in loss record 2 of 14
==42487==    at 0x4C2FB55: calloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==42487==    by 0x40120BD: _dl_check_map_versions (dl-version.c:293)
==42487==    by 0x4015B18: dl_open_worker (dl-open.c:286)
==42487==    by 0x4010563: _dl_catch_error (dl-error.c:187)
==42487==    by 0x4014DA8: _dl_open (dl-open.c:660)
==42487==    by 0x5CBEF08: dlopen_doit (dlopen.c:66)
==42487==    by 0x4010563: _dl_catch_error (dl-error.c:187)
==42487==    by 0x5CBF570: _dlerror_run (dlerror.c:163)
==42487==    by 0x5CBEFA0: dlopen@@GLIBC_2.2.5 (dlopen.c:87)
==42487==    by 0x60F92E4: _init (in /opt/intel/compilers_and_libraries_2017.1.132/linux/ipp/lib/intel64_lin/libipps.so)
==42487==    by 0x4010679: call_init.part.0 (dl-init.c:58)
==42487==    by 0x40107CA: call_init (dl-init.c:30)
==42487==    by 0x40107CA: _dl_init (dl-init.c:120)
==42487==
==42487== 72 bytes in 1 blocks are still reachable in loss record 3 of 14
==42487==    at 0x4C2FB55: calloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==42487==    by 0x40120BD: _dl_check_map_versions (dl-version.c:293)
==42487==    by 0x4015B18: dl_open_worker (dl-open.c:286)
==42487==    by 0x4010563: _dl_catch_error (dl-error.c:187)
==42487==    by 0x4014DA8: _dl_open (dl-open.c:660)
==42487==    by 0x5CBEF08: dlopen_doit (dlopen.c:66)
==42487==    by 0x4010563: _dl_catch_error (dl-error.c:187)
==42487==    by 0x5CBF570: _dlerror_run (dlerror.c:163)
==42487==    by 0x5CBEFA0: dlopen@@GLIBC_2.2.5 (dlopen.c:87)
==42487==    by 0x5EC4E24: _init (in /opt/intel/compilers_and_libraries_2017.1.132/linux/ipp/lib/intel64_lin/libippdc.so)
==42487==    by 0x4010679: call_init.part.0 (dl-init.c:58)
==42487==    by 0x40107CA: call_init (dl-init.c:30)
==42487==    by 0x40107CA: _dl_init (dl-init.c:120)
==42487==
==42487== 81 bytes in 1 blocks are still reachable in loss record 4 of 14
==42487==    at 0x4C2DB8F: malloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==42487==    by 0x401CF59: strdup (strdup.c:42)
==42487==    by 0x4008BA3: expand_dynamic_string_token (dl-load.c:376)
==42487==    by 0x4008BA3: _dl_map_object (dl-load.c:2409)
==42487==    by 0x4015576: dl_open_worker (dl-open.c:237)
==42487==    by 0x4010563: _dl_catch_error (dl-error.c:187)
==42487==    by 0x4014DA8: _dl_open (dl-open.c:660)
==42487==    by 0x5CBEF08: dlopen_doit (dlopen.c:66)
==42487==    by 0x4010563: _dl_catch_error (dl-error.c:187)
==42487==    by 0x5CBF570: _dlerror_run (dlerror.c:163)
==42487==    by 0x5CBEFA0: dlopen@@GLIBC_2.2.5 (dlopen.c:87)
==42487==    by 0x60F92E4: _init (in /opt/intel/compilers_and_libraries_2017.1.132/linux/ipp/lib/intel64_lin/libipps.so)
==42487==    by 0x4010679: call_init.part.0 (dl-init.c:58)
==42487==
==42487== 81 bytes in 1 blocks are still reachable in loss record 5 of 14
==42487==    at 0x4C2DB8F: malloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==42487==    by 0x400BEF3: _dl_new_object (dl-object.c:165)
==42487==    by 0x400650C: _dl_map_object_from_fd (dl-load.c:1006)
==42487==    by 0x4008C26: _dl_map_object (dl-load.c:2476)
==42487==    by 0x4015576: dl_open_worker (dl-open.c:237)
==42487==    by 0x4010563: _dl_catch_error (dl-error.c:187)
==42487==    by 0x4014DA8: _dl_open (dl-open.c:660)
==42487==    by 0x5CBEF08: dlopen_doit (dlopen.c:66)
==42487==    by 0x4010563: _dl_catch_error (dl-error.c:187)
==42487==    by 0x5CBF570: _dlerror_run (dlerror.c:163)
==42487==    by 0x5CBEFA0: dlopen@@GLIBC_2.2.5 (dlopen.c:87)
==42487==    by 0x60F92E4: _init (in /opt/intel/compilers_and_libraries_2017.1.132/linux/ipp/lib/intel64_lin/libipps.so)
==42487==
==42487== 82 bytes in 1 blocks are still reachable in loss record 6 of 14
==42487==    at 0x4C2DB8F: malloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==42487==    by 0x401CF59: strdup (strdup.c:42)
==42487==    by 0x4008BA3: expand_dynamic_string_token (dl-load.c:376)
==42487==    by 0x4008BA3: _dl_map_object (dl-load.c:2409)
==42487==    by 0x4015576: dl_open_worker (dl-open.c:237)
==42487==    by 0x4010563: _dl_catch_error (dl-error.c:187)
==42487==    by 0x4014DA8: _dl_open (dl-open.c:660)
==42487==    by 0x5CBEF08: dlopen_doit (dlopen.c:66)
==42487==    by 0x4010563: _dl_catch_error (dl-error.c:187)
==42487==    by 0x5CBF570: _dlerror_run (dlerror.c:163)
==42487==    by 0x5CBEFA0: dlopen@@GLIBC_2.2.5 (dlopen.c:87)
==42487==    by 0x5EC4E24: _init (in /opt/intel/compilers_and_libraries_2017.1.132/linux/ipp/lib/intel64_lin/libippdc.so)
==42487==    by 0x4010679: call_init.part.0 (dl-init.c:58)
==42487==
==42487== 82 bytes in 1 blocks are still reachable in loss record 7 of 14
==42487==    at 0x4C2DB8F: malloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==42487==    by 0x400BEF3: _dl_new_object (dl-object.c:165)
==42487==    by 0x400650C: _dl_map_object_from_fd (dl-load.c:1006)
==42487==    by 0x4008C26: _dl_map_object (dl-load.c:2476)
==42487==    by 0x4015576: dl_open_worker (dl-open.c:237)
==42487==    by 0x4010563: _dl_catch_error (dl-error.c:187)
==42487==    by 0x4014DA8: _dl_open (dl-open.c:660)
==42487==    by 0x5CBEF08: dlopen_doit (dlopen.c:66)
==42487==    by 0x4010563: _dl_catch_error (dl-error.c:187)
==42487==    by 0x5CBF570: _dlerror_run (dlerror.c:163)
==42487==    by 0x5CBEFA0: dlopen@@GLIBC_2.2.5 (dlopen.c:87)
==42487==    by 0x5EC4E24: _init (in /opt/intel/compilers_and_libraries_2017.1.132/linux/ipp/lib/intel64_lin/libippdc.so)
==42487==
==42487== 1,249 bytes in 1 blocks are still reachable in loss record 8 of 14
==42487==    at 0x4C2FB55: calloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==42487==    by 0x400BBF5: _dl_new_object (dl-object.c:75)
==42487==    by 0x400650C: _dl_map_object_from_fd (dl-load.c:1006)
==42487==    by 0x4008C26: _dl_map_object (dl-load.c:2476)
==42487==    by 0x4015576: dl_open_worker (dl-open.c:237)
==42487==    by 0x4010563: _dl_catch_error (dl-error.c:187)
==42487==    by 0x4014DA8: _dl_open (dl-open.c:660)
==42487==    by 0x5CBEF08: dlopen_doit (dlopen.c:66)
==42487==    by 0x4010563: _dl_catch_error (dl-error.c:187)
==42487==    by 0x5CBF570: _dlerror_run (dlerror.c:163)
==42487==    by 0x5CBEFA0: dlopen@@GLIBC_2.2.5 (dlopen.c:87)
==42487==    by 0x60F92E4: _init (in /opt/intel/compilers_and_libraries_2017.1.132/linux/ipp/lib/intel64_lin/libipps.so)
==42487==
==42487== 1,250 bytes in 1 blocks are still reachable in loss record 9 of 14
==42487==    at 0x4C2FB55: calloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==42487==    by 0x400BBF5: _dl_new_object (dl-object.c:75)
==42487==    by 0x400650C: _dl_map_object_from_fd (dl-load.c:1006)
==42487==    by 0x4008C26: _dl_map_object (dl-load.c:2476)
==42487==    by 0x4015576: dl_open_worker (dl-open.c:237)
==42487==    by 0x4010563: _dl_catch_error (dl-error.c:187)
==42487==    by 0x4014DA8: _dl_open (dl-open.c:660)
==42487==    by 0x5CBEF08: dlopen_doit (dlopen.c:66)
==42487==    by 0x4010563: _dl_catch_error (dl-error.c:187)
==42487==    by 0x5CBF570: _dlerror_run (dlerror.c:163)
==42487==    by 0x5CBEFA0: dlopen@@GLIBC_2.2.5 (dlopen.c:87)
==42487==    by 0x5EC4E24: _init (in /opt/intel/compilers_and_libraries_2017.1.132/linux/ipp/lib/intel64_lin/libippdc.so)
==42487==
==42487== 5,936 bytes in 1 blocks are still reachable in loss record 10 of 14
==42487==    at 0x4C2DB8F: malloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==42487==    by 0x4E41000: deflateInit2_ (in /home/martijn/zlib-1.2.8/libz.so.1.2.8)
==42487==    by 0x40271A: compress(char const*, std::vector<char, std::allocator<char> >&, int, int, int, int) (TestMain.c:52)
==42487==    by 0x402BFB: main (TestMain.c:100)
==42487==
==42487== 72,704 bytes in 1 blocks are still reachable in loss record 11 of 14
==42487==    at 0x4C2DB8F: malloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==42487==    by 0x50DCEFF: ??? (in /usr/lib/x86_64-linux-gnu/libstdc++.so.6.0.21)
==42487==    by 0x40106B9: call_init.part.0 (dl-init.c:72)
==42487==    by 0x40107CA: call_init (dl-init.c:30)
==42487==    by 0x40107CA: _dl_init (dl-init.c:120)
==42487==    by 0x4000C69: ??? (in /lib/x86_64-linux-gnu/ld-2.23.so)
==42487==
==42487== 223,232 bytes in 1 blocks are still reachable in loss record 12 of 14
==42487==    at 0x4C2DB8F: malloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==42487==    by 0x4E410BA: deflateInit2_ (in /home/martijn/zlib-1.2.8/libz.so.1.2.8)
==42487==    by 0x40271A: compress(char const*, std::vector<char, std::allocator<char> >&, int, int, int, int) (TestMain.c:52)
==42487==    by 0x402BFB: main (TestMain.c:100)
==42487==
==42487== 67,108,864 bytes in 1 blocks are still reachable in loss record 13 of 14
==42487==    at 0x4C2E0EF: operator new(unsigned long) (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==42487==    by 0x404AE5: __gnu_cxx::new_allocator<char>::allocate(unsigned long, void const*) (new_allocator.h:104)
==42487==    by 0x40302E: std::allocator_traits<std::allocator<char> >::allocate(std::allocator<char>&, unsigned long) (alloc_traits.h:491)
==42487==    by 0x403365: std::_Vector_base<char, std::allocator<char> >::_M_allocate(unsigned long) (stl_vector.h:170)
==42487==    by 0x40409D: void std::vector<char, std::allocator<char> >::_M_range_insert<unsigned char*>(__gnu_cxx::__normal_iterator<char*, std::vector<char, std::allocator<char> > >, unsigned char*, unsigned char*, std::forward_iterator_tag) (vector.tcc:659)
==42487==    by 0x403D01: void std::vector<char, std::allocator<char> >::_M_insert_dispatch<unsigned char*>(__gnu_cxx::__normal_iterator<char*, std::vector<char, std::allocator<char> > >, unsigned char*, unsigned char*, std::__false_type) (stl_vector.h:1377)
==42487==    by 0x403C56: __gnu_cxx::__normal_iterator<char*, std::vector<char, std::allocator<char> > > std::vector<char, std::allocator<char> >::insert<unsigned char*, void>(__gnu_cxx::__normal_iterator<char const*, std::vector<char, std::allocator<char> > >, unsigned char*, unsigned char*) (stl_vector.h:1099)
==42487==    by 0x4027D7: compress(char const*, std::vector<char, std::allocator<char> >&, int, int, int, int) (TestMain.c:64)
==42487==    by 0x402BFB: main (TestMain.c:100)
==42487==
==42487== 1,271,111,304 bytes in 1 blocks are still reachable in loss record 14 of 14
==42487==    at 0x4C2E0EF: operator new(unsigned long) (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==42487==    by 0x404AE5: __gnu_cxx::new_allocator<char>::allocate(unsigned long, void const*) (new_allocator.h:104)
==42487==    by 0x40302E: std::allocator_traits<std::allocator<char> >::allocate(std::allocator<char>&, unsigned long) (alloc_traits.h:491)
==42487==    by 0x403365: std::_Vector_base<char, std::allocator<char> >::_M_allocate(unsigned long) (stl_vector.h:170)
==42487==    by 0x403821: std::vector<char, std::allocator<char> >::_M_default_append(unsigned long) (vector.tcc:557)
==42487==    by 0x403672: std::vector<char, std::allocator<char> >::resize(unsigned long) (stl_vector.h:676)
==42487==    by 0x4024B8: readFile(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::vector<char, std::allocator<char> >&) (TestMain.c:17)
==42487==    by 0x40299D: main (TestMain.c:82)
==42487==
==42487== LEAK SUMMARY:
==42487==    definitely lost: 0 bytes in 0 blocks
==42487==    indirectly lost: 0 bytes in 0 blocks
==42487==      possibly lost: 0 bytes in 0 blocks
==42487==    still reachable: 1,338,525,031 bytes in 14 blocks
==42487==         suppressed: 0 bytes in 0 blocks
==42487==
==42487== Use --track-origins=yes to see where uninitialised values come from
==42487== ERROR SUMMARY: 1153 errors from 6 contexts (suppressed: 16722 from 2)
==42487==
==42487== 1 errors in context 1 of 6:
==42487== Invalid read of size 4
==42487==    at 0x8A21A2C: l9_ippsDeflateLZ77Fast_8u (in /opt/intel/compilers_and_libraries_2017.1.132/linux/ipp/lib/intel64_lin/libippdcl9.so)
==42487==    by 0x4E3F8D2: deflate_common (in /home/martijn/zlib-1.2.8/libz.so.1.2.8)
==42487==    by 0x4E3DC51: deflate (in /home/martijn/zlib-1.2.8/libz.so.1.2.8)
==42487==    by 0x40276C: compress(char const*, std::vector<char, std::allocator<char> >&, int, int, int, int) (TestMain.c:62)
==42487==    by 0x402BFB: main (TestMain.c:100)
==42487==  Address 0xb05be139 is not stack'd, malloc'd or (recently) free'd
==42487==
==42487==
==42487== 6 errors in context 2 of 6:
==42487== Use of uninitialised value of size 8
==42487==    at 0x8A21A2C: l9_ippsDeflateLZ77Fast_8u (in /opt/intel/compilers_and_libraries_2017.1.132/linux/ipp/lib/intel64_lin/libippdcl9.so)
==42487==    by 0x4E3F8D2: deflate_common (in /home/martijn/zlib-1.2.8/libz.so.1.2.8)
==42487==    by 0x4E3DC51: deflate (in /home/martijn/zlib-1.2.8/libz.so.1.2.8)
==42487==    by 0x40276C: compress(char const*, std::vector<char, std::allocator<char> >&, int, int, int, int) (TestMain.c:62)
==42487==    by 0x402BFB: main (TestMain.c:100)
==42487==
==42487==
==42487== 6 errors in context 3 of 6:
==42487== Use of uninitialised value of size 8
==42487==    at 0x8A21A28: l9_ippsDeflateLZ77Fast_8u (in /opt/intel/compilers_and_libraries_2017.1.132/linux/ipp/lib/intel64_lin/libippdcl9.so)
==42487==    by 0x4E3F8D2: deflate_common (in /home/martijn/zlib-1.2.8/libz.so.1.2.8)
==42487==    by 0x4E3DC51: deflate (in /home/martijn/zlib-1.2.8/libz.so.1.2.8)
==42487==    by 0x40276C: compress(char const*, std::vector<char, std::allocator<char> >&, int, int, int, int) (TestMain.c:62)
==42487==    by 0x402BFB: main (TestMain.c:100)
==42487==
==42487==
==42487== 226 errors in context 4 of 6:
==42487== Conditional jump or move depends on uninitialised value(s)
==42487==    at 0x8A21B06: l9_ippsDeflateLZ77Fast_8u (in /opt/intel/compilers_and_libraries_2017.1.132/linux/ipp/lib/intel64_lin/libippdcl9.so)
==42487==    by 0x4E3F8D2: deflate_common (in /home/martijn/zlib-1.2.8/libz.so.1.2.8)
==42487==    by 0x4E3DC51: deflate (in /home/martijn/zlib-1.2.8/libz.so.1.2.8)
==42487==    by 0x40276C: compress(char const*, std::vector<char, std::allocator<char> >&, int, int, int, int) (TestMain.c:62)
==42487==    by 0x402BFB: main (TestMain.c:100)
==42487==
==42487==
==42487== 457 errors in context 5 of 6:
==42487== Conditional jump or move depends on uninitialised value(s)
==42487==    at 0x4E3DC42: deflate (in /home/martijn/zlib-1.2.8/libz.so.1.2.8)
==42487==    by 0x40276C: compress(char const*, std::vector<char, std::allocator<char> >&, int, int, int, int) (TestMain.c:62)
==42487==    by 0x402BFB: main (TestMain.c:100)
==42487==
==42487==
==42487== 457 errors in context 6 of 6:
==42487== Conditional jump or move depends on uninitialised value(s)
==42487==    at 0x4E3DC39: deflate (in /home/martijn/zlib-1.2.8/libz.so.1.2.8)
==42487==    by 0x40276C: compress(char const*, std::vector<char, std::allocator<char> >&, int, int, int, int) (TestMain.c:62)
==42487==    by 0x402BFB: main (TestMain.c:100)
==42487==
--42487--
--42487-- used_suppression:  16722 zlib-1.2.x trickyness (1a): See http://www.zlib.net/zlib_faq.html#faq36 /usr/lib/valgrind/default.supp:508
==42487==
==42487== ERROR SUMMARY: 1153 errors from 6 contexts (suppressed: 16722 from 2)

 

 

3 posts / 0 new
Last post
For more complete information about compiler optimizations, see our Optimization Notice.

Hi Martjin,

Seems the problem is caused by memory problem. If you ever allocate memory for source? If the size of source file is correct? And what about other arguments (window_bit, mem_level, compression_level)? I create a quick sample according to your snippet code (win_bit=15, mem_level=MAX_MEM_LEVEL, level=default), but could not reproduce your problem. Could you please use it test with your file. If you still meet problem, please send me your source file.

Best regards,
Fiona

Attachments: 

AttachmentSize
Downloadtext/x-csrc TestMain.c3.45 KB

Hi Martijn,

Regarding the source code, I would do

do {
...
while(defstream.avail_in > 0)

It means "do compression while there's anything to compress". And this way is recommended by Zlib documentation. May be it's not related to your issue, but it's more logical.

Regards,
Sergey

Leave a Comment

Please sign in to add a comment. Not a member? Join today