Quote Originally Posted by JacobNax View Post
Hi, i have a very weird fatal exception happening very rarely on my application (compiled under gcc - Ubuntu linux)

it seems that this this function :

Code:
bool GetConnect( ) {return m_Connected;}
causes a Segmentation Fault sometimes (not all the times)
There is nothing weird about these errors. When you corrupt memory, use pointers incorrectly, or other errors that cause memory corruption, then the behaviour of the application is undefined. It could work all the time, fail sometimes, work on one machine and fail on another. So nothing is "weird".
No the instance of the class is not deleted when i call that function.
Great, but how are we, persons who know nothing about the rest of your code, the state of your program at the time of the crash, what really happened before the problem occurred, can confirm this? Too many times, we get persons taking oaths that they are doing this or that, and when it comes time to actually see their code in action, they are not doing what they say they are doing.
I tried declaring m_Connected as volatile bool m_Connected but still the error happens.
several different threads also access the function that calls this function.
So are you or do you use proper synchronization in this multithreaded program? The usage of "volatile" is not a substitute for proper thread synchronization (mutexes, semaphores, etc.).
to make sure that another thread doesnt crash the application i also tried creating the other threads in completely different timings. It crashes every time on the same line.
First, does your program run correctly using one thread? If not, then you need to correct that first.

After that, use proper synchronization objects in your code. Trying to outguess when to create a thread by using "different timings" (whatever that is), or using "volatile" as a poor man's synchronization object isn't going to get the job done.
Although it makes no sense at all
If this indeed a threading problem, and you are not familiar with what parts of the code are not thread safe, then anything can happen that may not seem to make sense. Racing conditions, re-entrancy issues, etc. are all of the things that a programmer must be aware of when writing or maintaining multithreaded applications, and little to no experience in these issues will make a seemingly OK looking multithreaded program into one that will fail.

Regards,

Paul McKenzie