Help answer threads with 0 replies.
Go Back > Forums > Non-*NIX Forums > Programming
User Name
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.


  Search this Thread
Old 07-09-2005, 04:41 PM   #1
LQ Newbie
Registered: Mar 2005
Posts: 18

Rep: Reputation: 0
Unhappy c++ threads


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 ??

Old 07-09-2005, 05:39 PM   #2
LQ Guru
Registered: Mar 2004
Distribution: SusE 8.2
Posts: 5,863
Blog Entries: 1

Rep: Reputation: Disabled
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.

This post probably belonged in the "programming" forum.

Last edited by paulsm4; 07-09-2005 at 05:41 PM.
Old 07-09-2005, 05:49 PM   #3
Registered: Nov 2002
Location: Kent, England
Distribution: Debian Testing
Posts: 19,192
Blog Entries: 4

Rep: Reputation: 475Reputation: 475Reputation: 475Reputation: 475Reputation: 475
Moved: This thread is more suitable in Programming and has been moved accordingly to help your thread/question get the exposure it deserves.
Old 07-10-2005, 11:32 AM   #4
Registered: Oct 2003
Location: Canada
Distribution: Slackware
Posts: 340

Rep: Reputation: 30
umm, code would obviously help us figure out the problem...

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

Last edited by lowpro2k3; 07-10-2005 at 11:35 AM.
Old 07-10-2005, 12:21 PM   #5
LQ Guru
Registered: Feb 2004
Location: SE Tennessee, USA
Distribution: Gentoo, LFS
Posts: 10,078
Blog Entries: 4

Rep: Reputation: 3657Reputation: 3657Reputation: 3657Reputation: 3657Reputation: 3657Reputation: 3657Reputation: 3657Reputation: 3657Reputation: 3657Reputation: 3657Reputation: 3657
"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! ", but if you can post moderate and specific snippets we may be able to help you more.


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Java threads listed using kill -3 does not contain all threads found using ps -auxww coneheed Programming 2 11-14-2005 09:57 AM
How often do threads go ot? lectraplayer General 5 09-26-2005 10:26 PM
Java Threads vs Native Threads rjmendez Programming 0 08-16-2004 06:58 AM
threads...... socket9001 Programming 4 04-26-2004 10:05 AM
Useful threads....... chingasman Linux - General 1 02-21-2003 10:23 AM > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 09:23 PM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration