Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.
Announcements
FPGA community forums and blogs on community.intel.com are migrating to the new Altera Community and are read-only. For urgent support needs during this transition, please visit the FPGA Design Resources page or contact an Altera Authorized Distributor.
29285 Discussions

SIGSEGV at end of execution of extremely simple code

gregfi04
Beginner
446 Views
Hi,

I'm getting the following error using a 32-bit compiler suite on CentOS 5 (*AFTER* the code executes successfully):

forrtl: severe (174): SIGSEGV, segmentation fault occurred

The code in question is listed below:

!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

PROGRAM test_code_1
IMPLICIT NONE

CHARACTER(LEN=117) :: cfgstrg
CHARACTER(LEN=150) :: argv0

call getarg(0,argv0)
call ccheck(argv0, 'test_code_1'//char(0), cfgstrg)

write(*,*) "TEST_CODE_1 CONTROL STRING:"
write(*,*) cfgstrg

end program

!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

Clearly, the culprit is this "ccheck" routine, which is about 300 lines of C code.

The weird thing, though, is this exact same code works fine on a 64-bit SUSE machine. I can also make the 32-bit code not segfault by including debugging symbols (-g) at compile time. What does this suggest for my 32-bit platform? An issue with libstdc++? Some other system-level library? Is there any way around this? I'd rather not compile this with debug flags.

Thanks,
Greg
0 Kudos
1 Reply
TimP
Honored Contributor III
446 Views
If it's C code, libstdc++ shouldn't enter in. However, you may not have handled the 3 additional implicit string length arguments on the C side. As you have gone to the trouble of appending a null character to one of the strings, you might consider following through and using standard Fortran throughout (call get_command, iso_c_binding, interface block), so as to avoid non-portable legacy issues like the additional string length arguments.
0 Kudos
Reply