SIGSEGV, Segmentation fault


 
Thread Tools Search this Thread
Top Forums Programming SIGSEGV, Segmentation fault
# 1  
Old 12-13-2006
SIGSEGV, Segmentation fault

Here is my initiating code:
Code:
#define NUM 20

static struct tab {
	int count;
	int use;
} tab[NUM];

int curtab = 0;

int tab_create(int tab_count)
{
	curtab++;
	tab[curtab].use = 1;
	tab[curtab].count = tab_count;
        kprintf("here!");
	return curtab;
}

When I run my program main() which calls intval = tab_create(1); I receive this error
Code:
here!Exception 13 at EIP=00000003: General protection violation

I used GDB for debugging and stepped through the process and received this output:
Code:
main () at prodcons.c:39
39          intval = tab_create(1);
(gdb) s

Program received signal SIGSEGV, Segmentation fault.
0x3 in ?? ()


Any ideas why this is a seg-fault?
# 2  
Old 12-13-2006
What is kprintf?
# 3  
Old 12-13-2006
kernel mode printf. I dunno what he's doing either.... but if it's user mode code then kprintf is very likely to be the problem.
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. Solaris

Segmentation fault

Hi Guys, I just installed and booted a zone called testzone. When I logged in remotely and tried changing to root user I get this error: "Segmentation fault" Can someone please help me resolve this? Thanks alot (2 Replies)
Discussion started by: cjashu
2 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 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. Solaris

sigsegv Fault

I receive a sigsegv failure. I was under the impression that a core file is created everytime a sigsegv occurrs and the process is terminated. I have had two recent occurrances of a core file not being created. Does anyone know why a core file would not be created. (2 Replies)
Discussion started by: amp4cats
2 Replies

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

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

8. Programming

Program received signal SIGSEGV, Segmentation fault.

Dear all, I used debugger from C++ and these are the message I got: Program received signal SIGSEGV, Segmentation fault. 0x00323fc0 in free () from /lib/tls/libc.so.6 (gdb) info s #0 0x00323fc0 in free () from /lib/tls/libc.so.6 #1 0x00794fa1 in operator delete () from... (5 Replies)
Discussion started by: napapanbkk
5 Replies

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

10. Programming

Hi! segmentation fault

I have written a program which takes a directory as command line arguments and displays all the dir and files in it. I don't know why I have a problem with the /etc directory.It displays all the directories and files untill it reaches a sub directory called peers which is in /etc/ppp/peers.the... (4 Replies)
Discussion started by: vijlak
4 Replies
Login or Register to Ask a Question