> >> Could you provide a reduced test case ?
> > 
> > Well, this is only two source files, with less than 300 lines.
> 
> and ? :)
Just attach GDB an look for the cause?

> > Isn't there an LLVM tool to reduce further?
> 
> http://packages.debian.org/jessie/creduce
  $ LANG=C man creduce
  No manual entry for creduce
  See 'man 7 undocumented' for help when manual pages are not available.
  $ creduce --help
  test script '/tmp/crash/--help' not found
  usage: creduce test_script.sh file.c
  Died at /usr/bin/creduce line 347.


And it's not that trivial, the clang commandline needs the line number 
and character position - which will change when modifying the file.


I tried writing a perl script to find the line, but all I get is

  running 4 interestingness tests in parallel
  test (and sanity check) fails at /usr/bin/creduce line 133.


Ah, the return code convention is the wrong way around ... and there's a 
version in unstable that understands "--help".



Seems to hang at that point:

  $ creduce ./r.pl config.h
  ===< 11609 >===
  running 4 interestingness test(s) in parallel
  ===< pass_blank :: 0 >===
  (1.1 %, 6738 bytes)
  (12.4 %, 5964 bytes)
  ===< pass_lines :: 0 >===
  (12.5 %, 5962 bytes)
  (100.0 %, 0 bytes)
  ===< pass_lines :: 0 >===


With config.h.best equal to config.h attached (just inlined booth.h into 
that file).


A second run crashes

  $ creduce ./r.pl config.h
  ===< 11590 >===
  running 4 interestingness test(s) in parallel
  ===< pass_blank :: 0 >===
  Illegal division by zero at /usr/bin/creduce line 150.

because ^C leaves config.h with 0 bytes length ;/



Well, good luck.

/* 
 * Copyright (C) 2011 Jiaju Zhang <jjzh...@suse.de>
 * Copyright (C) 2013 Philipp Marek <philipp.ma...@linbit.com>
 * 
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public
 * License as published by the Free Software Foundation; either
 * version 2.1 of the License, or (at your option) any later version.
 * 
 * This software is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * General Public License for more details.
 * 
 * You should have received a copy of the GNU General Public
 * License along with this library; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 */

#ifndef _CONFIG_H
#define _CONFIG_H

#include <stdint.h>

/* 
 * Copyright (C) 2011 Jiaju Zhang <jjzh...@suse.de>
 * Copyright (C) 2013 Philipp Marek <philipp.ma...@linbit.com>
 * 
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public
 * License as published by the Free Software Foundation; either
 * version 2.1 of the License, or (at your option) any later version.
 * 
 * This software is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * General Public License for more details.
 * 
 * You should have received a copy of the GNU General Public
 * License along with this library; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 */

#ifndef _BOOTH_H
#define _BOOTH_H

#include <stdint.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <arpa/inet.h>
#include <netinet/in.h>

#define BOOTH_LOG_DUMP_SIZE (1024*1024)

#define BOOTH_RUN_DIR "/var/run/booth/"
#define BOOTH_LOG_DIR "/var/log"
#define BOOTH_LOGFILE_NAME "booth.log"
#define BOOTH_DEFAULT_CONF "/etc/booth/booth.conf"

#define DAEMON_NAME		"booth"
#define BOOTH_NAME_LEN		63
#define BOOTH_PATH_LEN		127

#define BOOTH_PROTO_FAMILY	AF_INET

#define BOOTHC_MAGIC		0x5F1BA08C
#define BOOTHC_VERSION		0x00010002

struct boothc_header {
	/** BOOTHC_MAGIC */
	uint32_t magic;
	/** BOOTHC_VERSION */
	uint32_t version;

	/** Packet source; nodeid. See add_node(). */
	uint32_t from;

	/** Length including header */
	uint32_t length;

	/** The command, see cmd_request_t. cmp paxos_state_t ?? */
	uint32_t cmd;
	/** Result of operation. 0 == OK */
	uint32_t result;

	char data[0];
} __attribute__((packed));


typedef unsigned char boothc_site  [BOOTH_NAME_LEN];
typedef unsigned char boothc_ticket[BOOTH_NAME_LEN];

struct booth_node {
	int nodeid;
	int type;
	int local;

	int role;

	char addr_string[BOOTH_NAME_LEN];

	int tcp_fd;

	unsigned short family;
	union {
		struct sockaddr_in  sa4;
		struct sockaddr_in6 sa6;
	};
	int saddrlen;
	int addrlen;
} __attribute__((packed));


extern struct booth_node *local;

inline static int booth_get_myid(void)
{
	return local ? local->nodeid : -1;
}


struct ticket_data {
	/** Ticket name. */
	boothc_ticket id;

	/** Owner. May be NO_OWNER. See add_node().  */
	uint32_t owner;
	/* Better use that? but from is an int currently, too */
	boothc_site owner;

	/** POSIX timestamp? Or time until expiration? */
	uint32_t expiry;

	/* needed?? */
	/* From lease */
	uint32_t op; /* OP_START_LEASE, OP_STOP_LEASE? ?*/
} __attribute__((packed));


struct paxos_control_data {
	/** Current protocol state. See paxos_state_t. */
	uint32_t state;

	/** Current ballot number. Might be < prev_ballot if overflown. */
	uint32_t ballot;
	/** Previous ballot. */
	uint32_t prev_ballot;


	/* From lease - needed? */
	uint32_t clear; /* NOT_CLEAR_RELEASE ? */
	uint32_t leased;  /* has_been_leased by another node? */
};

struct paxos_control_data {

struct site_msg {
	boothc_site site;
};

struct boothc_ticket_site_msg {
	struct boothc_header header;
	struct ticket_msg ticket;
	struct site_msg site;
} __attribute__((packed));

struct boothc_ticket_msg {
	struct boothc_header header;
	struct ticket_msg ticket;
} __attribute__((packed));


struct ticket_data {
};


typedef enum {
	BOOTHC_CMD_LIST = 0x30,
	BOOTHC_CMD_GRANT,
	BOOTHC_CMD_REVOKE,
	BOOTHC_CMD_CATCHUP,
} cmd_request_t;

typedef enum {
	BOOTHC_RLT_ASYNC = 0x40,
	BOOTHC_RLT_SYNC_SUCC,
	BOOTHC_RLT_SYNC_FAIL,
	BOOTHC_RLT_INVALID_ARG,
	BOOTHC_RLT_REMOTE_OP,
	BOOTHC_RLT_OVERGRANT,
} cmd_result_t;

struct client {
        int fd;
        void (*workfn)(int);
        void (*deadfn)(int);
};

int client_add(int fd, void (*workfn)(int ci), void (*deadfn)(int ci));
int do_read(int fd, void *buf, size_t count);
int do_write(int fd, void *buf, size_t count);
void process_connection(int ci);
void safe_copy(char *dest, char *value, size_t buflen, const char *description);



static inline void init_header(struct boothc_header *h, int cmd,
			int result, int data_len)
{
	h->magic   = htonl(BOOTHC_MAGIC);
	h->version = htonl(BOOTHC_VERSION);
	h->length  = htonl(data_len);
	h->cmd     = htonl(cmd);
	h->from    = htonl(local->nodeid);
	h->expiry  = htonl(0);
	h->result  = htonl(result);
}

static inline void init_ticket_site_header(struct boothc_ticket_site_msg *msg, int cmd)
{
	init_header(&msg->header, cmd, 0, sizeof(*msg));
}

static inline void init_ticket_msg(struct boothc_ticket_msg *msg, int cmd)
{
	init_header(&msg->header, cmd, 0, sizeof(*msg));
	memset(&msg->ticket, 0, sizeof(msg->ticket));
}


static inline void init_ticket_site_msg(struct boothc_ticket_site_msg *msg, int cmd)
{
	init_ticket_site_header(msg, cmd);
	memset(&msg->site, 0, sizeof(msg->site));
	memset(&msg->ticket, 0, sizeof(msg->ticket));
}


#endif /* _BOOTH_H */
#include "config.h"
#include "paxos_lease.h"
#include "transport.h"

#define MAX_NODES	16
#define TICKET_ALLOC	16

#define NO_OWNER (-1)

struct ticket_config {
	boothc_ticket name;

	/* How many seconds to hold it */
	int expiry;
	/* Who has it. */
	int owner; struct booth_node *owner; ??

		/** Timestamp of expiration.
		 *
	time_t expires;

	int ballot;

	pl_handle_t handle;

	int weight[MAX_NODES];
};

struct booth_config {
    char name[BOOTH_NAME_LEN];
    int node_count;
    int ticket_count;
    transport_layer_t proto;
    uint16_t port;
    struct booth_node node[MAX_NODES];
    struct ticket_config ticket[0];
};

struct booth_config *booth_conf;

int read_config(const char *path);

int check_config(int type);

int find_site_in_config(unsigned char *site, struct booth_node **node);

const char *type_to_string(int type);

static inline struct booth_transport const *transport(void) {
	return booth_transport + booth_conf->proto;
}


#endif /* _CONFIG_H */

Reply via email to