Closed
Description
Following program crashes on my machine (x86_64 linux, commit 50e277b).
#include <zmq.h>
#include <error.h>
#include <stdio.h>
#include <stdlib.h>
#include <assert.h>
void check(int rc)
{
rc = rc;
if (rc < 0)
{
fprintf(stderr, "%s:%d ERROR: %u\n",
__FILE__, __LINE__, errno);
exit(1);
}
}
int test_sock(const char* addr, int sock_type, int connect, int n)
{
int i;
int rc;
// typically fails very quickly, less than 20 iterations
for (i = 0; i < n; i++)
{
printf("\r%d", i);
fflush(stdout);
void *ctx = zmq_ctx_new();
assert(ctx);
void *sock = zmq_socket(ctx, sock_type);
assert(sock);
if (connect) {
check(zmq_connect(sock, addr));
} else {
check(zmq_bind(sock, addr));
}
check(zmq_close(sock));
check(zmq_ctx_term(ctx));
}
printf("\n");
}
int main(void)
{
test_sock("inproc://testing", ZMQ_REP, 1, 1000);
test_sock("inproc://testing", ZMQ_ROUTER, 1, 1000);
return 0;
}
Error message:
Assertion failed: written (/home/seb/src/libzmq/src/ctx.cpp:583)
What is the function of that assertion? Would it be okay to let it silently fail here, especially when there is nobody receiving the message. Also, smells like a race condition because not every iteration causes a crash...
Metadata
Metadata
Assignees
Labels
No labels