LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   c++ threads (https://www.linuxquestions.org/questions/programming-9/c-threads-341673/)

siemens 07-09-2005 03:41 PM

c++ threads
 
hi

I'm having troubles to use threads at my c++ program.

every time I'm trying to use thread the program throws "segmention fault" announcment...

does anu one know what is the problem ??

thanks

paulsm4 07-09-2005 04:39 PM

Run your program in a debugging (for example, "gdb").

When it dies, look at your stack traceback (for example, "where")

Look backwards from the point of failure.

PS:
This post probably belonged in the "programming" forum.

XavierP 07-09-2005 04:49 PM

Moved: This thread is more suitable in Programming and has been moved accordingly to help your thread/question get the exposure it deserves.

lowpro2k3 07-10-2005 10:32 AM

umm, code would obviously help us figure out the problem...

Telling us the thread library you're using would also be a help

sundialsvcs 07-10-2005 11:21 AM

"Segmentation fault" means nothing more and nothing less than "your program tried to use a chunk of memory that was not assigned to it." That's a wild-behavior of the program which could happen for any number of reasons, none of which have anything to do with threading.

It is, however, somewhat more likely to be some kind of a timing problem. So maybe the very first thing to do is to establish that the threads really are being created... then start carefully debugging your code. Some things to consider:
  • Are you, in fact, using synchronization objects (mutexes, locks, etc.) in a well-planned and "correct" way?
  • Are you properly initializing those objects?
  • Are there any possible "timing holes" at all?
  • Are you properly initializing all memory-blocks... is there any possibility of a "stale" or uninitialized pointer?
Most of the time, such diagnoses require some very careful "desk checking," because when a segmentation-fault happens it is usually down in the bowels of some runtime library, far away both in time and in space from where the real source of the problem lies.

It is fairly unrealistic to hand a program to a forum and say, "debug it for me! :rolleyes:", but if you can post moderate and specific snippets we may be able to help you more.


All times are GMT -5. The time now is 01:18 PM.