error solved

Solved – program received signal sigsegv: segmentation fault


In this article, you will learn how to solve program received signal sigsegv: segmentation fault – invalid memory reference.

Let’s look at a code example that produces the same error.

CnewV = CnewV + alpha2 * r

Segmentation error happens because of memory conflicts. and in our case error is due to wrong allocation of variables. Consider the code snippet below to correctly allocate the variables.

CnewV(0:IG,0:JG) = CnewV(0:IG,0:JG) + alpha2 * r(0:IG,0:JG)

If an array index is being outside the declared range It can also cause segmentation fault error.

There are few other reasons which can produce the above error:

  1. Your integers with INTEGER*8 might be too long, maybe INTEGER*4 or simply INTEGER would be better
  2. You call SGESV on double arguments instead of DGESV
  3. Your LDA argument is missing, so your code should perhaps look like CALL DGESV(N,N,DMA2,N,pivot,FU,N,inf) but you need to check whether this is what you want.

To solve this issue  you should use iostat=<some integer var> to check for the return value of the open operation.


Share on social media

//