fix memory leak
authorBrian Demsky <bdemsky@uci.edu>
Thu, 28 May 2020 19:54:52 +0000 (12:54 -0700)
committerBrian Demsky <bdemsky@uci.edu>
Thu, 28 May 2020 19:54:52 +0000 (12:54 -0700)
datarace.cc

index 28ebcf6..cfbe94b 100644 (file)
@@ -143,6 +143,8 @@ static void expandRecord(uint64_t *shadow)
                ASSERT(readThread >= 0);
                record->thread[0] = readThread;
                record->readClock[0] = readClock;
+       } else {
+               record->thread = NULL;
        }
        if (shadowval & ATOMICMASK)
                record->isAtomic = 1;
@@ -541,7 +543,7 @@ struct DataRace * fullRaceCheckRead(thread_id_t thread, const void *location, ui
        }
 
        if (__builtin_popcount(copytoindex) <= 1) {
-               if (copytoindex == 0) {
+               if (copytoindex == 0 && record->thread == NULL) {
                        int newCapacity = INITCAPACITY;
                        record->thread = (thread_id_t *)snapshot_malloc(sizeof(thread_id_t) * newCapacity);
                        record->readClock = (modelclock_t *)snapshot_malloc(sizeof(modelclock_t) * newCapacity);