[zeromq-dev] zframe_is fails in a simple client server application

Pieter Hintjens ph at imatix.com
Mon Mar 16 19:21:53 CET 2015


Hi Sachin,

Sorry for the delay. I did reproduce the crash. There are a couple of
issues in your code.

- The OUTPUT INDEXES OK method defines status as number/8, so
signal_have_output_indexes_ok() must use the picture '8' for that.
- that method sends the frame to the client API, which destroys it.
Thus, it has to grab ownership of the frame and not simply its
reference, otherwise the frame is destroyed twice in different
threads, leading to the crash.

This is the correct code:

static void
signal_have_output_indexes_ok (client_t *self)
{
    zsock_send (self->cmdpipe, "s8p", "OUTPUT INDEXES OK",
        wap_proto_status (self->message),
        wap_proto_get_o_indexes (self->message));
}

And then it seems to work.

-Pieter

On Sun, Mar 8, 2015 at 6:43 PM, Sachin Hosmani <oranjuices at hotmail.com> wrote:
> Hi,
>
> I'm using zproto and czmq stack for writing a client server application (and
> the underlying protocol) in C/C++.
>
> The code was run on a Linux box (Ubuntu 14.04).
>
> I wrote a minimalist test case to reproduce my problem.
>
> The code is here: https://github.com/oranjuice/monero-0mq/tree/master/src
> You can find the xml protocol files there.
>
> The main file is wap_tutorial.c:
> https://github.com/oranjuice/monero-0mq/blob/master/src/wap_tutorial.c
>
> When I run wap_tutorial the client receives the "output indexes" and prints
> them just fine but soon after, there is an assertion failure:
> "wap_tutorial: src/zframe.c:87: zframe_destroy: Assertion `zframe_is (self)'
> failed."
>
> Here is the stack dump:
>
> #0  0x00007ffff753bcc9 in __GI_raise (sig=sig at entry=6) at
> ../nptl/sysdeps/unix/sysv/linux/raise.c:56
> #1  0x00007ffff753f0d8 in __GI_abort () at abort.c:89
> #2  0x00007ffff7534b86 in __assert_fail_base (fmt=0x7ffff76863d0 "%s%s%s:%u:
> %s%sAssertion `%s' failed.\n%n",
>     assertion=assertion at entry=0x7ffff79292a7 "zframe_is (self)",
> file=file at entry=0x7ffff792929a "src/zframe.c", line=line at entry=87,
>     function=function at entry=0x7ffff792a69a <__PRETTY_FUNCTION__.11157>
> "zframe_destroy") at assert.c:92
> #3  0x00007ffff7534c32 in __GI___assert_fail
> (assertion=assertion at entry=0x7ffff79292a7 "zframe_is (self)",
>     file=file at entry=0x7ffff792929a "src/zframe.c", line=line at entry=87,
>     function=function at entry=0x7ffff792a69a <__PRETTY_FUNCTION__.11157>
> "zframe_destroy") at assert.c:101
> #4  0x00007ffff78ed336 in zframe_destroy (self_p=0x7fffe8001680) at
> src/zframe.c:87
> #5  0x00000000004031fa in wap_proto_destroy (self_p=0x7fffe8000910) at
> wap_proto.c:240
> #6  0x000000000040b9fa in s_client_destroy (self_p=0x7ffff4e68eb8) at
> wap_client_engine.inc:270
> #7  0x000000000040de63 in wap_client (cmdpipe=0x61b560, msgpipe=0x619630) at
> wap_client_engine.inc:1347
> #8  0x00007ffff78df403 in s_thread_shim (args=0x61b540) at src/zactor.c:67
> #9  0x00007ffff6e95182 in start_thread (arg=0x7ffff4e69700) at
> pthread_create.c:312
> #10 0x00007ffff760000d in clone () at
> ../sysdeps/unix/sysv/linux/x86_64/clone.S:111
>
> Does anyone have an idea of what's wrong here?
>
> Thank you
>
> Sachin Hosmani
> (OranJuice)
>



More information about the zeromq-dev mailing list