So I am running into an odd problem. I have a pointer to a struct, and I am passing it to a function. Once inside that function, one of the variables I am interested in appears to be 0, but before passing the struct to the function I check to make sure that specific variable is not 0. The weird thing is this does not happen every time, only once in a while. Has anyone ever seen something like this happen before?
Source Code:
if( expand->num == 0)
return status;
status = decode( expand );
...
Status_type decode ( expand_type * expand )
{
if(expand->cur_num >= expand->num) // Here is where my error occurs
// 'num' is 0.
{
// Do stuff
}
}
Finally found the problem. There are multiple threads, and two threads were trying to access the same variable at the same time (the expand variable), causing it to be overwritten! So I had to stop one of the threads at a certain point so both wouldn’t be accessing the same stuff.