Quantcast
Channel: Recent posts
Viewing all articles
Browse latest Browse all 415

Segment Fault Error when Linking to Dynamic Library in Linux

$
0
0

Hello!

I am attempting to interface an old Fortan77 code to a newer code base written in Fortran90 by linking as a dynamic library.  I have been able to succefully compile and link using Fortran 10.6.3 in OSX (Yosemite 10.10.5), and the code runs without error.  Also, one of my associates has been able to compile, link, and run without errors in Windows7 using a DLL. However, in Linux (Elementary OS-64bit, Ubuntu variant) using Fortan 17.0.1, I encouter a segmentation fault error when the linked code is executed.

forrtl: severe (174): SIGSEGV, segmentation fault occurred
Image              PC                Routine            Line        Source
mcan.lin  00000000005B2421  Unknown               Unknown  Unknown
mcan.lin  00000000005B055B  Unknown               Unknown  Unknown
mcan.lin  000000000055A0B4  Unknown               Unknown  Unknown
mcan.lin  0000000000559EC6  Unknown               Unknown  Unknown
mcan.lin  00000000004F0DB9  Unknown               Unknown  Unknown
mcan.lin  00000000004F80B6  Unknown               Unknown  Unknown
libpthread-2.15.s  00002ABC3FB40CB0  Unknown               Unknown  Unknown
libscram_api.s  00002ABC35F39C9F  ggeni_                    241  ggeni.for

Here are the commands used to generate the Linux f77 library:

ifort -O0 -fltconsistency -save -c -fpic -I$include -debug all -traceback -check all -CB -g *.for
ld -nofor_main -shared -fpic --no-omagic -o libscram_api.so *.o

and to link to the f90 code:

ifort *.o -L. -lscram_api -o mcan

A couple other items to note are:

- The old f77 code has a single f90 file for wrapper to expose the interface. So, it is technically mixed f77/f90.

- The old f77 code has multiple common block and local variables that do not have explicity typing.  Could this be the issue? I have tried explicitly typing the lines near the segment fault but the issue persists.  Also, explicity typing all the variables in the entire code is a not a realistic solution - it would literally take months of work given the size of the code base.

- The code segment faults in the same location when I attempted to link in OSX via a static library or fully compile the f77 code with the f90 code.

So my question is this: why does the code segment fault in Linux and not in OSX or Windows? Is there a flag that I am missing that would resolve the issue?

Best regards,
Andy


Viewing all articles
Browse latest Browse all 415

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>