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

4.3.x : segfault on sending data from XSUB to XPUB #3656

Closed
freemanix opened this issue Sep 1, 2019 · 1 comment · Fixed by #3659
Closed

4.3.x : segfault on sending data from XSUB to XPUB #3656

freemanix opened this issue Sep 1, 2019 · 1 comment · Fixed by #3659

Comments

@freemanix
Copy link

Starting with libzmq 4.3.0, this code crashes:

int main()
{
    zmq::context_t ctx;

    zmq::socket_t publisher(ctx, ZMQ_XPUB);
    publisher.bind("inproc://test");

    zmq::socket_t receiver(ctx, ZMQ_XSUB);
    receiver.connect("inproc://test");

    zmq::message_t subscribe(1);
    *static_cast<unsigned char *>(subscribe.data()) = 2;
    receiver.send(subscribe);

    zmq::message_t receive;
    publisher.recv(&receive);

    return 0;
}

Note that instead of activating subscription (1) or cancelling it (0), I simply send user data (2). The problem is that this code for handling user messages comming upstream never executes:

libzmq/src/xpub.cpp

Lines 114 to 123 in c737e57

} else {
// Process user message coming upstream from xsub socket
_pending_data.push_back (blob_t (msg_data, sub.size ()));
if (metadata)
metadata->add_ref ();
_pending_metadata.push_back (metadata);
_pending_flags.push_back (sub.flags ());
sub.close ();
continue;
}

Instead, the above else is activated, but it just skip the data processing if first byte is not 0 or 1. Also, this else kind of duplicates above if.

As a result, my code which needs to send upstream data from XSUB to XPUB does not work with libzmq 4.3.0 or higher. Any way how to resolve this?

bluca added a commit to bluca/libzmq that referenced this issue Sep 2, 2019
Solution: fix regression introduced by:
zeromq#3168

Correctly fall back to user message if the first byte is neither 0 nor
1, and add a simple unit test

Fixes zeromq#3656
@bluca
Copy link
Member

bluca commented Sep 2, 2019

Thanks for the report, regression introduced by #3168 PR pending

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

Successfully merging a pull request may close this issue.

2 participants