[zeromq-dev] Compilation fails when NDEBUG is enabled.

Chernyshev Vyacheslav astellar at ro.ru
Thu Aug 23 23:06:21 CEST 2012


Thank you. What do you think about other problems in test_monitor? I 
will partially repeat my message posted in thread "Reporting make check 
error". Do not want to create a pull request without discussing this 
issue with others, even if it seems that issue is really present.

First, memcmp returns zero if two byte strings are equal. We assert that 
it is non-zero in all cases of test_monitor. So test passes only if two 
byte strings are different everywhere. Is it really an intended 
behaviour? Second, memcmp compares 22 bytes of memory, while addr char 
array "tcp://127.0.0.1:5560" has only 20 bytes (not counting trailing 
zero terminator) and it means that data_-><something>.addr can not have 
more than 20 bytes too. memcmp does not stop like strcmp when it finds a 
'\0' character, it simply compares passed amount of bytes. So we 
definitely read memory that does not belong to us.

As we do not know length of data_-><something>.addr in advance, probably 
strcmp (or strncmp with upper limit of addr length) should be used in 
this test case and at least some asserts must check whether strncmp(...) 
== 0.



More information about the zeromq-dev mailing list