2

I have a general question about what causes a Seg Fault? I always knew that it is caused when a code is trying to access a memory zone that doesn't belong to it.

Since few months, I've been facing a huge problem with a commercial code, producing a random Seg Fault: The same code, used to run the same physical model, could produce a Seg Fault, but it's not reproducible!

The editor of the code is convinced that it a problem related to my HPC environment (OS, MPI implementation, gcc version...)! I have checked and cross-checked my environment, with no luck!

Could someone please explain me what is a Seg Fault, and what are causes of it? Could an environment parameter be a cause to such an issue?

Thank you, Ouissem

o_Ouissem
  • 21
  • 1
  • Welcome to StackOverflow ! There are dozens of topics dealing with the subject already. I suggest you read them first, and if you don't find an solution to your issues, ask a question providing a [Minimal, Complete, and Verifiable example](http://stackoverflow.com/help/mcve). – Badda May 04 '17 at 14:05
  • In addition to the existing answer to the question posed, I'll add that nothing in the C or C++ standards defines a way to produce a segfault, nor even acknowledges their existence. Therefore, if ever you see one, it can only be a manifestation of undefined behavior. There are many ways that your program could trigger undefined behavior; we cannot help you attribute blame without reference to actual code. – John Bollinger May 04 '17 at 14:13
  • @JohnBollinger sorry to nitpick, but `void foo(int i) { if (i) foo(i - 1); }` isn't UB as per the standard, or is it? Yet it will segfault in some situations. (Of course your comment is still valid in the context of this question!) – Zulan May 05 '17 at 07:42

0 Answers0