Skip to contentSkip to conversation

Fix: consumer snapshot: handle unsigned long overflow

PATCH Jérémie Galarneau 1 participant 1 message Mar 29, 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, stable-2.11, stable-2.10, and stable-2.9.

Thanks!
Jérémie

Quoted 42 lines · Mathieu Desnoyers

Comparing the consumed iterator and the produced position without using a difference generates an empty snapshot when the iterator is before unsigned long overflow and the produced position is after unsigned long overflow.

This applies to both UST and kernel consumers.

---
 src/common/kernel-consumer/kernel-consumer.c | 2 +-
 src/common/ust-consumer/ust-consumer.c       | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)
src/common/kernel-consumer/kernel-consumer.c +1 -1
index 9bed7b55..1533e9ef 100644
@@ -234,7 +234,7 @@ int lttng_kconsumer_snapshot_channel(struct lttng_consumer_channel *channel,
 				produced_pos, nb_packets_per_stream,
 				stream->max_sb_size);
 
-		while (consumed_pos < produced_pos) {
+		while ((long) (consumed_pos - produced_pos) < 0) {
 			ssize_t read_len;
 			unsigned long len, padded_len;
 
src/common/ust-consumer/ust-consumer.c +1 -1
index 46f33005..94b761cb 100644
@@ -1168,7 +1168,7 @@ static int snapshot_channel(struct lttng_consumer_channel *channel,
 				produced_pos, nb_packets_per_stream,
 				stream->max_sb_size);
 
-		while (consumed_pos < produced_pos) {
+		while ((long) (consumed_pos - produced_pos) < 0) {
 			ssize_t read_len;
 			unsigned long len, padded_len;
 
Signature · 1 line
2.11.0