Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.
29270 Discussions

Mixed language Fortran main program ignores SetUnhandledExceptionFilter

Brian_Sung
Beginner
1,217 Views
Hi,

I have a Fortran main application that calls intoa C/C++ library. The very first thing that the Fortran main does is call into the C library to register an exception handler via the Win32 function SetUnhandledExceptionFilter.

Then further into the Fortran program, I deliberately create an access violation in the C library by writing to a NULL pointer to test the exception filter function. However, I am not seeing the exception filter function being invoked. Instead, I am seeing the forrtl error listing. I also tried defining the environment variable FOR_IGNORE_EXCEPTIONS, but I get the JIT debugger popup dialog instead of the exception filter being invoked. Why isn't the exception filter function being invoked? Is there any special build setting I need to enable? My test program source and solution filesare included in the for_runtime_tests.zip file.

I've also have a c_main program that does a similar kind of thing; and the exception filter function is invoked.

Compiler information:
Intel Visual Fortran Compiler for applications running on Intel 64, Version 10.1 Build 20070913 Package ID: w_fc_p_10.1.011, and
Microsoft C/C++ Optimizing Compiler Version 14.00.50727.762 for x64

Thanks,
-brian
0 Kudos
7 Replies
Steven_L_Intel1
Employee
1,217 Views
Brian,

I can reproduce what you're seeing and I agree it does not look correct. I'll have to pass this on to the developers for investigation - when I hear more, I'll let you know. The issue ID is DPD200121369.

I was not familiar with this particular API - the recommended way of catching errors is to wrap the Fortran code in a C++ code that uses a try-except block. Have you considered that?
0 Kudos
Brian_Sung
Beginner
1,217 Views
Brian,

I can reproduce what you're seeing and I agree it does not look correct. I'll have to pass this on to the developers for investigation - when I hear more, I'll let you know. The issue ID is DPD200121369.

I was not familiar with this particular API - the recommended way of catching errors is to wrap the Fortran code in a C++ code that uses a try-except block. Have you considered that?

Yes, I've done some experiments wrapping the Fortran main inside a C/C++ main, similar to what's described in the documentation under:
Error Handling -> Handling Run-Time Errors ->Advanced Exception and Termination Handling
->Handlers for the Application (Project) Type.
and that works.We have a lot of existing Fortran applications.So I want tomake sure there is absolutelynothing I can do strictly on the Fortran side, before suggesting itto the rest of the development team to pursue the alternative of wrappingthe Fortran code inside C/C++.

Thanks,
-brian
0 Kudos
Brian_Sung
Beginner
1,217 Views
Hi Steve,

I am new to this forum. How do I monitor the issue ID? Can you give me an idea when I could expect any feedback from the developers? I am trying to resolve this issue which is important to our customers.

Thanks in advance,
-brian

0 Kudos
Steven_L_Intel1
Employee
1,217 Views
I will get notified when there is an update and will post a reply here. I would not expect a quick resolution to this, given its complexity and use of a Win32 API routine, but I will let the developers know that this is important to you.
0 Kudos
Steven_L_Intel1
Employee
1,217 Views
The cause of this problem has been found and fixed. I do not yet know when the fix will appear.
0 Kudos
Steven_L_Intel1
Employee
1,217 Views
The fix should appear in Update 4, scheduled for mid-December.
0 Kudos
Steven_L_Intel1
Employee
1,217 Views
This issue was resolved in 11.1 Update 4. Defining the environment variable FOR_IGNORE_EXCEPTIONS now has the desired behavior.
0 Kudos
Reply