Skip to content

Instantly share code, notes, and snippets.

/*
Reproduces segmentation fault in 0MQ
1. Start in two windows
myname d1 d2
myname d2 d1
2. Kill either instance
3. Other instance crashes
#0 0x04f6e824 in ?? ()
#1 0x00152ac9 in zmq::session_t::activated (this=0x8054088, pipe_=0x8056598) at session.cpp:152
//
// Test case for issue 82
//
#include "zhelpers.h"
int main () {
void *context = zmq_init (1);
s_version ();
char *endpoint = "tcp://*:5050";
//
// Show inter-thread signalling using 0MQ sockets
//
#include "zhelpers.h"
static void *
child_thread (void *context)
{
void *socket = zmq_socket (context, ZMQ_PAIR);
assert (zmq_connect (socket, "inproc://sink") == 0);
//
// Proto1 - gateway
//
#include "zmsg.c"
#include "omp.h"
int main ()
{
void *context = zmq_init (1);
s_version ();
@hintjens
hintjens / exhaust.c
Created November 8, 2010 15:06
Exhaust file handles
// Exhaust file handles per process
#include "zmq.h"
#include "stdio.h"
int main ()
{
void *context = zmq_init (1);
int socket_nbr;
@hintjens
hintjens / mailbugz.c
Created February 16, 2011 15:53
Trying to crash 0MQ's mailbox
//
// Try to crash mailbox
//
// 1. On a single thread, have two 0mq sockets. SocketA is a PUB socket and
// SocketB is a SUB socket. SocketB should subscribe to everything.
// 2. Have SocketA do a non-blocking send for a few million messages in a
// tight loop. Do *not* allow SocketB any chance to recv until SocketA's
// loop is complete.
// 3. When SocketA's publishing is complete, let SocketB do a non-blocking
// recv until EAGAIN.
@hintjens
hintjens / mailbugz.c
Created February 16, 2011 20:15
Crash 0MQ
//
// Crash mailbox... inspired by Chuck Remes
//
#include <zmq.h>
#include <stdlib.h>
#include <stdio.h>
#include <unistd.h>
// Specify any two legally combineable socket types
@hintjens
hintjens / mailbugz.c
Created February 17, 2011 09:55
Crash 0MQ after 604 reconnection attempts
//
// Crash mailbox...
//
#include <zmq.h>
#include <stdlib.h>
#include <stdio.h>
#include <unistd.h>
// Specify any two legally combineable socket types
//
// Custom routing Router to Dealer (XREP to XREQ)
//
// Changes for 2.1:
// - added version assertion
//
#include "zhelpers.h"
@hintjens
hintjens / core.zip
Created February 21, 2011 12:43
Provoke assertion during zmq_close