segmentation fault help required


 
Thread Tools Search this Thread
Operating Systems Linux segmentation fault help required
# 1  
Old 12-22-2009
segmentation fault help required

After i build fep and do
fep echo i get a Segmentation fault

(gdb) bt full
#0 0x000000341da785f4 in strncpy () from /lib64/libc.so.6
No symbol table info available.
#1 0x000000000040228d in get_pty_master () at fep_main.c:888
pty = 0x1dd51a90 <Address 0x1dd51a90 out of bounds>
#2 0x00000000004039c1 in main (argc=<value optimized out>, argv=0x7fffaab22f10) at fep_main.c:254
cp = 0x7fffaab246bb "echo"
cp = <value optimized out>

can you help me?
# 2  
Old 12-22-2009
You wrote past the end of an array or there was no memory allocated to the destination string - strncpy() copies n characters from source to destination.

What is "fep"?
# 3  
Old 12-22-2009
fep is front end processor

I did a initial debugging using gdb, the problem seems to be with value of pty, master referes master pseudo terminal,

Code:
     pty = ptsname(master);
     strncpy(slave_tty, pty, sizeof(slave_tty));[/COLOR]

I wrote a sample code using ptsname and ran it, It ran fine, I hardcoded pty with the slave pseudo terminal i got from the script, It was fine

my sample script was
Code:
#include <stdlib.h>
#include <stdio.h>
#include <fcntl.h>
 
main() {
char *pty;
unsigned int master;
 
master = open("/dev/ptmx", O_RDWR);
pty = ptsname(master);
if(pty != NULL) {
    printf ("%s\n", pty);
}
return 0;


Last edited by pludi; 12-22-2009 at 07:51 AM.. Reason: code tags,
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. Homework & Coursework Questions

Segmentation Fault

this is a network programming code to run a rock paper scissors in a client and server. I completed it and it was working without any error. After I added the findWinner function to the server code it starts giving me segmentation fault. -the segmentation fault is fixed Current problem -Also... (3 Replies)
Discussion started by: femchi
3 Replies

3. 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

4. Programming

segmentation fault

Hi, I am having this segmentation fault not in the following program, bt. in my lab program . My lab program is horrible long so cannot post it here bt. I am using the following logic in my program which is giving the segmentation fault. Bt. if I run this sample program as it is it dosen't give... (3 Replies)
Discussion started by: mind@work
3 Replies

5. 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

6. AIX

Segmentation fault

Hi , During execution a backup binary i get following error "Program error 11 (Segmentation fault), saving core file in '/usr/datatools" Riyaz (2 Replies)
Discussion started by: rshaikh
2 Replies

7. Programming

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... (8 Replies)
Discussion started by: rockgal
8 Replies

8. UNIX for Dummies Questions & Answers

Segmentation Fault

hello all, I tried a program on an array to intialise array elements from the standard input device.it is an integer array of 5 elements.but after entering the 4th element it throws a message called "Segmentation Fault" and returns to the command prompt without asking for the 5th element. ... (3 Replies)
Discussion started by: compbug
3 Replies

9. AIX

Segmentation fault

I am tring to install Lotus Domino/Notes 5.0.5 on a AIX 4.3.3 server. I go to run the cdrom/ibmpow/install and I get the following error. Lotus Notes for Unix Install Program --------------------------------------------- ./install: 10088 Segmentation fault This had Lotus Notes installed... (1 Reply)
Discussion started by: jshaulis
1 Replies

10. Programming

segmentation fault

hi all i'm trying to execute a c program under linux RH and it gives me segmentation fault, this program was running under unix at&t anybody kow what the problem could be? thanx in advance regards (2 Replies)
Discussion started by: omran
2 Replies
Login or Register to Ask a Question