From: Mathieu Desnoyers Date: Wed, 12 Dec 2018 22:24:11 +0000 (-0500) Subject: Fix: do not repurpose iterator while it is being used X-Git-Tag: v2.12.0-rc1~676 X-Git-Url: https://git.lttng.org./?a=commitdiff_plain;h=a5d64ae7893cc1d2b595614a8f8e3d03c401cf39;p=lttng-tools.git Fix: do not repurpose iterator while it is being used The hash table iteration uses an iterator that needs to stay valid for the next loop. Using that same iterator variable in a nested lookup in a different hash table leads to segmentation fault. Signed-off-by: Mathieu Desnoyers Signed-off-by: Jérémie Galarneau --- diff --git a/src/bin/lttng-sessiond/notification-thread-events.c b/src/bin/lttng-sessiond/notification-thread-events.c index 9cc91cc40..9d82b8313 100644 --- a/src/bin/lttng-sessiond/notification-thread-events.c +++ b/src/bin/lttng-sessiond/notification-thread-events.c @@ -1931,6 +1931,7 @@ int bind_trigger_to_matching_channels(const struct lttng_trigger *trigger, channels_ht_node) { struct lttng_trigger_list_element *trigger_list_element; struct lttng_channel_trigger_list *trigger_list; + struct cds_lfht_iter lookup_iter; if (!trigger_applies_to_channel(trigger, channel)) { continue; @@ -1940,8 +1941,8 @@ int bind_trigger_to_matching_channels(const struct lttng_trigger *trigger, hash_channel_key(&channel->key), match_channel_trigger_list, &channel->key, - &iter); - node = cds_lfht_iter_get_node(&iter); + &lookup_iter); + node = cds_lfht_iter_get_node(&lookup_iter); assert(node); trigger_list = caa_container_of(node, struct lttng_channel_trigger_list,