zeromq / libzmq

ZeroMQ core engine in C++, implements ZMTP/3.1
https://www.zeromq.org
Mozilla Public License 2.0
9.75k stars 2.36k forks source link

Use of uninitialized value #4265

Open darkdragon-001 opened 3 years ago

darkdragon-001 commented 3 years ago

Issue description

My memory sanitizer shows me usage of uninitialized value

Environment

Self-built dynamic library with LLVM 11 and linked against LLVM's libc++.

Minimal test code / Steps to reproduce the issue

Link your application with the memory sanitizer and run it: https://clang.llvm.org/docs/MemorySanitizer.html

What's the actual result? (include assertion message & call stack if applicable)

Uninitialized bytes in MemcmpInterceptorCommon at offset 0 inside [0x705000000021, 3)
==544017==WARNING: MemorySanitizer: use-of-uninitialized-value
    #0 0x757bbe in memcmp (APPLICATION_BINARY+0x757bbe)
    #1 0x7f44446f6436 in std::__1::pair<std::__1::__tree_iterator<std::__1::__value_type<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, zmq::own_t* (zmq::session_base_t::*)(zmq::io_thread_t*, bool)>, std::__1::__tree_node<std::__1::__value_type<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, zmq::own_t* (zmq::session_base_t::*)(zmq::io_thread_t*, bool)>, void*>*, long>, bool> std::__1::__tree<std::__1::__value_type<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, zmq::own_t* (zmq::session_base_t::*)(zmq::io_thread_t*, bool)>, std::__1::__map_value_compare<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, std::__1::__value_type<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, zmq::own_t* (zmq::session_base_t::*)(zmq::io_thread_t*, bool)>, std::__1::less<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > >, true>, std::__1::allocator<std::__1::__value_type<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, zmq::own_t* (zmq::session_base_t::*)(zmq::io_thread_t*, bool)> > >::__emplace_hint_unique_key_args<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, std::__1::pair<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const, zmq::own_t* (zmq::session_base_t::*)(zmq::io_thread_t*, bool)> const&>(std::__1::__tree_const_iterator<std::__1::__value_type<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, zmq::own_t* (zmq::session_base_t::*)(zmq::io_thread_t*, bool)>, std::__1::__tree_node<std::__1::__value_type<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, zmq::own_t* (zmq::session_base_t::*)(zmq::io_thread_t*, bool)>, void*>*, long>, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, std::__1::pair<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const, zmq::own_t* (zmq::session_base_t::*)(zmq::io_thread_t*, bool)> const&) (/usr/local/lib/libzmq.so.5+0x83436)
    #2 0x7f44446f5ded in _GLOBAL__sub_I_session_base.cpp (/usr/local/lib/libzmq.so.5+0x82ded)
    #3 0x7f444485796d  (/lib64/ld-linux-x86-64.so.2+0x1196d)
    #4 0x7f4444857a57  (/lib64/ld-linux-x86-64.so.2+0x11a57)
    #5 0x7f4444847109  (/lib64/ld-linux-x86-64.so.2+0x1109)

SUMMARY: MemorySanitizer: use-of-uninitialized-value (/tmp/go-build2113932925/b224/pipes.test+0x757bbe) in memcmp

What's the expected result?

Memory sanitizer doesn't find errors.

bluca commented 3 years ago

There's no symbols in that backtrace. Can you send a PR to fix it?