Skip to content

zero-copy message cannot send same amount of transmission as copy message and ZMQbg/IO/0" received signal SIGABRT #614

Open
@fengmao31

Description

@fengmao31

I found it have the error when I use zero-cpoy way to create big message and send it.
If the transimission is large, the zero- copy way the create have problem., while the copy work well.
I can send the 2MB size message and send 25Hz in copy message, but only can send 100KB message in the zero-cpoy way in the same frequency or I can send 2MB size meesage in low frequency.

This two work well. use alloc to take message or use copy way to create message.

zmq::message_t msg(const_cast<char*>(m2.data()), m2.size());            
char* bbb = (char*)malloc(m.size());
memcpy(bbb, m.data() , m.size());
zmq::message_t msg(bbb, m.size(), my_free3, nullptr);

This one cannot work. use zero-copy way to create message.

auto my_free3 = [](void* data, void* hint) {};
zmq::message_t msg(const_cast<char*>(m.data()), m.size(), my_free3, nullptr);
fengmao@fengmao-Precision-3660:~/rima/cpp-python-programmer/rmw/zmq/build$ ./zmqpub_multi_frame_zerocopy 
Sending seq 2 info size 27
Sending seq 2 m size 20000017
Bad address (/home/fengmao/rima/libzmq/src/tcp.cpp:254)
Aborted
fengmao@fengmao-Precision-3660:~/rima/cpp-python-programmer/rmw/zmq/build$ gdb zmqpub_multi_frame_zerocopy 
GNU gdb (Ubuntu 9.2-0ubuntu1~20.04.1) 9.2
Copyright (C) 2020 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
Type "show copying" and "show warranty" for details.
This GDB was configured as "x86_64-linux-gnu".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>.
Find the GDB manual and other documentation resources online at:
    <http://www.gnu.org/software/gdb/documentation/>.

For help, type "help".
Type "apropos word" to search for commands related to "word"...
Reading symbols from zmqpub_multi_frame_zerocopy...
(gdb) r
Starting program: /home/fengmao/rima/cpp-python-programmer/rmw/zmq/build/zmqpub_multi_frame_zerocopy 
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1".
[New Thread 0x7ffff713e700 (LWP 779197)]
[New Thread 0x7ffff693d700 (LWP 779198)]
[New Thread 0x7ffff613c700 (LWP 779199)]
Sending seq 2 info size 27
Sending seq 2 m size 20000017
Sending seq 3 info size 27
Sending seq 3 m size 20000017
Bad address (/home/fengmao/rima/libzmq/src/tcp.cpp:254)
Sending seq 4 info size 27
Sending seq 4 m size 20000017

Thread 4 "ZMQbg/IO/0" received signal SIGABRT, Aborted.
[Switching to Thread 0x7ffff613c700 (LWP 779199)]
__GI_raise (sig=sig@entry=6)
    at ../sysdeps/unix/sysv/linux/raise.c:50
50      ../sysdeps/unix/sysv/linux/raise.c: No such file or directory.
(gdb) 

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions