I have a very strange problem and since it is not possible for me to send code I will try to explain.
This is more like philosophical problem - I hope someone has time/knowledge to think about this.
1) I have project.cpp looking exactly like this:
#include <pthread.h>
#include <unistd.h>
pthread_t pplayer_thread;
void *play(void*);
int main(int argc, char **argv) {
pthread_create(&pplayer_thread, NULL, play_cb, NULL);
usleep(5000000);
return 0;
}
2) pplayer.cpp looking something like this:
...
void *play_cb(void *arg) {
// this starts movie using gstreamer and exits thread
}
...
3) not_executed_from_main.cpp looking something like this:
...
extern MyClass *myObj; // this is included from .h file
...
MyClass *myObj = NULL;
...
some_function() {
...
myObj = MyClass::createNew(args);
...
}
...
This is all linked together with various other libraries and ton of garbage, but this is basically what is important.
--> Problem:
When I run this, I should see window playing movie clip using gstreamer for 5 seconds -> BUT I only hear sound!
--> Strange thing:
When I comment the line:
myObj = MyClass::createNew(args);
and run again --> I see gstreamer window also (everything is fine)
--> Notes:
this may have something to do with:
--> I ask once more:
How can a small change in a code which is never executed make a difference?
(please help)
Seems like you need to get familiar with chaos theory. In a sufficiently complex system, the slightest change can propagate through any inherent instability to the point of causing a massive difference.
In your case, it can be anything from implicit side-effects of that method, to a memory-related error becoming visible when the layout of the executable code changes.
You should use a debugger to trace your code. Make sure nothing from the supposedly not-executed code is actually executed. Your code may be entering code paths that you mistakenly think are inaccessible, or some other part of your program (e.g. a static initilizer) may be acting up.
Valgrind can also be useful if it is available for your platform - it will detect a multitude of memory-related errors, like the one I suspect you have at your hands. Unfortunately it is not very good at detecting errors in the stack - your compiler may be able to help there, though.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With