Latest LQ Deal: Linux Power User Bundle
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 08-26-2005, 11:05 AM   #1
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?

Old 08-26-2005, 12:38 PM   #2
jim mcnamara
Registered: May 2002
Posts: 964

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

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


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.

Old 09-05-2005, 07:49 AM   #4
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 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...
void handle(int sig)
      fprintf (stderr, "here with tid: %d \n", pthread_self());
      signal (SIGSEGV,SIG_DFL);
Old 09-06-2005, 02:22 AM   #5
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-08-2005, 12:20 AM   #6
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.



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

All times are GMT -5. The time now is 06:15 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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration