From 4791f626882697a94abbccdae7c2f4d16ace1904 Mon Sep 17 00:00:00 2001 From: Cameron Gutman Date: Tue, 6 Jun 2017 02:55:25 -0700 Subject: [PATCH] Add additional asserts that were useful for debugging corruption caused by the bug fixed in a499413221 --- src/ControlStream.c | 2 ++ src/RtpFecQueue.c | 8 ++++++++ 2 files changed, 10 insertions(+) diff --git a/src/ControlStream.c b/src/ControlStream.c index 2a013e3..f173dbc 100644 --- a/src/ControlStream.c +++ b/src/ControlStream.c @@ -205,6 +205,8 @@ int getNextFrameInvalidationTuple(PQUEUED_FRAME_INVALIDATION_TUPLE* qfit) { } void queueFrameInvalidationTuple(int startFrame, int endFrame) { + LC_ASSERT(startFrame <= endFrame); + if ((NegotiatedVideoFormat == VIDEO_FORMAT_H264 && (VideoCallbacks.capabilities & CAPABILITY_REFERENCE_FRAME_INVALIDATION_AVC)) || ((NegotiatedVideoFormat == VIDEO_FORMAT_H265 && (VideoCallbacks.capabilities & CAPABILITY_REFERENCE_FRAME_INVALIDATION_HEVC)))) { PQUEUED_FRAME_INVALIDATION_TUPLE qfit; diff --git a/src/RtpFecQueue.c b/src/RtpFecQueue.c index 7b413be..e95caae 100644 --- a/src/RtpFecQueue.c +++ b/src/RtpFecQueue.c @@ -80,6 +80,10 @@ static void repairPackets(PRTP_FEC_QUEUE queue) { } reed_solomon* rs = reed_solomon_new(queue->bufferDataPackets, totalParityPackets); + + // This could happen in an OOM condition, but it could also mean the FEC data + // that we fed to reed_solomon_new() is bogus, so we'll assert to get a better look. + LC_ASSERT(rs != NULL); unsigned char** packets = malloc(totalPackets * sizeof(unsigned char*)); unsigned char* marks = malloc(totalPackets * sizeof(unsigned char)); @@ -122,6 +126,10 @@ static void repairPackets(PRTP_FEC_QUEUE queue) { } ret = reed_solomon_reconstruct(rs, packets, marks, totalPackets, receiveSize); + + // We should always provide enough parity to recover the missing data successfully. + // If this fails, something is probably wrong with our FEC state. + LC_ASSERT(ret == 0); cleanup_packets: for (i = 0; i < totalPackets; i++) {