0

I'm using ubuntu 14.04 64bit LTS and I'm writing image processing program in C. When I'm runing any programe in terminal it shows segmentation fault (core dumped).
The same program run nicely in 10.04.

Any help please?

$ cc -o out.e sub.c -lm
$ ./out.e
Segmentation fault (core dumped)
6
  • stackoverflow.com/questions/19641597/… check this link , that will help you..if problem is not solved then please post your script..
    – hunch
    Oct 14, 2014 at 6:52
  • The compiler versions changed. Whatever you did in the code was probably non-standard, and probably the compiler now implements it in a way that causes it to segfault. I have seen code which compiles and runs in GCC 4.6 and not in 4.8, and run with no optimization but fail with -O3. Write standards-compliant code.
    – muru
    Oct 14, 2014 at 8:35
  • i checked with codeblockers...no errors found in the programe..
    – user312911
    Oct 14, 2014 at 8:45
  • what is standards-compliant code??
    – user312911
    Oct 14, 2014 at 8:46
  • i really need help regarding this plzz
    – user312911
    Oct 14, 2014 at 8:56

1 Answer 1

1

What actually happened in detail is hard to tell, but I'll give an example of the kind of problem.

What is important is that the program worked on 10.04, but fails on 14.0. The exact problem could be different, but similar and related:

Something is against the rules

The error "segmentation fault" usually means some memory was accessed that does not belong to the program. It can be that on both 10.04 and 14.04, there was such an illegal access to memory, but it did not cause any problem on 10.04.

Rules are not strictly enforced

That would mean it worked just by chance in 10.04; That is quite possible, because for many reasons, memory nearby the "official" memory of your program may also belong to your program technically.
That is to make thinks easier for the compiler, or make the program faster by more regular memory access.
By this, the program may be allowed to do things that it is not allowed to do based on the program text.

Tolerance can change

Which "inofficial" memory you can access without a segmentation fault depends on the compiler version, and library versions, which both have changed.

The simplest, and most common case should be that there is a bug in the program where a memory access went to far, like accessing the byte after an array by an of-by-one error in the index.

Summary

The bug existed before, but it worked anyway.
Now, it does not work, and it's just a normal bug that causes a segmentation fault.

For a positive aspect: when it worked, with the bug, it may have created wrong results - which is much worse than the crash you see now.


Enforce the rules

A good approach to debug this kind of problem is to instrument the program to enforce the rules that are not enforced by the normal runtime system.
One tool to do this when looking for problem with memory access is valgrind (man valgrind).

7
  • is there any solution?
    – user312911
    Oct 14, 2014 at 9:10
  • Yes: to find and fix the bug! Oct 14, 2014 at 9:11
  • Assuming it's really about memory access, there are tools that help to find this kind of problem, like valgrind Oct 14, 2014 at 9:13
  • same programe run in 10.04....what to do with 14.04???
    – user312911
    Oct 14, 2014 at 9:17
  • I already answered that above, as far as I can tell - what's the remaining question? Oct 14, 2014 at 9:18

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .