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

Using a Tree Structure

everythingfunctional
3,217 Views

I use polymorphic tree structures a lot in my libraries, and am having trouble getting them to work with the Intel compiler. I've got this (relatively) simple example application that can be found here:

https://gitlab.com/everythingfunctional/binary_tree

It is just a binary tree of integers that can then format itself in a "pretty" way, but it's implemented using polymorphism. When I compile and run the application with gfortran it works fine, i.e.

 

$ fpm run
Project is up to date
    ------------
    |          |
  -------  -------
  |     |  |     |
 ----- 567 89  -----
 |   |         |   |
---  4        1234 56
| |
1 23

 

 but trying to use the intel compiler it crashes with:

 

$ fpm run --compiler ifx
Project is up to date
==98196==WARNING: MemorySanitizer: use-of-uninitialized-value
    #0 0x496428 in node_m_MP_to_string_ /home/brad/Repositories/GitLab/everythingfunctional/binary_tree/././src/node_m.f90:43:9
    #1 0x4968e9 in node_m_MP_to_string_ /home/brad/Repositories/GitLab/everythingfunctional/binary_tree/././src/node_m.f90:43:9
    #2 0x4928aa in MAIN__ /home/brad/Repositories/GitLab/everythingfunctional/binary_tree/app/main.f90:24:19
    #3 0x40adb8 in main (/home/brad/Repositories/GitLab/everythingfunctional/binary_tree/build/ifx_22B6DB2C5432A52F/app/binary_tree+0x40adb8) (BuildId: 23be80717f69625b736f03c05320b9eccd6c428c)
    #4 0x7f67c5185ccf  (/usr/lib/libc.so.6+0x27ccf) (BuildId: 023ea16fd6c04ef9cf094507024e6ecdb35e02ca)
    #5 0x7f67c5185d89 in __libc_start_main (/usr/lib/libc.so.6+0x27d89) (BuildId: 023ea16fd6c04ef9cf094507024e6ecdb35e02ca)
    #6 0x40ac84 in _start (/home/brad/Repositories/GitLab/everythingfunctional/binary_tree/build/ifx_22B6DB2C5432A52F/app/binary_tree+0x40ac84) (BuildId: 23be80717f69625b736f03c05320b9eccd6c428c)

  Uninitialized value was created by a heap allocation
    #0 0x417576 in __interceptor_malloc /netbatch/donb00013_00/dir/workspace/NIT/xmain-rel/LX/xmainefi2linux_release/ws/icsws/llvm/compiler-rt/lib/msan/msan_interceptors.cpp:933:3
    #1 0x676274 in _mm_malloc (/home/brad/Repositories/GitLab/everythingfunctional/binary_tree/build/ifx_22B6DB2C5432A52F/app/binary_tree+0x676274) (BuildId: 23be80717f69625b736f03c05320b9eccd6c428c)
    #2 0x609dff in do_alloc_copy for_alloc_copy.c
    #3 0x60aa04 in do_alloc_copy for_alloc_copy.c
    #4 0x60b5d6 in do_alloc_assign for_alloc_copy.c
    #5 0x60b67e in for_alloc_assign_v2 (/home/brad/Repositories/GitLab/everythingfunctional/binary_tree/build/ifx_22B6DB2C5432A52F/app/binary_tree+0x60b67e) (BuildId: 23be80717f69625b736f03c05320b9eccd6c428c)
    #6 0x490e0a in MAIN__ /home/brad/Repositories/GitLab/everythingfunctional/binary_tree/app/main.f90:10:5
    #7 0x40adb8 in main (/home/brad/Repositories/GitLab/everythingfunctional/binary_tree/build/ifx_22B6DB2C5432A52F/app/binary_tree+0x40adb8) (BuildId: 23be80717f69625b736f03c05320b9eccd6c428c)
    #8 0x7f67c5185ccf  (/usr/lib/libc.so.6+0x27ccf) (BuildId: 023ea16fd6c04ef9cf094507024e6ecdb35e02ca)

SUMMARY: MemorySanitizer: use-of-uninitialized-value /home/brad/Repositories/GitLab/everythingfunctional/binary_tree/././src/node_m.f90:43:9 in node_m_MP_to_string_
Exiting
<ERROR> Execution for object " binary_tree " returned exit code  1
<ERROR> *cmd_run*:stopping due to failed executions
STOP 1

 

Any help would be greatly appreciated as this is basically a show stopper for pretty much all my projects to work with the Intel compiler.

Labels (2)
0 Kudos
26 Replies
everythingfunctional
611 Views

You're still missing one of the dependencies, exceptional_numbers, used by strff. https://gitlab.com/everythingfunctional/exceptional_numbers.git

0 Kudos
JohnNichols
Valued Contributor III
601 Views

iso_varying_string.f90(2522): warning #5462: Global name too long, shortened from:

ISO_VARYING_STRINGREPLACE_TARGET_CHARACTER_WITH_CHARACTER_IN_CHARACTER_mp_GET_NUM_TARGETS to:

 G_STRINGREPLACE_TARGET_CHARACTER_WITH_CHARACTER_IN_CHARACTER_mp_GET_NUM_TARGETS

 

Screenshot 2023-10-04 124807.png

Seems to run ok?

0 Kudos
JohnNichols
Valued Contributor III
601 Views

It would be easier in Scheme or AutoLISP

0 Kudos
everythingfunctional
584 Views

Yeah, but then where's the challenge?

0 Kudos
everythingfunctional
584 Views

Have you tried turning on the address sanitizer (I.e. `-check uninit`)? And are you using the latest version (2023.2.0)? That was the general source of the error.

0 Kudos
JohnNichols
Valued Contributor III
568 Views

Windows Preview 11 - Canary Build

VS 2022 Latest Preview

Intel Fortran latest download from OneAPI

I like to ride the edge that bleeds.  Steve shakes his head when I am mentioned. 

It can occasionally be painful, but not as painful as 20 minutes with Linux. 

0 Kudos
Reply