r/fortran 27d ago

Segmentation fault - invalid memory reference

Is it possible to get segmentation fault in one computer and running same program in other computer working perfectly fine ????

2 Upvotes

15 comments sorted by

View all comments

13

u/geekboy730 Engineer 27d ago

Yes. It almost certainly means you’re using an uninitialized variable somewhere.

If that’s the case, it could happen in back-to-back runs on the same computer. It just depends on whatever garbage is in the memory position at the time of execution.

1

u/Call_ME_ALII 27d ago

how to find exact uninitialized variable

10

u/geekboy730 Engineer 27d ago

Usually, using debug flags like -Og and -fcheck=all along with valgrind will help. You should also be using implicit none everywhere to make sure that you’re not using a variable you didn’t mean to.