I am not certain whether this is a Fortran problem, since it occurs when mixing object files from both Fortran and C sources, therefore I apologize in advance if this is the wrong forum to post my question.
Recently I upgraded from version 7.1 to version 8.0 of the Intel Fortran and C/C++ compilers and this broke my applications. I develop a threads library in C and I use icc to compile it. In order to test my library I use version 3.0 of the OpenMP NAS Benchmarks. The benchmarks are preprocessed with a source-to-source compiler and the output is an equivalent Fortran program with calls to my library. The preprocessed benchmarks do not contain anymore the main function of the program, which is defined in the library I develop and which is responsible to call the first routine of the benchmark (new_program_main() in the following example). Therefore I need the -nofor_main option in the link stage. The process to build an application is as follows:
1) Build threads library (as a shared library) with icc (everything compiles fine. Options used are -w1 -g -c -D_REENTRANT)
2) Pass benchmark sources through the source-to-source compiler (everything compiles fine)
3) Pass output of the source-to-source compiler through ifort to create object files (everything compiles fine. Options used are -w1 -g -c -auto -stack-temps -D_REENTRANT)
4) Link object files from Step 3 with library from Step 1 using ifort (everything compiles fine. Options used are -nofor_main)
The executables are produced without any problem, but when I try to execute them they start and almost immediately give me a segmentation fault. Using gdb I found that the problem lies in the function __pthread_internal_tsd_get(). Executing the "where" command under gdb (while running the CG benchmark) gives the following results.
#0 0x4008b96d in __pthread_internal_tsd_get () from /lib/libpthread.so.0
#1 0x40139da4 in malloc () from /lib/libc.so.6
#2 0x080626b7 in for__get_vm ()
#3 0x08056dfe in for__acquire_lun ()
#4 0x08059bc2 in for_open ()
#5 0x0804a301 in new_program_main ()
Executing the application step-by-step under gdb revealed that the problem lies in the following source line of the CG benchmark:
OPEN(unit=2, file='timer.flag', status='old', iostat=fstatus)
This problem occurs only when I use version 8.0 of the Intel compilers. The applications execute without any problems with version 7.1 of the Intel compilers and with gcc.
I also tried other command line options (-O2 for example) and also removed the -D_REENTRANT option from all stages, but the problem remains.
Any ideas about what the problem could be?
Thank you in advance,