Runtime Error

Please explain Why i get SIGSEGV error and give some tips to remove SIGSEGV error from the code.

SIGSEGV means segmentation fault… you’re trying to access a block of memory which you’re not supposed to…
Check in your code
1.Memory allocations done properly
2.Array Boundaries
3.Using uninitialized pointers
4.Freeing a memory twice
5.Running out of space

I think this should solve your problems… Good Luck!!

1 Like

SIGSEGV is a a fault raised by hardware with memory protection notifying the operating system an acces violation

The following are some typical causes of a segmentation fault:

  • Dereferencing NULL pointers – this is
    special-cased by memory management

  • Attempting to access a nonexistent
    memory address (outside process’s
    address space)

  • Attempting to access memory the
    program does not have rights to (such
    as kernel structures in process

  • Attempting to write read-only memory
    (such as code segment)

These in turn are often caused by programming errors that result in invalid memory access:

  • Dereferencing or assigning to an
    uninitialized pointer (wild pointer,
    which points to a random memory

  • Dereferencing or assigning to a freed
    pointer (dangling pointer, which
    points to memory that has been

  • A buffer overflow or A stack

  • Attempting to execute a program that
    does not compile correctly. (Some
    compilers will output an executable
    file despite the presence of
    compile-time errors.)

1 Like

This is an error caused by an invalid memory reference or segmentation fault. The most common causes are accessing an array element out of bounds, or using too much memory.
Some things for you to try:
Make sure you aren’t using variables that haven’t been initialised. These may be set to 0 on your computer, but aren’t guaranteed to be on the judge.
Check every single occurrence of accessing an array element and see if it could possibly be out of bounds.
Make sure you aren’t declaring too much memory. 64 MB is guaranteed, but having an array of size [10000][10000] will never work.
Make sure you aren’t declaring too much stack memory. Any large arrays should be declared globally, outside of any functions - putting an array of 100000 ints inside a function probably won’t work.

@saajan can you guide me how to make [10^5][10^5] array in C such that SIGSEGV error not occur. or ant link for theory help related to this big array