Using gdb to detect segmentation fault in sh?


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers Using gdb to detect segmentation fault in sh?
# 1  
Old 01-17-2015
Using gdb to detect segmentation fault in sh?

I am using scientific linux. In the directory user/project/Build, after I ran 'make' to compile and link all the cpp files,I had no problems. But then, when I went to directory
Code:
user/run/run.sh

, which runs the project binary in
Code:
user/project/Build/bin/project

, I get a segmentation fault error. In the directory user/run, I enter 'gdb' in the command prompt and get the message
Code:
*** No targets specified and no makefile found.  Stop.

"

I then set the size limit of core files by

Code:
ulimit -c 75000

But when I enter

Code:
gdb /user/project/Build/bin/project core

I get

Code:
gdb /user/project/Build/core: No such file or directory.

When I enter
Code:
bt

, I get
Code:
No stack

When I then use the command prompt to go into directory

Code:
/user/project/Build/bin

and then type

Code:
gdb project

and then "run", I get

Code:
Thread debugging using libthread_db enabled.. Program exited with code 01.Missing separate debuginfos, 
use: debuginfo-install glibc-2.12-1.149.el6_6.4.x86_64 libICE-1.0.6-1.el6.x86_64 .

..

What am I supposed to do to detect the segmentation fault?
# 2  
Old 01-22-2015
Well, 'core' is a real file, somewhere, and it has to be produced (by allowing configuration) and properly pathed for gdb to open it. The dying process puts it in $PWD/core. Once gdb is up, 'where' will get you down to a subroutine. Of course, you need source and it helps if the compile options and lack of stripping make the crashing object easy to debug. Sometiems fate is cruel, and it only bombs if you compile it without symbols! There is also running it under truss/tusc/strace to get some idea of what calls preceded the crash.
 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Programming

C. To segmentation fault or not to segmentation fault, that is the question.

Oddities with gcc, 2.95.3 for the AMIGA and 4.2.1 for MY current OSX 10.14.1... I am creating a basic calculator for the AMIGA ADE *NIX emulator in C as it does not have one. Below are two very condensed snippets of which I have added the results inside the each code section. IMPORTANT!... (11 Replies)
Discussion started by: wisecracker
11 Replies

2. Programming

Using gdb, ignore beginning segmentation fault until reproduce environment segmentation fault

I use a binary name (ie polo) it gets some parameter , so for debugging normally i do this : i wrote script for watchdog my app (polo) and check every second if it's not running then start it , the problem is , if my app , remain in state of segmentation fault for a while (ie 15 ... (6 Replies)
Discussion started by: pooyair
6 Replies

3. Programming

Segmentation fault gdb

Hello everyone, I am using the debugger from C++ and these are the message I got: Program received signal SIGSEGV, Segmentation fault. 0x0040cc0e in malloc_consolidate (av=0x4ff3c0) at malloc.c:5169 in malloc.c I don't know if the problem is cause i'm trying to acess an invalid memory... (1 Reply)
Discussion started by: juliecf5
1 Replies

4. Programming

Segmentation fault in C

i have this code int already_there(char *client_names, char *username) { int i; for(i = 0; i<NUM; i++) { printf("HERE\n"); if (strcmp(client_names, username)==0) return(1); } return(0); } and i get a segmentation fault, whats wrong here? (7 Replies)
Discussion started by: omega666
7 Replies

5. Programming

segmentation fault.

This code is causing a segmentation fault and I can't figure out why. I'm new to UNIX and I need to learn how to avoid this segmentation fault thing. Thank you so much. Thanks also for the great answers to my last post.:):b: int main() { mysqlpp::Connection conn(false); if... (3 Replies)
Discussion started by: sepoto
3 Replies

6. Programming

Segmentation fault.

I'm getting a segmentation fault. I'm new to Linux programming. Thanks so much for all of your input.:eek: #include </usr/include/mysql++/mysql++.h> #include <stdio.h> #include <iostream> #include <sstream> #include <string.h> using namespace std; int outputToImport(const char*... (1 Reply)
Discussion started by: sepoto
1 Replies

7. Programming

segmentation fault

What is segmentation fault(core dumped) (1 Reply)
Discussion started by: gokult
1 Replies

8. Programming

segmentation fault

If I do this. Assume struct life { char *nolife; } struct life **life; // malloc initialization & everything if(life->nolife == 0) Would I get error at life->nolife if it is equal to 0. wrong accession? (3 Replies)
Discussion started by: joey
3 Replies

9. UNIX for Dummies Questions & Answers

Segmentation Fault

Hi, While comparing primary key data of two tables thr bteq script I am getting this Error. This script is a shell script. *** Error: The following error was encountered on the output file. Script.sh: 3043492 Segmentation fault(coredump) Please let me know how to get through it. ... (5 Replies)
Discussion started by: monika
5 Replies

10. Programming

Why not a segmentation fault??

Hi, Why I don't receive a segmentation fault in the following sample. int main(void) { char buff; sprintf(buff,"Hello world"); printf("%s\n",buff); } If I define a buffer of 10 elements and I'm trying to put inside it twelve elements, Should I receive a sigsev... (22 Replies)
Discussion started by: lagigliaivan
22 Replies
Login or Register to Ask a Question