LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Home Forums Tutorials Articles Register
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
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.

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: 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, 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
LQ Guru
 
Registered: Feb 2004
Location: SE Tennessee, USA
Distribution: Gentoo, LFS
Posts: 10,659
Blog Entries: 4

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



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

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 11:53 PM.

Main Menu
Advertisement
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
Open Source Consulting | Domain Registration