[tor-commits] [tor/master] Use assertions so GCC LTO doesn't worry about TLS channel conversion
nickm at torproject.org
nickm at torproject.org
Sun Oct 14 19:42:13 UTC 2018
commit 965549aa07d94a9f9e510cdb7a215bf9a3ed7bb8
Author: Nick Mathewson <nickm at torproject.org>
Date: Tue Sep 18 15:06:36 2018 -0400
Use assertions so GCC LTO doesn't worry about TLS channel conversion
Part of #27772
---
src/core/mainloop/connection.c | 11 ++++++-----
src/core/or/channel.c | 2 ++
src/core/or/channelpadding.c | 2 ++
src/core/or/scheduler_kist.c | 4 ++++
4 files changed, 14 insertions(+), 5 deletions(-)
diff --git a/src/core/mainloop/connection.c b/src/core/mainloop/connection.c
index 0c3abc844..7e2c4ce40 100644
--- a/src/core/mainloop/connection.c
+++ b/src/core/mainloop/connection.c
@@ -656,14 +656,15 @@ connection_free_minimal(connection_t *conn)
tor_free(or_conn->nickname);
if (or_conn->chan) {
/* Owww, this shouldn't happen, but... */
+ channel_t *base_chan = TLS_CHAN_TO_BASE(or_conn->chan);
+ tor_assert(base_chan);
log_info(LD_CHANNEL,
"Freeing orconn at %p, saw channel %p with ID "
"%"PRIu64 " left un-NULLed",
- or_conn, TLS_CHAN_TO_BASE(or_conn->chan),
- (
- TLS_CHAN_TO_BASE(or_conn->chan)->global_identifier));
- if (!CHANNEL_FINISHED(TLS_CHAN_TO_BASE(or_conn->chan))) {
- channel_close_for_error(TLS_CHAN_TO_BASE(or_conn->chan));
+ or_conn, base_chan,
+ base_chan->global_identifier);
+ if (!CHANNEL_FINISHED(base_chan)) {
+ channel_close_for_error(base_chan);
}
or_conn->chan->conn = NULL;
diff --git a/src/core/or/channel.c b/src/core/or/channel.c
index 0c204ddfb..79c52235d 100644
--- a/src/core/or/channel.c
+++ b/src/core/or/channel.c
@@ -3423,6 +3423,8 @@ channel_rsa_id_group_set_badness(struct channel_list_s *lst, int force)
/* it would be more efficient to do a slice, but this case is rare */
smartlist_t *or_conns = smartlist_new();
SMARTLIST_FOREACH_BEGIN(channels, channel_t *, channel) {
+ tor_assert(channel); // Suppresses some compiler warnings.
+
if (!common_ed25519_identity)
common_ed25519_identity = &channel->ed25519_identity;
diff --git a/src/core/or/channelpadding.c b/src/core/or/channelpadding.c
index 7c3a77f62..d3d6890c0 100644
--- a/src/core/or/channelpadding.c
+++ b/src/core/or/channelpadding.c
@@ -296,6 +296,7 @@ channelpadding_send_disable_command(channel_t *chan)
channelpadding_negotiate_t disable;
cell_t cell;
+ tor_assert(chan);
tor_assert(BASE_CHAN_TO_TLS(chan)->conn->link_proto >=
MIN_LINK_PROTO_FOR_CHANNEL_PADDING);
@@ -328,6 +329,7 @@ channelpadding_send_enable_command(channel_t *chan, uint16_t low_timeout,
channelpadding_negotiate_t enable;
cell_t cell;
+ tor_assert(chan);
tor_assert(BASE_CHAN_TO_TLS(chan)->conn->link_proto >=
MIN_LINK_PROTO_FOR_CHANNEL_PADDING);
diff --git a/src/core/or/scheduler_kist.c b/src/core/or/scheduler_kist.c
index 41c346ac7..f112ea635 100644
--- a/src/core/or/scheduler_kist.c
+++ b/src/core/or/scheduler_kist.c
@@ -116,6 +116,7 @@ static unsigned int kist_lite_mode = 1;
static inline size_t
channel_outbuf_length(channel_t *chan)
{
+ tor_assert(chan);
/* In theory, this can not happen because we can not scheduler a channel
* without a connection that has its outbuf initialized. Just in case, bug
* on this so we can understand a bit more why it happened. */
@@ -194,6 +195,8 @@ update_socket_info_impl, (socket_table_ent_t *ent))
{
#ifdef HAVE_KIST_SUPPORT
int64_t tcp_space, extra_space;
+ tor_assert(ent);
+ tor_assert(ent->chan);
const tor_socket_t sock =
TO_CONN(BASE_CHAN_TO_TLS((channel_t *) ent->chan)->conn)->s;
struct tcp_info tcp;
@@ -451,6 +454,7 @@ MOCK_IMPL(int, channel_should_write_to_kernel,
* kernel */
MOCK_IMPL(void, channel_write_to_kernel, (channel_t *chan))
{
+ tor_assert(chan);
log_debug(LD_SCHED, "Writing %lu bytes to kernel for chan %" PRIu64,
(unsigned long)channel_outbuf_length(chan),
chan->global_identifier);
More information about the tor-commits
mailing list