LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
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 08-26-2005, 10:05 AM   #1
sachintalk
LQ Newbie
 
Registered: Aug 2005
Posts: 3

Rep: Reputation: 0
help required on segmentation fault


Hi all,

I have multithreaded application. (pthread_create).
I did threadpooling.

I am getting Segmentation fault. (randomly)
Is there any way to know in which thread Segmentation fault has occoured.

Can i get thread_id or anything related in signal handler?

Regards,
sachin.
 
Old 08-26-2005, 11:38 AM   #2
jim mcnamara
Member
 
Registered: May 2002
Posts: 964

Rep: Reputation: 36
Did you try gdb - compiling gcc -g , etc.?
 
Old 08-27-2005, 02:11 AM   #3
sachintalk
LQ Newbie
 
Registered: Aug 2005
Posts: 3

Original Poster
Rep: Reputation: 0
help required on segmentation fault

Hi,

i did gdb.
problem is not occouring for each run.
say it comes aftrer 10 days.

I added log per thread, but as there is multipal thread
i want to know which thread gets segmentation fault.


Regards,
sachin.
 
Old 09-05-2005, 06:49 AM   #4
shishir
Member
 
Registered: Jul 2003
Location: bangalore . india
Distribution: openSUSE 10.3
Posts: 251

Rep: Reputation: 33
if you want to log the thread id of teh thread that was executing when the program crashed...you may want to handle the signal , sigsegv, log the pthread_self in some file or to some console and then restore the default hanler for segv and return so that the default behaviour of the signal takes up from there...
Code:
void handle(int sig)
{
      fprintf (stderr, "here with tid: %d \n", pthread_self());
      signal (SIGSEGV,SIG_DFL);
      return;
}
-shishir
 
Old 09-06-2005, 01:22 AM   #5
paulsm4
LQ Guru
 
Registered: Mar 2004
Distribution: SusE 8.2
Posts: 5,863
Blog Entries: 1

Rep: Reputation: Disabled
You can also run the program inside gdb for 10 days. Or start the program(s) and, once started, attach to it (them) with GDB.

Either way, GDB will be able to tell you a lot more. For example: how many threads were active, and their respective stackss.
 
Old 09-07-2005, 11:20 PM   #6
sachintalk
LQ Newbie
 
Registered: Aug 2005
Posts: 3

Original Poster
Rep: Reputation: 0
Before running my application
i set

ulimit -c unlimited

for core dump.

I debug core file with gdb and reach to root of problem.

thanks for help.

Regards,
sachin.
 
  


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
yast segmentation fault, system freezing - nvidia driver at fault? BaltikaTroika SUSE / openSUSE 2 12-02-2005 09:34 AM
Help !!! Segmentation fault mola Linux - Software 3 06-23-2005 11:13 AM
Segmentation fault tejas15_10 Programming 9 06-20-2005 09:12 AM
segmentation fault ntduongntd Linux - General 4 11-29-2004 12:00 PM
segmentation fault ! wwnn1 Programming 7 06-18-2002 09:48 AM

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

All times are GMT -5. The time now is 12:05 AM.

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