Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Valgrind - Conditional jump or move depends on uninitialised value(s) #17

Open
romintomasetti opened this issue Jan 25, 2021 · 2 comments

Comments

@romintomasetti
Copy link

romintomasetti commented Jan 25, 2021

I ran Valgrind on my program, that at some point uses miniz-cpp.

It raised one error for miniz-cpp, which is the following:

==37967== Conditional jump or move depends on uninitialised value(s)
==37967==    at 0x565D9C4: tdefl_find_match (zip_file.hpp:2339)
==37967==    by 0x565D9C4: tdefl_compress_normal (zip_file.hpp:2610)
==37967==    by 0x565EA34: tdefl_compress (zip_file.hpp:2727)
==37967==    by 0x565EBDE: tdefl_compress_buffer (zip_file.hpp:2747)
==37967==    by 0x566506B: mz_zip_writer_add_mem_ex (zip_file.hpp:4430)
==37967==    by 0x5663B0F: mz_zip_writer_add_mem (zip_file.hpp:4190)
==37967==    by 0x566E63D: miniz_cpp::zip_file::writestr(std::string const&, std::string const&) (zip_file.hpp:5514)
==37967==    by 0x566E515: miniz_cpp::zip_file::write(std::string const&, std::string const&) (zip_file.hpp:5504)

I don't think I have the latest code of miniz-cpp so I also put the line here:

    }
    if (!dist) break; q = (const mz_uint16*)(d->m_dict + probe_pos); if (TDEFL_READ_UNALIGNED_WORD(q) != s01) continue; p = s; probe_len = 32;
    do { } while ( (TDEFL_READ_UNALIGNED_WORD(++p) == TDEFL_READ_UNALIGNED_WORD(++q)) && (TDEFL_READ_UNALIGNED_WORD(++p) == TDEFL_READ_UNALIGNED_WORD(++q)) &&
                   (TDEFL_READ_UNALIGNED_WORD(++p) == TDEFL_READ_UNALIGNED_WORD(++q)) && (TDEFL_READ_UNALIGNED_WORD(++p) == TDEFL_READ_UNALIGNED_WORD(++q)) && (--probe_len > 0) );
    if (!probe_len)
    {

Tracking the origin gives:

==44853== Conditional jump or move depends on uninitialised value(s)
==44853==    at 0x564B8A2: tdefl_find_match (zip_file.hpp:2338)
==44853==    by 0x564B8A2: tdefl_compress_normal (zip_file.hpp:2610)
==44853==    by 0x564C8F5: tdefl_compress (zip_file.hpp:2727)
==44853==    by 0x564CA9F: tdefl_compress_buffer (zip_file.hpp:2747)
==44853==    by 0x5652F2C: mz_zip_writer_add_mem_ex (zip_file.hpp:4430)
==44853==    by 0x56519D0: mz_zip_writer_add_mem (zip_file.hpp:4190)
==44853==    by 0x565C4FF: miniz_cpp::zip_file::writestr(std::string const&, std::string const&) (zip_file.hpp:5514)
==44853==    by 0x565C3D7: miniz_cpp::zip_file::write(std::string const&, std::string const&) (zip_file.hpp:5504)
...
==44853==  Uninitialised value was created by a heap allocation
==44853==    at 0x4A37ECB: malloc (vg_replace_malloc.c:307)
==44853==    by 0x56422AB: def_alloc_func (zip_file.hpp:1054)
==44853==    by 0x5652C34: mz_zip_writer_add_mem_ex (zip_file.hpp:4375)
==44853==    by 0x56519D0: mz_zip_writer_add_mem (zip_file.hpp:4190)
==44853==    by 0x565C4FF: miniz_cpp::zip_file::writestr(std::string const&, std::string const&) (zip_file.hpp:5514)
==44853==    by 0x565C3D7: miniz_cpp::zip_file::write(std::string const&, std::string const&) (zip_file.hpp:5504)
...
==44853== 

It would be great if you can solve this issue 😄

@tfussell
Copy link
Owner

Thanks for the issue. I'll try to take care of this soon.

@romintomasetti
Copy link
Author

Thanks ! I think that using calloc instead of malloc in def_alloc_func would already solve some issues 😄

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants