I have a code. like this:
int functionA (){
Foo(**,**,**);
return 0;
}
Foo() is a huge function(more than 10,000 lines). Which I don’t understand all.Foo function includes some multi-thread code.
The problem now is, if I have “return” code right after Foo, Foo can be run correctly.
If I insert some other code (even a really simple cout code) between Foo() and “return”. The Foo function will act weird(partly not run correctly).
I debugged this thing for 3 days. Nothing found.
This is known as a race condition, some of your code is likely interfering with the operation of Foo(), without a more detailed description of the problem it is impossible to determine how to fix it. Either sleep() while the threaded operations are in progress, or read the documentation to determine if foo() can be safely operated on, and if a flag is set by foo to indicate when it is thread safe.