Q:

how can reading data from a buffer affect the value of another variable in C

Ok I was looking at this for hours. If the data I'm providing is does not provide full context please let me know and I'll provide some more.
So basically I got a blob of data pointed to by NSData * packetDescData and it looks like this:
00000000 00000000 00000007 00000007 00000000 00000016 0000001d 00000000 0000001a 00000037 00000000
0000002a 00000061 00000000 00000025 00000086 00000000 00000029 000000af 00000000 00000032 000000e1     
00000000 00000027 00000108 00000000 00000038 00000140 00000000 00000031 00000171 00000000 0000001e
0000018f 00000000 00000035 000001c4 00000000 00000027 000001eb 00000000 0000002d 00000218 00000000 
00000031 00000249 00000000 00000026 0000026f 00000000 00000033 000002a2 00000000 00000037 000002d9 
00000000 00000035 0000030e 00000000 0000002c 0000033a 00000000 00000025 0000035f 00000000 00000020 
0000037f 00000000 00000034 000003b3 00000000 0000005d

I run through a loop that reads data from certain offsets and assign them to different variables: (along with log statements):
for (int i=0; i < packetDescNumber; i++) {    
    packetDescs[i].mStartOffset = [packetDescData rw_int32AtOffset:offset];
    offset += sizeof(UInt32);        
    NSLog(@"packetDescriptionArray[%d].mStartOffset: %lld, fillbuffindex: %d, offset %lu", i,packetDescs[i].mStartOffset, fillBufferIndex, offset);

    packetDescs[i].mVariableFramesInPacket = [packetDescData rw_int32AtOffset:offset];
    offset += sizeof(UInt32);
    NSLog(@"packetDescriptionArray[%d].mVariableFramesInPacket: %lu, fillbuffindex: %d, offset %lu", i,packetDescs[i].mVariableFramesInPacket, fillBufferIndex, offset);

    packetDescs[i].mDataByteSize = [packetDescData rw_int32AtOffset:offset];                
    offset += sizeof(UInt32);
    NSLog(@"packetDescriptionArray[%d].mDataByteSize: %lu, fillbuffindex: %d, offset %lu", i,packetDescs[i].mDataByteSize, fillBufferIndex, offset);

    NSLog(@"-------------------------------------------------------\n\n\n\n");

}    

rw_int32AtOffset is defined as:
- (int)rw_int32AtOffset:(size_t)offset
{
    const int *intBytes = (const int *)[self bytes];
    return ntohl(intBytes[offset / 4]);
}

the output is this (notice how some other random variable (fillbuffindex).. on the same thread.. suddenly changes it's value to the same value as mStartOffset when mStartOffset becomes 175 at packetDescriptionArray[6].mStartOffset:
packetDescriptionArray[4].mStartOffset: 97, fillbuffindex: 0, offset 52
MAIN: we are appending 1231 bytes to ring buffer
MAIN: appendToRingBuffer: FILLBUFFERINDEX: 0
packetDescriptionArray[4].mVariableFramesInPacket: 0, fillbuffindex: 0, offset 56
packetDescriptionArray[4].mDataByteSize: 37, fillbuffindex: 0, offset 60
-------------------------------------------------------

packetDescriptionArray[5].mStartOffset: 134, fillbuffindex: 0, offset 64
packetDescriptionArray[5].mVariableFramesInPacket: 0, fillbuffindex: 0, offset 68
packetDescriptionArray[5].mDataByteSize: 41, fillbuffindex: 0, offset 72
-------------------------------------------------------

packetDescriptionArray[6].mStartOffset: 175, fillbuffindex: 175, offset 76
packetDescriptionArray[6].mVariableFramesInPacket: 0, fillbuffindex: 175, offset 80
packetDescriptionArray[6].mDataByteSize: 50, fillbuffindex: 175, offset 84
-------------------------------------------------------

packetDescriptionArray[7].mStartOffset: 225, fillbuffindex: 175, offset 88
packetDescriptionArray[7].mVariableFramesInPacket: 0, fillbuffindex: 175, offset 92
packetDescriptionArray[7].mDataByteSize: 39, fillbuffindex: 175, offset 96
-------------------------------------------------------

MAIN: we are appending 1224 bytes to ring buffer
MAIN: appendToRingBuffer: FILLBUFFERINDEX: 175
packetDescriptionArray[8].mStartOffset: 264, fillbuffindex: 175, offset 100
packetDescriptionArray[8].mVariableFramesInPacket: 0, fillbuffindex: 175, offset 104
packetDescriptionArray[8].mDataByteSize: 56, fillbuffindex: 175, offset 108
-------------------------------------------------------

the  MAIN: we are appending 1231 bytes to ring buffer point is just me appending to a ring buffer on a separate thread.. the ring buffer is shared amongst the threads, but it has nothing to do with fillbuffindex.. any ideas? 

A:

I originally answered in the comments:

I work under the assumption that if memory bounds are overrun (even
  during reading) then almost anything can happen. So reading your post
  I assume you are overrunning your memory bounds somewhere. Look for
  memory related errors using a memory debugger like valgrind: valgrind
  --leak-check=yes a.out and also a static analyzer like the clang static analyzer: scan-build gcc mycode.c

This is a generic answer to any question like: "I'm getting really weird behavior in a code that uses dynamic memory allocation." The point is that overrunning memory can cause undefined behavior, including e.g. variables changing without being explicitly assigned to.
Besides manual debugging, static analyzers like the clang static analyzer and memory debuggers like valgrind are great for finding bugs like this.

