Skip to contentSkip to conversation

Fix: do not repurpose iterator while it is being used

PATCH Jérémie Galarneau 1 participant 1 message Jan 22, 2019 1 message not in the archive

lore
Share & tools
lore

A message that is not in the archive (sent off-list or not yet received): [email protected]

#1 lore raw

Merged in master and stable-2.11.

Thanks,
Jérémie

Quoted 36 lines · Mathieu Desnoyers

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.

---
 src/bin/lttng-sessiond/notification-thread-events.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
src/bin/lttng-sessiond/notification-thread-events.c +3 -3
index 9cc91cc4..9d82b831 100644
@@ -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,
--

2.11.0

Signature · 7 lines
Jérémie Galarneau
EfficiOS Inc.
http://www.efficios.com
_______________________________________________
lttng-dev mailing list
[email protected]
https://lists.lttng.org/cgi-bin/mailman/listinfo/lttng-dev