LinuxQuestions.org
Did you know LQ has a Linux Hardware Compatibility List?
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
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.

Notices

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

Rep: Reputation: 0
Unhappy 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
 
Old 07-09-2005, 04:39 PM   #2
paulsm4
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.

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

Last edited by paulsm4; 07-09-2005 at 04:41 PM.
 
Old 07-09-2005, 04:49 PM   #3
XavierP
Moderator
 
Registered: Nov 2002
Location: Kent, England
Distribution: Lubuntu
Posts: 19,176
Blog Entries: 4

Rep: Reputation: 430Reputation: 430Reputation: 430Reputation: 430Reputation: 430
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, 10:32 AM   #4
lowpro2k3
Member
 
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 10:35 AM.
 
Old 07-10-2005, 11:21 AM   #5
sundialsvcs
Guru
 
Registered: Feb 2004
Location: SE Tennessee, USA
Distribution: Gentoo, LFS
Posts: 5,401

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


Reply


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 08:57 AM
How often do threads go ot? lectraplayer General 5 09-26-2005 09:26 PM
Java Threads vs Native Threads rjmendez Programming 0 08-16-2004 05:58 AM
threads...... socket9001 Programming 4 04-26-2004 09:05 AM
Useful threads....... chingasman Linux - General 1 02-21-2003 09:23 AM


All times are GMT -5. The time now is 03:55 AM.

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