I have a strange problem, which I have not experienced till now.
I create two threads, and each thread basically opens a a FILE*
to write some data onto the disk.
Now, the writing part itself does not cause runtime problems (the output seems to be corrupted though), but all hell breaks loose when I close the two different FILE*
in these two separate threads.
I see that one thread has _IO_buf_base
pointing to 0x7ffff66d3000
whereas in the other thread _IO_write_end
points to 0x7ffff66d3000
. Maybe this is the reason that fclose thows up:
*** Error in `/home/raid/Documents/Temp/TemperatureMonitoringC/Debug/TemperatureMonitoringC': free(): invalid next size (normal): 0x00007ffff0000950 ***
*** Error in `/home/raid/Documents/Temp/TemperatureMonitoringC/Debug/TemperatureMonitoringC': free(): invalid next size (normal): 0x00007ffff0003540 ***
I am pretty sure that I am not the first person the have messed it up. Can anyone help? I could not find clear enough referenced on Google.
Debugger screenshots for both threads: