- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I have an application which has a C++ main() and which links in a Fortran library. We try to make sure that if a Fortran run-time library error occurs, the program has some way to report it. In the program below, the Fortran code delibrately causes a run-time error, but instead of printing the error and the traceback, something in the Fortran run-time library simply aborts. Here is the C++ main program (main.cpp):
[cpp]
extern "C" gen_error ( void );
int main( )
{
gen_error();
}
[/cpp]
and here is the Fortran part (gen_error.f90)
[fortran]
subroutine gen_error ( ) bind(c)
real, allocatable :: a(:)
allocate a(10)
allocate a(10) ! Can't allocate an allocated array
end subroutine gen_error
[/fortran]
When I build this:
[plain]
$ icc -c main.cpp
$ ifort -o main main.o -fexceptions gen_error.f90 -cxxlib
$ ./main
Segmentation fault
[/plain]
Running it under valgrind shows (in part):
[plain]
==8722== Jump to the invalid address stated on the next line
==8722== at 0x0: ???
==8722== by 0x404FAD: for__issue_diagnostic (in /scratch/shared/src/main)
==8722== by 0x403269: for_alloc_allocatable (in /scratch/shared/src/main)
==8722== by 0x402C55: wha (in /scratch/shared/src/main)
==8722== by 0x402B5C: main (in /scratch/shared/src/main)
==8722== Address 0x0 is not stack'd, malloc'd or (recently) free'd
==8722==
==8722==
==8722== Process terminating with default action of signal 11 (SIGSEGV)
==8722== Bad permissions for mapped region at address 0x0
==8722== at 0x0: ???
==8722== by 0x404FAD: for__issue_diagnostic (in /scratch/shared/src/main)
==8722== by 0x403269: for_alloc_allocatable (in /scratch/shared/src/main)
==8722== by 0x402C55: wha (in /scratch/shared/src/main)
==8722== by 0x402B5C: main (in /scratch/shared/src/main)
[/plain]
It kind of looks like the run-time has not warmed up enough to emit the error message. Is there a Fortran run-time initialization routine we should be calling before entering the Fortran the first time from the C++ side?
This is with icc/ifort 12.1.2 20111128 on a CentOS 5.6 system with GCC 4.3.2.
Thanks,
Allen
Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
We found that the "stack unwind" code we were calling, part of a C library, "knew" that the main program was C++ and effectively disabled the Fortran traceback code. We have found a workaround for this for a future release.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
This should be resolved in the 14.0 compiler.

- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page