[zeromq-dev] libzmq and helgrind

Michi Henning michi at triodia.com
Tue Aug 19 09:03:50 CEST 2014


On 19/08/14 13:28, Thomas Rodgers wrote:
> ... then, having realizing that it linked against the Ubuntu installed 
> default version (libzmq3), I re-ran this against libzmq4 and the 
> current libzmq 'trunk'.  I get no races/issues in libzmq3 or libzmq4, 
> but 4.1 definitely seems to have a problem, in that this test program 
> is triggering GCC's stack smashing detector, so seems like a 4.1 
> specific issue mebe?
>
> If I get some time tomorrow, I will try to figure out why (no obvious 
> from a libzmq call in the backtrace).

Thanks heaps for that, I truly appreciate it!

I'm running with version 4.0.4 here from the Utopic archives, with gcc 4.9.

I've attached the output I'm getting from helgrind, just in case. I 
assume that yours will be pretty much identical. That was with a string 
length of 40. Note that I sometimes get a clean run, especially with 
shorter strings. I just tried with a length of 30 and, every now and 
then, helgrind reports zero errors (maybe one in ten tries).

Cheers,

Michi.
-------------- next part --------------
==10464== Helgrind, a thread error detector
==10464== Copyright (C) 2007-2013, and GNU GPL'd, by OpenWorks LLP et al.
==10464== Using Valgrind-3.10.0.SVN and LibVEX; rerun with -h for copyright info
==10464== Command: ./a.out
==10464== 
==10464== ---Thread-Announcement------------------------------------------
==10464== 
==10464== Thread #1 is the program's root thread
==10464== 
==10464== ----------------------------------------------------------------
==10464== 
==10464== Possible data race during read of size 8 at 0x6317620 by thread #1
==10464== Locks held: none
==10464==    at 0x4E58194: zmq::msg_t::data() (in /usr/lib/x86_64-linux-gnu/libzmq.so.3.1.0)
==10464==    by 0x401FC9: zmq::message_t::data() (zmq.hpp:220)
==10464==    by 0x401B7C: main (main.cpp:37)
==10464== 
==10464== Address 0x6317620 is 0 bytes inside a block of size 80 alloc'd
==10464==    at 0x4C2BF00: malloc (in /usr/lib/valgrind/vgpreload_helgrind-amd64-linux.so)
==10464==    by 0x4E57E70: zmq::msg_t::init_size(unsigned long) (in /usr/lib/x86_64-linux-gnu/libzmq.so.3.1.0)
==10464==    by 0x4E7CD54: zmq::v2_decoder_t::one_byte_size_ready() (in /usr/lib/x86_64-linux-gnu/libzmq.so.3.1.0)
==10464==    by 0x4E7D2C8: zmq::decoder_base_t<zmq::v2_decoder_t>::decode(unsigned char const*, unsigned long, unsigned long&) (in /usr/lib/x86_64-linux-gnu/libzmq.so.3.1.0)
==10464==    by 0x4E72988: zmq::stream_engine_t::in_event() (in /usr/lib/x86_64-linux-gnu/libzmq.so.3.1.0)
==10464==    by 0x4E52BAD: zmq::epoll_t::loop() (in /usr/lib/x86_64-linux-gnu/libzmq.so.3.1.0)
==10464==    by 0x4E771DF: thread_routine (in /usr/lib/x86_64-linux-gnu/libzmq.so.3.1.0)
==10464==    by 0x4C30E26: ??? (in /usr/lib/valgrind/vgpreload_helgrind-amd64-linux.so)
==10464==    by 0x5DDE164: start_thread (pthread_create.c:309)
==10464==    by 0x56B64DC: clone (clone.S:111)
==10464== 
==10464== ----------------------------------------------------------------
==10464== 
==10464== Possible data race during read of size 2 at 0x6317648 by thread #1
==10464== Locks held: none
==10464==    at 0x4C34DE0: memcpy@@GLIBC_2.14 (in /usr/lib/valgrind/vgpreload_helgrind-amd64-linux.so)
==10464==    by 0x5159DAF: char* std::string::_S_construct<char const*>(char const*, char const*, std::allocator<char> const&, std::forward_iterator_tag) (in /usr/lib/x86_64-linux-gnu/libstdc++.so.6.0.20)
==10464==    by 0x5159E2B: std::basic_string<char, std::char_traits<char>, std::allocator<char> >::basic_string(char const*, unsigned long, std::allocator<char> const&) (in /usr/lib/x86_64-linux-gnu/libstdc++.so.6.0.20)
==10464==    by 0x401B98: main (main.cpp:37)
==10464== 
==10464== Address 0x6317648 is 40 bytes inside a block of size 80 alloc'd
==10464==    at 0x4C2BF00: malloc (in /usr/lib/valgrind/vgpreload_helgrind-amd64-linux.so)
==10464==    by 0x4E57E70: zmq::msg_t::init_size(unsigned long) (in /usr/lib/x86_64-linux-gnu/libzmq.so.3.1.0)
==10464==    by 0x4E7CD54: zmq::v2_decoder_t::one_byte_size_ready() (in /usr/lib/x86_64-linux-gnu/libzmq.so.3.1.0)
==10464==    by 0x4E7D2C8: zmq::decoder_base_t<zmq::v2_decoder_t>::decode(unsigned char const*, unsigned long, unsigned long&) (in /usr/lib/x86_64-linux-gnu/libzmq.so.3.1.0)
==10464==    by 0x4E72988: zmq::stream_engine_t::in_event() (in /usr/lib/x86_64-linux-gnu/libzmq.so.3.1.0)
==10464==    by 0x4E52BAD: zmq::epoll_t::loop() (in /usr/lib/x86_64-linux-gnu/libzmq.so.3.1.0)
==10464==    by 0x4E771DF: thread_routine (in /usr/lib/x86_64-linux-gnu/libzmq.so.3.1.0)
==10464==    by 0x4C30E26: ??? (in /usr/lib/valgrind/vgpreload_helgrind-amd64-linux.so)
==10464==    by 0x5DDE164: start_thread (pthread_create.c:309)
==10464==    by 0x56B64DC: clone (clone.S:111)
==10464== 
==10464== ----------------------------------------------------------------
==10464== 
==10464== Possible data race during read of size 2 at 0x6317658 by thread #1
==10464== Locks held: none
==10464==    at 0x4C34DEE: memcpy@@GLIBC_2.14 (in /usr/lib/valgrind/vgpreload_helgrind-amd64-linux.so)
==10464==    by 0x5159DAF: char* std::string::_S_construct<char const*>(char const*, char const*, std::allocator<char> const&, std::forward_iterator_tag) (in /usr/lib/x86_64-linux-gnu/libstdc++.so.6.0.20)
==10464==    by 0x5159E2B: std::basic_string<char, std::char_traits<char>, std::allocator<char> >::basic_string(char const*, unsigned long, std::allocator<char> const&) (in /usr/lib/x86_64-linux-gnu/libstdc++.so.6.0.20)
==10464==    by 0x401B98: main (main.cpp:37)
==10464== 
==10464== Address 0x6317658 is 56 bytes inside a block of size 80 alloc'd
==10464==    at 0x4C2BF00: malloc (in /usr/lib/valgrind/vgpreload_helgrind-amd64-linux.so)
==10464==    by 0x4E57E70: zmq::msg_t::init_size(unsigned long) (in /usr/lib/x86_64-linux-gnu/libzmq.so.3.1.0)
==10464==    by 0x4E7CD54: zmq::v2_decoder_t::one_byte_size_ready() (in /usr/lib/x86_64-linux-gnu/libzmq.so.3.1.0)
==10464==    by 0x4E7D2C8: zmq::decoder_base_t<zmq::v2_decoder_t>::decode(unsigned char const*, unsigned long, unsigned long&) (in /usr/lib/x86_64-linux-gnu/libzmq.so.3.1.0)
==10464==    by 0x4E72988: zmq::stream_engine_t::in_event() (in /usr/lib/x86_64-linux-gnu/libzmq.so.3.1.0)
==10464==    by 0x4E52BAD: zmq::epoll_t::loop() (in /usr/lib/x86_64-linux-gnu/libzmq.so.3.1.0)
==10464==    by 0x4E771DF: thread_routine (in /usr/lib/x86_64-linux-gnu/libzmq.so.3.1.0)
==10464==    by 0x4C30E26: ??? (in /usr/lib/valgrind/vgpreload_helgrind-amd64-linux.so)
==10464==    by 0x5DDE164: start_thread (pthread_create.c:309)
==10464==    by 0x56B64DC: clone (clone.S:111)
==10464== 
==10464== ----------------------------------------------------------------
==10464== 
==10464== Possible data race during read of size 8 at 0x6317630 by thread #1
==10464== Locks held: none
==10464==    at 0x4E57FD9: zmq::msg_t::close() (in /usr/lib/x86_64-linux-gnu/libzmq.so.3.1.0)
==10464==    by 0x401F8D: zmq::message_t::~message_t() (zmq.hpp:163)
==10464==    by 0x401BFC: main (main.cpp:35)
==10464== 
==10464== Address 0x6317630 is 16 bytes inside a block of size 80 alloc'd
==10464==    at 0x4C2BF00: malloc (in /usr/lib/valgrind/vgpreload_helgrind-amd64-linux.so)
==10464==    by 0x4E57E70: zmq::msg_t::init_size(unsigned long) (in /usr/lib/x86_64-linux-gnu/libzmq.so.3.1.0)
==10464==    by 0x4E7CD54: zmq::v2_decoder_t::one_byte_size_ready() (in /usr/lib/x86_64-linux-gnu/libzmq.so.3.1.0)
==10464==    by 0x4E7D2C8: zmq::decoder_base_t<zmq::v2_decoder_t>::decode(unsigned char const*, unsigned long, unsigned long&) (in /usr/lib/x86_64-linux-gnu/libzmq.so.3.1.0)
==10464==    by 0x4E72988: zmq::stream_engine_t::in_event() (in /usr/lib/x86_64-linux-gnu/libzmq.so.3.1.0)
==10464==    by 0x4E52BAD: zmq::epoll_t::loop() (in /usr/lib/x86_64-linux-gnu/libzmq.so.3.1.0)
==10464==    by 0x4E771DF: thread_routine (in /usr/lib/x86_64-linux-gnu/libzmq.so.3.1.0)
==10464==    by 0x4C30E26: ??? (in /usr/lib/valgrind/vgpreload_helgrind-amd64-linux.so)
==10464==    by 0x5DDE164: start_thread (pthread_create.c:309)
==10464==    by 0x56B64DC: clone (clone.S:111)
==10464== 
==10464== 
==10464== For counts of detected and suppressed errors, rerun with: -v
==10464== Use --history-level=approx or =none to gain increased speed, at
==10464== the cost of reduced accuracy of conflicting-access information
==10464== ERROR SUMMARY: 22 errors from 4 contexts (suppressed: 814 from 486)


More information about the zeromq-dev mailing list