segmentation fault(programming)

Most of programmer are really bothered with this one. After compiling a bunch of code, suddenly you’ve got this message. If you have a big source code, and your code is unstructured, then let’s die…

Haha, may be there’s some issues that may cause segfault:

  1. In some recursive line, may be there’s some limit of that recursive line which shouldn’t be there. For example in these cut of source code… find it by your self, the clue is there is no Kode(J) = 4 in the assignment of JobList
  2. int main()
    {
        JobList J;
        ...
        /*the list of JobList J on this case actually have only Kode(J) = 1, 2, or 3*/
        jobnr = 4;
        ...
    return 0;
    }
    /*-----------------------------------------------------------------*/
    void CreateJobQueue ( JobList J, ToDoList  *TD, int jobnr, int nrexec)
    /*locale*/
        	int i,jobnr ;
    	addressJ Pt, P ;
    /*algorithm*/
            Pt = First(J) ;
    	if (jobnr != Kode(Pt))
    	{
    		while (jobnr != Kode(Pt) || (Pt != Nil))
    		{
    			Pt = NextJ(Pt) ;
    		}
    	}
    ...
  3. Unstopable looping
  4. You access something it shouldn’t be there. for example : J is an address which point to some type includes address-Next() and  integer-val. Next() is an info on address J which lead to another address. say that you assign address of Next(J) with NULL. If you assign Next(J).val with some integer your program will have a segfault. Why? because the address of Next(J) is nowhere.

Maybe I’ve just known this two. I’ll add into it later, if I found it again, okay…😀

Tinggalkan Balasan

Isikan data di bawah atau klik salah satu ikon untuk log in:

Logo WordPress.com

You are commenting using your WordPress.com account. Logout / Ubah )

Gambar Twitter

You are commenting using your Twitter account. Logout / Ubah )

Foto Facebook

You are commenting using your Facebook account. Logout / Ubah )

Foto Google+

You are commenting using your Google+ account. Logout / Ubah )

Connecting to %s