SIGSEGV from Kernel

I am having a linked list of nodes modified(added and deleted) dynamically from a user space program. What are the chances that the allocation of nodes are always in user space?

Usual Linked list node,

struct node {
  int x;
  struct node *next;
};

I got this question since when I traverse through the list, the kernel sends a SIGSEGV signal to this user space process.Also I have done the NULL pointer check whenever I create a new node.

Also I know that the kernel sends SIGSEGV signal if the process tries accessing kernel memory.

Answers


What are the chances that the allocation of nodes are always in user space?

100% certain.

when I traverse through the list, the kernel sends a SIGSEGV signal

It means there is a bug in your program trying to access la-la-land.

Also I know that the kernel sends SIGSEGV signal if the process tries accessing kernel memory.

SIGSEGV is a POSIX standard signal sent when the program tries to access forbidden memory. So not necessarily just kernel memory, but rather any memory anywhere outside the space that your process has access to.


SIGSEGV is a segmentation fault. What this means is that your program is trying to access memory in a region that is not inside of the programs allotted memory range, or segment. Segmentation was an ugly system that people used to have to deal with directly, but not so much anymore. What it means for you today is that your code is most likely deferencing either a null pointer or some un-initialized value.

What you should do is hook your debugger up to your program and see what address is causing the SIGSEGV to be thrown. As soon as you see it, it will most likely be 0x0, or some garbage value such as 0xDEADC0DE or something.

Probably you are not setting all the pointers in your nodes to 0x0. Do this inside the constructor and double check your addNode() removeNode() function to be sure you don't have dangling pointers hanging around.


Do not forget to set next=NULL; in node constructor, or just after node creation. And yes, allocation is always done in user space


Need Your Help

need some help to get data out of quotes and brackets

java regex

I'm working with java URL class to read data from URLs. The problem is, i have got some strings and i wanna get rid off quotes and brackets using regex. Please help me out.

MySQL Join Many to Many as single rows

sql mysql join pivot

I know there's got to be a way to do this, but for the life of me I can't figure it out:

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.