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

Bug in Temporary Object Cleanup

everythingfunctional
New Contributor I
1,098 Views

I've been trying my best to narrow this down, but I'm at a point that trying to remove what I believe to be unrelated features in the code keeps changing where the crash happens. I'll try my best to explain what I've done and hope it's sufficient.

I believe the error lies somewhere in the cleanup of temporary/intermediate objects. Specifically it seems likely to be related to objects with procedure pointer components, but I have so far been unable to reproduce it in small examples where that is the only feature.

I encountered the bug after successfully working around other compiler bugs in the veggies test framework such that it could finally be compiled by ifort/ifx. The code at this stage can be found at https://gitlab.com/everythingfunctional/veggies/-/tree/workaround-intel-bugs?ref_type=heads

Compiling and attempting to execute the test suite crashes before the tests have been constructed.

$ fpm test --compiler ifx --flag "-g -O0 -traceback"
Project is up to date
forrtl: severe (174): SIGSEGV, segmentation fault occurred
Image              PC                Routine            Line        Source             
libc.so.6          00007FF1A1B6F710  Unknown               Unknown  Unknown
veggies-test       000000000077CAE2  Unknown               Unknown  Unknown
veggies-test       0000000000786C53  Unknown               Unknown  Unknown
veggies-test       0000000000786ED1  Unknown               Unknown  Unknown
veggies-test       0000000000786ED1  Unknown               Unknown  Unknown
veggies-test       000000000065A4D9  describe_with_tra         204  test_constructors_m.f90
veggies-test       0000000000671D02  when_with_transfo         775  test_constructors_m.f90
veggies-test       00000000005FC819  test_failing_case          33  failing_case_test.f90
veggies-test       000000000040AEF8  run                       132  main.f90
veggies-test       0000000000405C7C  main                        5  main.f90
veggies-test       0000000000405C4D  Unknown               Unknown  Unknown
libc.so.6          00007FF1A1B58CD0  Unknown               Unknown  Unknown
libc.so.6          00007FF1A1B58D8A  __libc_start_main     Unknown  Unknown
veggies-test       0000000000405B65  Unknown               Unknown  Unknown
<ERROR> Execution for object " veggies-test " returned exit code  174
<ERROR> *cmd_run*:stopping due to failed executions
STOP 174

I tried a few small example codes to try and reproduce the bug, but was unsuccessful, so I started down the path of removing all the code from the test suite and framework that was unnecessary to encounter the bug. I got to the point of being ready to remove external dependencies, but then doing so moved where the crash occurred! The simplified code with external dependencies can be found at https://gitlab.com/everythingfunctional/veggies/-/tree/last-consistent-place, and then with the external dependencies removed at https://gitlab.com/everythingfunctional/veggies/-/tree/narrow-down-ifx-bug?ref_type=heads

You can see below how the point of the crash moves.

$ git checkout last-consistent-place
$ fpm test --compiler ifx --flag "-g -O0 -traceback"
Project is up to date
forrtl: severe (174): SIGSEGV, segmentation fault occurred
Image              PC                Routine            Line        Source             
libc.so.6          00007FE2B965C710  Unknown               Unknown  Unknown
veggies-test       00000000004358B3  Unknown               Unknown  Unknown
veggies-test       000000000043E2A3  Unknown               Unknown  Unknown
veggies-test       000000000043E521  Unknown               Unknown  Unknown
veggies-test       000000000043E521  Unknown               Unknown  Unknown
veggies-test       000000000040A509  describe_with_tra         110  test_constructors_m.f90
veggies-test       0000000000412352  when_with_transfo         287  test_constructors_m.f90
veggies-test       0000000000405623  test_example               23  main.f90
veggies-test       0000000000406F03  run                        78  main.f90
veggies-test       0000000000406A6C  main                       63  main.f90
veggies-test       00000000004051CD  Unknown               Unknown  Unknown
libc.so.6          00007FE2B9645CD0  Unknown               Unknown  Unknown
libc.so.6          00007FE2B9645D8A  __libc_start_main     Unknown  Unknown
veggies-test       00000000004050E5  Unknown               Unknown  Unknown
<ERROR> Execution for object " veggies-test " returned exit code  174
<ERROR> *cmd_run*:stopping due to failed executions
STOP 174
$ git checkout narrow-down-ifx-bug
$ fpm test --compiler ifx --flag "-g -O0 -traceback"
Project is up to date
forrtl: severe (174): SIGSEGV, segmentation fault occurred
Image              PC                Routine            Line        Source             
libc.so.6          00007F5B1496F710  Unknown               Unknown  Unknown
veggies-test       000000000041C14D  Unknown               Unknown  Unknown
veggies-test       000000000041C301  Unknown               Unknown  Unknown
veggies-test       000000000041C301  Unknown               Unknown  Unknown
veggies-test       000000000041C301  Unknown               Unknown  Unknown
veggies-test       000000000041C301  Unknown               Unknown  Unknown
veggies-test       000000000040844F  describe_with_inp          48  test_constructors_m.f90
veggies-test       0000000000409319  given_with_input           71  test_constructors_m.f90
veggies-test       0000000000405935  test_example               23  main.f90
veggies-test       0000000000406ED3  run                        76  main.f90
veggies-test       0000000000406A3C  main                       61  main.f90
veggies-test       00000000004051CD  Unknown               Unknown  Unknown
libc.so.6          00007F5B14958CD0  Unknown               Unknown  Unknown
libc.so.6          00007F5B14958D8A  __libc_start_main     Unknown  Unknown
veggies-test       00000000004050E5  Unknown               Unknown  Unknown
<ERROR> Execution for object " veggies-test " returned exit code  174
<ERROR> *cmd_run*:stopping due to failed executions
STOP 174

What's then even crazier is that if I turn on the address sanitizer the crash moves again!

$ fpm test --compiler ifx --flag "-g -O0 -traceback -check uninit"
Project is up to date
 Running Tests
Uninitialized bytes in __interceptor_write at offset 0 inside [0x725000000000, 15)
==137575==WARNING: MemorySanitizer: use-of-uninitialized-value
    #0 0x4ee597 in for__write_output (/home/brad/Repositories/GitLab/everythingfunctional/veggies/build/ifx_2748D8EF2E1F6BCC/test/veggies-test+0x4ee597) (BuildId: 34f17cfa45fd14925c8b5f879f12a28413bc628b)
    #1 0x4ef30e in for__put_sf (/home/brad/Repositories/GitLab/everythingfunctional/veggies/build/ifx_2748D8EF2E1F6BCC/test/veggies-test+0x4ef30e) (BuildId: 34f17cfa45fd14925c8b5f879f12a28413bc628b)
    #2 0x4fbad1 in for_write_seq_lis_xmit (/home/brad/Repositories/GitLab/everythingfunctional/veggies/build/ifx_2748D8EF2E1F6BCC/test/veggies-test+0x4fbad1) (BuildId: 34f17cfa45fd14925c8b5f879f12a28413bc628b)
    #3 0x4f7cf2 in for_write_seq_lis (/home/brad/Repositories/GitLab/everythingfunctional/veggies/build/ifx_2748D8EF2E1F6BCC/test/veggies-test+0x4f7cf2) (BuildId: 34f17cfa45fd14925c8b5f879f12a28413bc628b)
    #4 0x4ad11e in veggies_run_tests_m_mp_run_tests_ /home/brad/Repositories/GitLab/everythingfunctional/veggies/././src/veggies/run_tests_m.f90:15:9
    #5 0x495d1f in main_IP_run_ /home/brad/Repositories/GitLab/everythingfunctional/veggies/test/main.f90:80:18
    #6 0x493648 in MAIN__ /home/brad/Repositories/GitLab/everythingfunctional/veggies/test/main.f90:61:14
    #7 0x40a578 in main (/home/brad/Repositories/GitLab/everythingfunctional/veggies/build/ifx_2748D8EF2E1F6BCC/test/veggies-test+0x40a578) (BuildId: 34f17cfa45fd14925c8b5f879f12a28413bc628b)
    #8 0x7fee3ceb2ccf  (/usr/lib/libc.so.6+0x27ccf) (BuildId: 8bfe03f6bf9b6a6e2591babd0bbc266837d8f658)
    #9 0x7fee3ceb2d89 in __libc_start_main (/usr/lib/libc.so.6+0x27d89) (BuildId: 8bfe03f6bf9b6a6e2591babd0bbc266837d8f658)
    #10 0x40a444 in _start (/home/brad/Repositories/GitLab/everythingfunctional/veggies/build/ifx_2748D8EF2E1F6BCC/test/veggies-test+0x40a444) (BuildId: 34f17cfa45fd14925c8b5f879f12a28413bc628b)

  Uninitialized value was created by a heap allocation
    #0 0x416d36 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 0x4f1b62 in for__get_vm (/home/brad/Repositories/GitLab/everythingfunctional/veggies/build/ifx_2748D8EF2E1F6BCC/test/veggies-test+0x4f1b62) (BuildId: 34f17cfa45fd14925c8b5f879f12a28413bc628b)
    #2 0x503e89 in for__open_proc (/home/brad/Repositories/GitLab/everythingfunctional/veggies/build/ifx_2748D8EF2E1F6BCC/test/veggies-test+0x503e89) (BuildId: 34f17cfa45fd14925c8b5f879f12a28413bc628b)
    #3 0x4ec78a in for__open_default (/home/brad/Repositories/GitLab/everythingfunctional/veggies/build/ifx_2748D8EF2E1F6BCC/test/veggies-test+0x4ec78a) (BuildId: 34f17cfa45fd14925c8b5f879f12a28413bc628b)
    #4 0x4f77a3 in for_write_seq_lis (/home/brad/Repositories/GitLab/everythingfunctional/veggies/build/ifx_2748D8EF2E1F6BCC/test/veggies-test+0x4f77a3) (BuildId: 34f17cfa45fd14925c8b5f879f12a28413bc628b)
    #5 0x4ad11e in veggies_run_tests_m_mp_run_tests_ /home/brad/Repositories/GitLab/everythingfunctional/veggies/././src/veggies/run_tests_m.f90:15:9
    #6 0x495d1f in main_IP_run_ /home/brad/Repositories/GitLab/everythingfunctional/veggies/test/main.f90:80:18
    #7 0x493648 in MAIN__ /home/brad/Repositories/GitLab/everythingfunctional/veggies/test/main.f90:61:14
    #8 0x40a578 in main (/home/brad/Repositories/GitLab/everythingfunctional/veggies/build/ifx_2748D8EF2E1F6BCC/test/veggies-test+0x40a578) (BuildId: 34f17cfa45fd14925c8b5f879f12a28413bc628b)
    #9 0x7fee3ceb2ccf  (/usr/lib/libc.so.6+0x27ccf) (BuildId: 8bfe03f6bf9b6a6e2591babd0bbc266837d8f658)

SUMMARY: MemorySanitizer: use-of-uninitialized-value (/home/brad/Repositories/GitLab/everythingfunctional/veggies/build/ifx_2748D8EF2E1F6BCC/test/veggies-test+0x4ee597) (BuildId: 34f17cfa45fd14925c8b5f879f12a28413bc628b) in for__write_output
Exiting
<ERROR> Execution for object " veggies-test " returned exit code  1
<ERROR> *cmd_run*:stopping due to failed executions
STOP 1

 I went ahead and kept simplifying anyway, and attached is the simplest I can make it and still get a crash. Note that it does still manage to get past the crash if you turn on the address sanitizer.

$ ifx -g -traceback example.f90
$ ./a.out
forrtl: severe (174): SIGSEGV, segmentation fault occurred
Image              PC                Routine            Line        Source             
libc.so.6          00007F2826A5C710  Unknown               Unknown  Unknown
a.out              000000000041849D  Unknown               Unknown  Unknown
a.out              0000000000418651  Unknown               Unknown  Unknown
a.out              0000000000418651  Unknown               Unknown  Unknown
a.out              0000000000418651  Unknown               Unknown  Unknown
a.out              0000000000418651  Unknown               Unknown  Unknown
a.out              0000000000418651  Unknown               Unknown  Unknown
a.out              0000000000418651  Unknown               Unknown  Unknown
a.out              0000000000418651  Unknown               Unknown  Unknown
a.out              000000000040F6D5  run                       751  example.f90
a.out              000000000040EB5C  main                      737  example.f90
a.out              00000000004051CD  Unknown               Unknown  Unknown
libc.so.6          00007F2826A45CD0  Unknown               Unknown  Unknown
libc.so.6          00007F2826A45D8A  __libc_start_main     Unknown  Unknown
a.out              00000000004050E5  Unknown               Unknown  Unknown
$ ifx -g -traceback -check uninit example.f90
$ ./a.out
 Running Tests
Uninitialized bytes in __interceptor_write at offset 0 inside [0x725000000000, 15)
==138506==WARNING: MemorySanitizer: use-of-uninitialized-value
    #0 0x4dbf67 in for__write_output (/home/brad/Repositories/GitLab/everythingfunctional/veggies/tmp/a.out+0x4dbf67) (BuildId: d40d79c0bb0f65cdf9699cd731f6132bed9f3a81)
    #1 0x4dccde in for__put_sf (/home/brad/Repositories/GitLab/everythingfunctional/veggies/tmp/a.out+0x4dccde) (BuildId: d40d79c0bb0f65cdf9699cd731f6132bed9f3a81)
    #2 0x4e94a1 in for_write_seq_lis_xmit (/home/brad/Repositories/GitLab/everythingfunctional/veggies/tmp/a.out+0x4e94a1) (BuildId: d40d79c0bb0f65cdf9699cd731f6132bed9f3a81)
    #3 0x4e56c2 in for_write_seq_lis (/home/brad/Repositories/GitLab/everythingfunctional/veggies/tmp/a.out+0x4e56c2) (BuildId: d40d79c0bb0f65cdf9699cd731f6132bed9f3a81)
    #4 0x4b60ce in veggies_run_tests_m_mp_run_tests_ /home/brad/Repositories/GitLab/everythingfunctional/veggies/tmp/example.f90:667:9
    #5 0x4c785a in main_IP_run_ /home/brad/Repositories/GitLab/everythingfunctional/veggies/tmp/example.f90:753:18
    #6 0x4c4158 in MAIN__ /home/brad/Repositories/GitLab/everythingfunctional/veggies/tmp/example.f90:737:14
    #7 0x40a578 in main (/home/brad/Repositories/GitLab/everythingfunctional/veggies/tmp/a.out+0x40a578) (BuildId: d40d79c0bb0f65cdf9699cd731f6132bed9f3a81)
    #8 0x7f43b4b90ccf  (/usr/lib/libc.so.6+0x27ccf) (BuildId: 8bfe03f6bf9b6a6e2591babd0bbc266837d8f658)
    #9 0x7f43b4b90d89 in __libc_start_main (/usr/lib/libc.so.6+0x27d89) (BuildId: 8bfe03f6bf9b6a6e2591babd0bbc266837d8f658)
    #10 0x40a444 in _start (/home/brad/Repositories/GitLab/everythingfunctional/veggies/tmp/a.out+0x40a444) (BuildId: d40d79c0bb0f65cdf9699cd731f6132bed9f3a81)

  Uninitialized value was created by a heap allocation
    #0 0x416d36 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 0x4df532 in for__get_vm (/home/brad/Repositories/GitLab/everythingfunctional/veggies/tmp/a.out+0x4df532) (BuildId: d40d79c0bb0f65cdf9699cd731f6132bed9f3a81)
    #2 0x4f1859 in for__open_proc (/home/brad/Repositories/GitLab/everythingfunctional/veggies/tmp/a.out+0x4f1859) (BuildId: d40d79c0bb0f65cdf9699cd731f6132bed9f3a81)
    #3 0x4da15a in for__open_default (/home/brad/Repositories/GitLab/everythingfunctional/veggies/tmp/a.out+0x4da15a) (BuildId: d40d79c0bb0f65cdf9699cd731f6132bed9f3a81)
    #4 0x4e5173 in for_write_seq_lis (/home/brad/Repositories/GitLab/everythingfunctional/veggies/tmp/a.out+0x4e5173) (BuildId: d40d79c0bb0f65cdf9699cd731f6132bed9f3a81)
    #5 0x4b60ce in veggies_run_tests_m_mp_run_tests_ /home/brad/Repositories/GitLab/everythingfunctional/veggies/tmp/example.f90:667:9
    #6 0x4c785a in main_IP_run_ /home/brad/Repositories/GitLab/everythingfunctional/veggies/tmp/example.f90:753:18
    #7 0x4c4158 in MAIN__ /home/brad/Repositories/GitLab/everythingfunctional/veggies/tmp/example.f90:737:14
    #8 0x40a578 in main (/home/brad/Repositories/GitLab/everythingfunctional/veggies/tmp/a.out+0x40a578) (BuildId: d40d79c0bb0f65cdf9699cd731f6132bed9f3a81)
    #9 0x7f43b4b90ccf  (/usr/lib/libc.so.6+0x27ccf) (BuildId: 8bfe03f6bf9b6a6e2591babd0bbc266837d8f658)

SUMMARY: MemorySanitizer: use-of-uninitialized-value (/home/brad/Repositories/GitLab/everythingfunctional/veggies/tmp/a.out+0x4dbf67) (BuildId: d40d79c0bb0f65cdf9699cd731f6132bed9f3a81) in for__write_output
Exiting

I'm out of ideas for how to simplify this further, but hopefully this is simple enough.

0 Kudos
1 Solution
Devorah_H_Intel
Moderator
105 Views

This issue is fixed in 2024.2 and 2025.0 ifx

View solution in original post

6 Replies
JohnNichols
Valued Contributor III
1,086 Views

I thought I had almost seen everything..................

.........................until now.

I watched Veggie Tales with my children, not my cup of tea, but one does it for one's children. 

But veggie-test.  Ok that is perfect.  

 

Screenshot 2023-10-09 120539.png

0 Kudos
andrew_4619
Honored Contributor III
1,032 Views

Out of interest I built and ran example.f90 in windows. The result is below, I haven't dug into it but the debugger reports "invalid structure member 'RUN' "

andrew_4619_0-1696939396476.png

 

 

 

0 Kudos
Ron_Green
Moderator
802 Views

The bug ID for example.f90 is CMPRLLVM-57073


Ron_Green
Moderator
793 Views

Interestingly,  when I test with the 2024.1.0 early build compiler AND I use Address Sanitizer it passes.  but without, same crash.  

 

ifx -g -O0 -traceback example.f90 -what -fsanitize=address

Intel(R) Fortran 24.0-1472.3

rwgreen@orcsle153:~/quad/q06171584$ ./a.out

Running Tests

Passed

 

I'm baffled why this would change the behavior.  

 

0 Kudos
Devorah_H_Intel
Moderator
106 Views

This issue is fixed in 2024.2 and 2025.0 ifx

everythingfunctional
New Contributor I
84 Views

Great news! It does appear that the bug I isolated above is fixed, unfortunately the full test suite for veggies still crashes, but it looks like a different bug. I'll see if I can create a reproducer and submit it in a new thread.

0 Kudos
Reply