The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

Go Back   The UNIX and Linux Forums > Top Forums > High Level Programming
.
google unix.com



High Level Programming Post questions about C, C++, Java, SQL, and other programming languages here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Why not a segmentation fault?? lagigliaivan High Level Programming 22 05-21-2008 11:07 AM
Segmentation Fault compbug UNIX for Dummies Questions & Answers 3 04-21-2006 10:43 AM
segmentation fault wojtyla High Level Programming 3 02-19-2005 02:53 PM
Segmentation fault jshaulis AIX 1 06-01-2004 04:16 PM
segmentation fault omran High Level Programming 2 08-01-2003 08:19 AM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Bulgarian Greek Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 11-24-2006
rockgal rockgal is offline
Registered User
  
 

Join Date: Nov 2006
Posts: 5
Question segmentation fault

ive written my code in C for implementation of a simple lexical analyser using singly linked list hence am making use of dynamic allocation,but when run in linux it gives a segmentation fault is it cause of the malloc function that ive made use of????any suggestions as to what i could do???
thank you!!

Last edited by rockgal; 12-03-2006 at 01:02 AM..
  #2 (permalink)  
Old 11-25-2006
jim mcnamara jim mcnamara is online now Forum Staff  
...@...
  
 

Join Date: Feb 2004
Location: NM
Posts: 5,739
I can't tell what your problem is from here.
The first problem is to find where in your code the segfault occurs -
compile and run your code under a debugger (gdb)
Code:
gcc -g -o myfile myfile.c
gdb myfile
gdb > r  <command line arguments>
<segfault happens here>
ba
The ba command in gdb will show a stack trace. Please post it.
  #3 (permalink)  
Old 11-25-2006
rockgal rockgal is offline
Registered User
  
 

Join Date: Nov 2006
Posts: 5
Ya will do that & get back to you...
thanks

Last edited by rockgal; 12-03-2006 at 01:03 AM..
  #4 (permalink)  
Old 11-25-2006
reborg's Avatar
reborg reborg is offline Forum Staff  
Administrator
  
 

Join Date: Mar 2005
Location: Ireland
Posts: 4,209
rockgal, please review the rules:


(9) Edit your posts if you see spelling or grammar errors (don't write in cyberchat or cyberpunk style). English only.
  #5 (permalink)  
Old 11-27-2006
rockgal rockgal is offline
Registered User
  
 

Join Date: Nov 2006
Posts: 5
I tried out these commands gdb >r <myfile> & gdb bt <myfile> on fedora 4.0
and this is what i got
bash: syntax error near unexpected token 'newline'
Am not sure of the syntax of the command but i picked up 'bt' from the man pages. I did try all possibilities and this is what i got for all of them...!
Please let me know if my command syntax is wrong or thats the error in my program and how can i debug it???
thank you,
rockgal

Last edited by rockgal; 12-03-2006 at 01:03 AM..
  #6 (permalink)  
Old 11-27-2006
andryk's Avatar
andryk andryk is offline Forum Advisor  
Registered User
  
 

Join Date: Sep 2003
Posts: 448
Quote:
gdb > r <command-line>
refers to gdb prompt typing r + optional command-lines
Seems like you are typing this in bash "gdb >r <myfile> & gdb bt <myfile>"
Closed Thread

Bookmarks

Tags
linux

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

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 On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 02:13 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0