[zeromq-dev] issue : libzmq can send messages in a curve socket before the handcheck is finished !

Laurent Alebarde l.alebarde at free.fr
Sun Oct 20 15:33:32 CEST 2013


I don't see any way to access /is_handcheck_complete()/ or something 
equivalent from a socket or any step in the send workflow, but I am very 
far from mastering the libzmq code.

So, I don't know how to solve this problem.

Help from devs would be welcome please.....


Le 19/10/2013 12:28, Laurent Alebarde a écrit :
> Hi Devs,
>
> _Observation_ : libzmq can send messages in a curve socket before the 
> handcheck is finished
>
> _Problem_ : This is anunexpected behaviour that can break some user's 
> program logic, or impose to add more logic to deal with. Moreover, it 
> happens in some rare and so not reproduceable circumstances, I assume 
> in multithread applications.
>
> _Test program_ : test_concurrency_curve.cpp 
> <http://pastebin.com/0LzJKUyC> based on test_proxy.cpp (not yet merged 
> - pulling request waiting). The number of clients and workers can be 
> parametered and are set here to 1, to facilitate debugging. The keys 
> used are the ones in the documentation, while in normal set-up, this 
> test uses different keys for each client (this is in comments).
>
> _To reproduce the problem_ :
> Add this test in your repository in the subdirectory tests and add the 
> following lines at the appropriate place inside tests/Makefile.am to 
> take it into account :
>
>                   test_concurrency_curve \
> test_concurrency_curve_SOURCES = test_concurrency_curve.cpp
>
>
> Set breakpoints here :
>
>   * test_concurrency_curve.cpp
>       o main, line 279 : msleep (1000);
>       o client_task, line 121 : rc = zmq_send (client, content,
>         CONTENT_SIZE, 0);
>   * curve_client.cpp
>       o zmq::curve_client_t::curve_client_t, line 41 : memcpy
>         (public_key, options_.curve_public_key,
>         crypto_box_PUBLICKEYBYTES);
>   * curve_server.cpp
>       o zmq::curve_server_t::curve_server_t, line 47 : memcpy
>         (secret_key, options_.curve_secret_key,
>         crypto_box_SECRETKEYBYTES);
>
> The break points in curve_client.cpp and curve_server.cpp prevent the 
> handcheck to be performed.
> The break point in test_concurrency_curve.cpp / client_task is where 
> the send is performed while the handcheck is not.
> I can follow the send until zmq.cpp / s_sendmsg , then ypipe.hpp /  
> zmq::pipe_t::write. As the return value is 0, I assume the message has 
> been sent. Then s_sendmsg returns 13, which correspond to the message 
> size actually sent. Finally, the assert in
> test_concurrency_curve.cpp line 122 is ok._
> _
>
> _Expected behaviour_ :
> Two possibilities :
>
>  1. The send may be blocking until the handcheck is finished
>     successfully, possibly with a time-out.
>  2. The send is aborted with an error status, and the user application
>     SHALL check the connected status of the socket before using it.
>
> I remain at your disposal for further information.
>
> Cheers,
>
>
> Laurent.
>
>
>
> _______________________________________________
> zeromq-dev mailing list
> zeromq-dev at lists.zeromq.org
> http://lists.zeromq.org/mailman/listinfo/zeromq-dev

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.zeromq.org/pipermail/zeromq-dev/attachments/20131020/5c1f05ff/attachment.htm>


More information about the zeromq-dev mailing list