Void StartDUTThread (int iDut)
{
//cstrings strTemp;
//AfxMessageBox (_T (" 1 "));
Int index=threadReq [iDut - 1]. The index;
G_iThreadResult] [iDut - 1 & amp;=threadReq [iDut - 1]. CurrentFunc (iDut, index);
G_bThreadEnabled [iDut - 1]=false;//notify the main thread has performed the task
if (! G_iThreadResult [iDut - 1) | | bIsStop [] iDut - 1)
{
EndDutThread (iDut, index);
}
}
As the above function, I'm a total of four threads, each thread to call this function at the same time, the debug mode: this function can be normal operation; The release mode: this function will be not bottom go to, such as I put "AfxMessageBox (_T (" 1")); "Comments cancelled, will not play frame, function may not come in, but I put the" cstrings strTemp; "Comments before take off, this function can run normally done, I tried to make the" cstrings strTemp; "Instead of other types, such as int, Boolean, etc., could not perform function, now found that add cstrings type of variable declarations can perform, how strange! Who can answer?
CodePudding user response:
You describe phenomena should be triggered some undefined behavior, multithreading estimate is the issue of global variables, to reduce the number of threads, and then break point to look atCodePudding user response:
Surface stack was changed,Cstrings strTemp; Unused, with space on the stack release, will not be optimized away,
Int t [n]. Unused, leaving no space on the stack release, will be optimized away,
Stack rewritten, so probably iDut parameter is changed, under test,