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

Fortran sanitizer?

david47
Novice
1,709 Views

Hi Everyone!

 

First of all, thank you to Devorah_H_Intel and jumdempseyatthecove for your help in resolving my problem with VS 2022 17.9.6 and Fortran 2022.  I have downloaded and installed Fortran the new Fortran 2024.1 and everything is working as expected!

Now, I have a memory leak problem in my code and wanted to use the sanitizer to help find it.  I could not find any information on how to do this in the VS GUI?  I tried adding an addition compiler command, /fsanitize=address but got lots of link error (LNK2001) about missing __asan_....  I am using the ifx compiler.

 

Could someone please help me to compile and lnk my Fortran code using the sanitizer?

 

Thank you so much in advance.  Any help would be greatly appreciated!

 

Sincerely,

 

David

0 Kudos
6 Replies
LarsJ
Novice
1,212 Views

Hi David

Did you get this to work?

I am having the same issue.

Created a "Hello World" console application from Microsoft Visual Studio, added the switch /fsanitize=address from the IDE (properties->Fortran->General).

When compiling I see LNK2019 unresolved external symbol __asan_*.

I am running Microsoft Visual Studio Professional 2022 (17.10.2) and Intel 2025.2.

Lars

0 Kudos
david47
Novice
751 Views

Hi Lars!

 

So sorry for not getting back to you earlier.  I am using the same setup as you (VS 2022 and Intel Fortran 2025.2 with IFX compiler) and did not really get it to work properly.  From what I remember, I had to add the ASAN libraries in the project and set fsanitize= address as you have done.  I did get my project to compile, link, and run but the results were not what I expected.  I have since removed all additional libraries, etc ... from my project so I am sorry but cannot be of help.   Reading the Intel website, it does say that ASAN is supported using Fortran 2025.2 and under Project/General there is a box for "Enable Address Sanitizer"

 

If you should get it to run, could you please post how you did it?

 

Thanks Lars!

 

Best of luck

 

David

0 Kudos
LarsJ
Novice
718 Views

Hi David

Thanks for your reply.


I finally got it to link correctly (with the help of chatGPT).

Here are the steps I needed to do:

In the properties dialog:
1) Include "$(VCToolsInstallDir)lib\x64" in Linker->General->Additional Library Directories
2) Include "clang_rt.asan_dbg_dynamic-x86_64.lib clang_rt.asan_dynamic_runtime_thunk-x86_64.lib" in Linker -> Input -> Additional Dependencies

The libraries are located here (in my installation): C:\Program Files\Microsoft Visual Studio\2022\Professional\VC\Tools\MSVC\14.44.35207\lib\x64\

I used this small code to check:

program Console2

    implicit none
    integer, allocatable :: a(:)
    allocate(a(4))
    a = 0
    deallocate(a)
    ! Use-after-free:
    print *, 'Value:', a(1)

end program Console2 


and got this output:

LarsJ_0-1758550498208.png

Hope this helps.

 



0 Kudos
david47
Novice
636 Views

Hi Lars!

 

Congratulations!  Thank you so much for sending me the info

 

I tried using the Google AI to show me how to call the CGAL library from Fortran and it unfortunately did not work   So glad to hear the AI helped you out!!

 

Take good care Lars.

 

David 

0 Kudos
Mark_Lewy
Valued Contributor I
777 Views

I don't believe the Windows IFX compiler supports the memory sanitizer yet.  You could try installing the Linux compiler on WSL and use that instead with "-check all".

0 Kudos
LarsJ
Novice
708 Views

Hi Mark

Thanks for your reply.

I think, from what I just posted above above, that it works under Windows although from what I can read it has more functions when running under Linux - anybody know if this is true?

We have tried to install the compiler under WSL (running Ubuntu 22), but are experiencing some issues when  using Meson for building the application (the dependency scan is not working or so it seems). So right now we are using the IFORT for Linux - with no options for the sanitizer.

0 Kudos
Reply