libzmq icon indicating copy to clipboard operation
libzmq copied to clipboard

zmq crash issue

Open cyforsr opened this issue 5 years ago • 2 comments

Please use this template for reporting suspected bugs or requests for help.

Issue description

we use pub-sub mode in linux-c with a very simple example: but always crash down, and the issue messages are different when the server is not work. it's issue messages: error message 1: image error message 2: image error message 3: 112866976-f7435a00-90ec-11eb-8fd9-5265f71d8adb 112866954-f3173c80-90ec-11eb-872c-18941cab8417

Environment

  • libzmq version (commit hash if unreleased): 4.3.2
  • OS: linux

Minimal test code / Steps to reproduce the issue

`

#include <iostream>
#include "zhelpers.hpp"
#include "timer.h"
using namespace std;

int main()
{
    int rst;
    void *context =zmq_init(1);
    void *publisher=zmq_socket(context,ZMQ_PUB);
    assert(publisher);
    zmq_bind(publisher,"tcp://*:5555");
    while(1)
    {
        sleep(5);
        char msg[2048];
        msg[0] = '\0';
        strcpy(msg, "hello");
        rst=zmq_send (publisher, msg, 6, 0);
    }
    zmq_close(publisher);
    zmq_term(context);
    return 1;
}

`

there are two clients and three fliters, and there is one socket of the server, the port is 5555. different data with filter is send though the zmq_send().

What's the actual result? (include assertion message & call stack if applicable)

crash down

What's the expected result?

efficient running

cyforsr avatar Mar 30 '21 14:03 cyforsr

our data is transform from struct variables into char arrays by memcpy(). for example:

struct student
{   
     char name[25];
     char class[10];
     int age;
     char adress[50];
}

student stu;
memset(&stu, 0, sizeof(stu));
strcpy(stu.name, "alex");
strcpy(stu.class, "senior");
stu.age = 18;
char msg[1024];
msg[0] = '\0';
memcpy(msg, "FP:", 4);
mencpy(msg+4, &stu, sizeof(struct stu));
zmq_send(socket, msg, 1024, 0);

cyforsr avatar Mar 30 '21 14:03 cyforsr

This issue has been automatically marked as stale because it has not had activity for 365 days. It will be closed if no further activity occurs within 56 days. Thank you for your contributions.

stale[bot] avatar Apr 16 '22 17:04 stale[bot]