define TOR_FRAGILE if you want tor to give you a core when

something goes wrong. this should only be used by people actively
tracking bugs.


svn:r3487
This commit is contained in:
Roger Dingledine 2005-02-01 00:37:16 +00:00
parent e7e77d6d8e
commit 2e97593d25
9 changed files with 70 additions and 2 deletions

View File

@ -764,6 +764,9 @@ static int new_route_len(double cw, uint8_t purpose, smartlist_t *routers) {
routelen = 4;
else {
log_fn(LOG_WARN,"Bug: unhandled purpose %d", purpose);
#ifdef TOR_FRAGILE
tor_assert(0);
#endif
return -1;
}
#endif
@ -1078,6 +1081,9 @@ choose_good_exit_server(uint8_t purpose, routerlist_t *dir,
return r;
}
log_fn(LOG_WARN,"Bug: unhandled purpose %d", purpose);
#ifdef TOR_FRAGILE
tor_assert(0);
#endif
return NULL;
}

View File

@ -699,6 +699,9 @@ circuit_launch_by_identity(uint8_t purpose, const char *exit_digest,
default:
log_fn(LOG_WARN,"Bug: unexpected purpose %d when cannibalizing a general circ.",
purpose);
#ifdef TOR_FRAGILE
tor_assert(0);
#endif
return NULL;
}
return circ;

View File

@ -220,8 +220,12 @@ void connection_about_to_close_connection(connection_t *conn)
assert(conn->marked_for_close);
if (conn->type == CONN_TYPE_AP || conn->type == CONN_TYPE_EXIT) {
if (!conn->has_sent_end)
if (!conn->has_sent_end) {
log_fn(LOG_WARN,"Bug: Edge connection hasn't sent end yet?");
#ifdef TOR_FRAGILE
tor_assert(0);
#endif
}
}
switch (conn->type) {
@ -295,6 +299,9 @@ void connection_close_immediate(connection_t *conn)
assert_connection_ok(conn,0);
if (conn->s < 0) {
log_fn(LOG_WARN,"Bug: Attempt to close already-closed connection.");
#ifdef TOR_FRAGILE
tor_assert(0);
#endif
return;
}
if (conn->outbuf_flushlen) {
@ -319,6 +326,9 @@ _connection_mark_for_close(connection_t *conn)
if (conn->marked_for_close) {
log(LOG_WARN, "Bug: Double mark-for-close on connection.");
#ifdef TOR_FRAGILE
tor_assert(0);
#endif
return -1;
}
@ -1371,6 +1381,9 @@ static int connection_process_inbuf(connection_t *conn, int package_partial) {
return connection_control_process_inbuf(conn);
default:
log_fn(LOG_WARN,"Bug: got unexpected conn type %d.", conn->type);
#ifdef TOR_FRAGILE
tor_assert(0);
#endif
return -1;
}
}
@ -1403,6 +1416,9 @@ static int connection_finished_flushing(connection_t *conn) {
return connection_control_finished_flushing(conn);
default:
log_fn(LOG_WARN,"Bug: got unexpected conn type %d.", conn->type);
#ifdef TOR_FRAGILE
tor_assert(0);
#endif
return -1;
}
}
@ -1426,6 +1442,9 @@ static int connection_finished_connecting(connection_t *conn)
return connection_dir_finished_connecting(conn);
default:
log_fn(LOG_WARN,"Bug: got unexpected conn type %d.", conn->type);
#ifdef TOR_FRAGILE
tor_assert(0);
#endif
return -1;
}
}
@ -1448,6 +1467,9 @@ static int connection_reached_eof(connection_t *conn)
return connection_control_reached_eof(conn);
default:
log_fn(LOG_WARN,"Bug: got unexpected conn type %d.", conn->type);
#ifdef TOR_FRAGILE
tor_assert(0);
#endif
return -1;
}
}

View File

@ -93,6 +93,9 @@ int connection_edge_process_inbuf(connection_t *conn, int package_partial) {
return 0;
}
log_fn(LOG_WARN,"Bug: Got unexpected state %d. Closing.",conn->state);
#ifdef TOR_FRAGILE
tor_assert(0);
#endif
connection_edge_end(conn, END_STREAM_REASON_MISC, conn->cpath_layer);
connection_mark_for_close(conn);
return -1;
@ -131,6 +134,9 @@ connection_edge_end(connection_t *conn, char reason, crypt_path_t *cpath_layer)
if (conn->has_sent_end) {
log_fn(LOG_WARN,"Bug: Calling connection_edge_end on an already ended stream?");
#ifdef TOR_FRAGILE
tor_assert(0);
#endif
return -1;
}
@ -183,6 +189,9 @@ int connection_edge_finished_flushing(connection_t *conn) {
return 0;
default:
log_fn(LOG_WARN,"BUG: called in unexpected state %d.", conn->state);
#ifdef TOR_FRAGILE
tor_assert(0);
#endif
return -1;
}
return 0;

View File

@ -78,6 +78,9 @@ int connection_or_finished_flushing(connection_t *conn) {
if (conn->state != OR_CONN_STATE_OPEN) {
log_fn(LOG_WARN,"BUG: called in unexpected state %d",conn->state);
#ifdef TOR_FRAGILE
tor_assert(0);
#endif
return -1;
}
@ -210,7 +213,7 @@ connection_t *connection_or_connect(uint32_t addr, uint16_t port,
if (server_mode(get_options()) && (me=router_get_my_routerinfo()) &&
!memcmp(me->identity_digest, id_digest,DIGEST_LEN)) {
log_fn(LOG_WARN,"Bug: Request to connect to myself! Failing.");
log_fn(LOG_WARN,"Bug: Client asked me to connect to myself! Refusing.");
return NULL;
}

View File

@ -1080,6 +1080,9 @@ int connection_dir_finished_flushing(connection_t *conn) {
return 0;
default:
log_fn(LOG_WARN,"Bug: called in unexpected state %d.", conn->state);
#ifdef TOR_FRAGILE
tor_assert(0);
#endif
return -1;
}
return 0;

View File

@ -118,9 +118,15 @@ static void purge_expired_resolves(uint32_t now) {
log(LOG_DEBUG,"Forgetting old cached resolve (expires %lu)", (unsigned long)resolve->expire);
if (resolve->state == CACHE_STATE_PENDING) {
log_fn(LOG_WARN,"Bug: Expiring a dns resolve that's still pending. Forgot to cull it?");
#ifdef TOR_FRAGILE
tor_assert(0);
#endif
}
if (resolve->pending_connections) {
log_fn(LOG_WARN, "Closing pending connections on expiring DNS resolve!");
#ifdef TOR_FRAGILE
tor_assert(0);
#endif
while (resolve->pending_connections) {
pend = resolve->pending_connections;
resolve->pending_connections = pend->next;
@ -401,6 +407,9 @@ void dns_cancel_pending_resolve(char *address) {
if (!resolve->pending_connections) {
/* XXX this should never trigger, but sometimes it does */
log_fn(LOG_WARN,"Bug: Address '%s' is pending but has no pending connections!", address);
#ifdef TOR_FRAGILE
tor_assert(0);
#endif
return;
}
tor_assert(resolve->pending_connections);
@ -596,6 +605,9 @@ int connection_dns_process_inbuf(connection_t *conn) {
if (conn->state != DNSWORKER_STATE_BUSY && buf_datalen(conn->inbuf)) {
log_fn(LOG_WARN,"Bug: read data from an idle dns worker. Please report.");
#ifdef TOR_FRAGILE
tor_assert(0);
#endif
return 0;
}
if (buf_datalen(conn->inbuf) < 5) /* entire answer available? */

View File

@ -339,6 +339,9 @@ conn_read_callback(int fd, short event, void *_conn)
#ifndef MS_WINDOWS
log_fn(LOG_WARN,"Bug: unhandled error on read for %s connection (fd %d); removing",
CONN_TYPE_TO_STRING(conn->type), conn->s);
#ifdef TOR_FRAGILE
tor_assert(0);
#endif
#endif
connection_mark_for_close(conn);
}
@ -366,6 +369,9 @@ static void conn_write_callback(int fd, short events, void *_conn)
/* this connection is broken. remove it. */
log_fn(LOG_WARN,"Bug: unhandled error on write for %s connection (fd %d); removing",
CONN_TYPE_TO_STRING(conn->type), conn->s);
#ifdef TOR_FRAGILE
tor_assert(0);
#endif
conn->has_sent_end = 1; /* otherwise we cry wolf about duplicate close */
/* XXX do we need a close-immediate here, so we don't try to flush? */
connection_mark_for_close(conn);

View File

@ -128,6 +128,10 @@
#include "../common/util.h"
#include "../common/torgzip.h"
/** Define this if you want Tor to crash when any problem comes up,
* so you can get a coredump and track things down. */
#undef TOR_FRAGILE
/** Upper bound on maximum simultaneous connections; can be lowered by
* config file. */
#define MAXCONNECTIONS 15000