Intel® oneAPI DPC++/C++ Compiler
Talk to fellow users of Intel® oneAPI DPC++/C++ Compiler and companion tools like Intel® oneAPI DPC++ Library, Intel® DPC++ Compatibility Tool, and Intel® Distribution for GDB*
Announcements
FPGA community forums and blogs on community.intel.com are migrating to the new Altera Community and are read-only. For urgent support needs during this transition, please visit the FPGA Design Resources page or contact an Altera Authorized Distributor.
806 Discussions

icx with OpenMP and Undefined Behavior sanitizer

fvanderhave
Beginner
2,662 Views

When I combined the Undefined Behavior sanitizer and OpenMP, I got unexpected results from software I am developing (compiling with icx on Linux). I reduced it to the test case in the attached icx_ubsan_omp_issue.c. The OMP for-loop within the OMP parallel section seems to run too many iterations in total when the Undefined Behavior sanitizer is used.

The system I am using has an Intel(R) Core(TM) i5-13600K, so OMP is expected to use 20 threads by default. My system is running Ubuntu 24.04.2 LTS with these compiler versions:

$ /opt/intel/oneapi/compiler/latest/bin/icx --version
Intel(R) oneAPI DPC++/C++ Compiler 2025.0.4 (2025.0.4.20241205)
Target: x86_64-unknown-linux-gnu
Thread model: posix
InstalledDir: /opt/intel/oneapi/compiler/2025.0/bin/compiler
Configuration file: /opt/intel/oneapi/compiler/2025.0/bin/compiler/../icx.cfg

$ gcc --version
gcc (Ubuntu 13.3.0-6ubuntu2~24.04) 13.3.0

$ clang --version
Ubuntu clang version 18.1.3 (1ubuntu1)
Target: x86_64-pc-linux-gnu
Thread model: posix
InstalledDir: /usr/bin

 

0 Kudos
1 Solution
Mayur_P_Intel
Moderator
2,196 Views

The Issue has been fixed, and the fix will be available in the compiler release 2025.3


View solution in original post

0 Kudos
6 Replies
fvanderhave
Beginner
2,661 Views

A run with the expected behavior:

$ /opt/intel/oneapi/compiler/latest/bin/icx -qopenmp -O1 -g -Wall -Wextra -o icx_ubsan_omp_issue icx_ubsan_omp_issue.c
$ ./icx_ubsan_omp_issue
We have entered the parallel section.
Number of threads: 20.
Thread 000 ; inx 0000000 ; &inx 0x7fff4be8643c
Thread 002 ; inx 0100000 ; &inx 0x7155613fbf3c
Thread 004 ; inx 0200000 ; &inx 0x715553ffdfbc
Thread 014 ; inx 0700000 ; &inx 0x71553affa23c
Thread 012 ; inx 0600000 ; &inx 0x7155335fe1bc
Thread 016 ; inx 0800000 ; &inx 0x715539ff62bc
Thread 008 ; inx 0400000 ; &inx 0x715551ff60bc
Thread 006 ; inx 0300000 ; &inx 0x715552ffa03c
Thread 018 ; inx 0900000 ; &inx 0x715538ff233c
Thread 010 ; inx 0500000 ; &inx 0x715550ff213c
Number of elements processed by parallel loop: 1000000.
$

A run with UBsan added, with an unexpected result:
$ /opt/intel/oneapi/compiler/latest/bin/icx -fsanitize=undefined -qopenmp -O1 -g -Wall -Wextra -o icx_ubsan_omp_issue icx_ubsan_omp_issue.c
$ ./icx_ubsan_omp_issue
We have entered the parallel section.
Number of threads: 20.
Thread 016 ; inx 0000000 ; &inx 0x7fff0d61257c
Thread 000 ; inx 0000000 ; &inx 0x7fff0d61257c
Thread 010 ; inx 0000000 ; &inx 0x7fff0d61257c
Thread 005 ; inx 0000000 ; &inx 0x7fff0d61257c
Thread 019 ; inx 0000000 ; &inx 0x7fff0d61257c
Thread 016 ; inx 0000000 ; &inx 0x7fff0d61257c
Thread 003 ; inx 0000000 ; &inx 0x7fff0d61257c
Thread 004 ; inx 0000000 ; &inx 0x7fff0d61257c
Thread 011 ; inx 0000000 ; &inx 0x7fff0d61257c
Thread 002 ; inx 0000000 ; &inx 0x7fff0d61257c
Thread 006 ; inx 0000000 ; &inx 0x7fff0d61257c
Thread 017 ; inx 0000000 ; &inx 0x7fff0d61257c
Thread 013 ; inx 0000000 ; &inx 0x7fff0d61257c
Thread 000 ; inx 0000000 ; &inx 0x7fff0d61257c
Thread 012 ; inx 0000000 ; &inx 0x7fff0d61257c
Thread 010 ; inx 0000000 ; &inx 0x7fff0d61257c
Thread 001 ; inx 0000000 ; &inx 0x7fff0d61257c
Thread 009 ; inx 0000000 ; &inx 0x7fff0d61257c
Thread 005 ; inx 0000000 ; &inx 0x7fff0d61257c
Thread 018 ; inx 0000000 ; &inx 0x7fff0d61257c
Thread 014 ; inx 0000000 ; &inx 0x7fff0d61257c
Thread 015 ; inx 0000000 ; &inx 0x7fff0d61257c
Thread 007 ; inx 0000000 ; &inx 0x7fff0d61257c
Thread 008 ; inx 0000000 ; &inx 0x7fff0d61257c
Thread 016 ; inx 0100000 ; &inx 0x7fff0d61257c
Thread 019 ; inx 0100000 ; &inx 0x7fff0d61257c
Thread 005 ; inx 0100000 ; &inx 0x7fff0d61257c
Thread 014 ; inx 0100000 ; &inx 0x7fff0d61257c
Thread 018 ; inx 0100000 ; &inx 0x7fff0d61257c
Thread 017 ; inx 0100000 ; &inx 0x7fff0d61257c
Thread 019 ; inx 0100000 ; &inx 0x7fff0d61257c
Thread 005 ; inx 0100000 ; &inx 0x7fff0d61257c
Thread 016 ; inx 0100000 ; &inx 0x7fff0d61257c
Thread 005 ; inx 0100000 ; &inx 0x7fff0d61257c
Thread 014 ; inx 0200000 ; &inx 0x7fff0d61257c
Thread 018 ; inx 0200000 ; &inx 0x7fff0d61257c
Thread 017 ; inx 0200000 ; &inx 0x7fff0d61257c
Thread 003 ; inx 0200000 ; &inx 0x7fff0d61257c
Thread 001 ; inx 0200000 ; &inx 0x7fff0d61257c
Thread 011 ; inx 0100000 ; &inx 0x7fff0d61257c
Thread 009 ; inx 0100000 ; &inx 0x7fff0d61257c
Thread 003 ; inx 0100000 ; &inx 0x7fff0d61257c
Thread 005 ; inx 0100000 ; &inx 0x7fff0d61257c
Thread 019 ; inx 0100000 ; &inx 0x7fff0d61257c
Thread 013 ; inx 0100000 ; &inx 0x7fff0d61257c
Thread 008 ; inx 0100000 ; &inx 0x7fff0d61257c
Thread 018 ; inx 0100000 ; &inx 0x7fff0d61257c
Thread 017 ; inx 0100000 ; &inx 0x7fff0d61257c
Thread 000 ; inx 0100000 ; &inx 0x7fff0d61257c
Thread 006 ; inx 0100000 ; &inx 0x7fff0d61257c
Thread 016 ; inx 0100000 ; &inx 0x7fff0d61257c
Thread 001 ; inx 0100000 ; &inx 0x7fff0d61257c
Thread 016 ; inx 0200000 ; &inx 0x7fff0d61257c
Thread 019 ; inx 0200000 ; &inx 0x7fff0d61257c
Thread 006 ; inx 0300000 ; &inx 0x7fff0d61257c
Thread 018 ; inx 0300000 ; &inx 0x7fff0d61257c
Thread 017 ; inx 0300000 ; &inx 0x7fff0d61257c
Thread 000 ; inx 0300000 ; &inx 0x7fff0d61257c
Thread 019 ; inx 0300000 ; &inx 0x7fff0d61257c
Thread 012 ; inx 0300000 ; &inx 0x7fff0d61257c
Thread 011 ; inx 0300000 ; &inx 0x7fff0d61257c

.... many more lines with repeated occurrences of the same value for inx and the same address for inx ...

Number of elements processed by parallel loop: 20000000.

0 Kudos
Mayur_P_Intel
Moderator
2,589 Views

I am able to reproduce this issue with Intel 2025.1 compiler.

0 Kudos
fvanderhave
Beginner
2,554 Views

Apologies for not testing with the latest release straight away. The Ubuntu update from 22.04 LTS to 24.04 disabled my oneAPI updates, which I had not noticed. I upgraded my Intel compiler to 2025.1. The unexpected behavior in both the software where I noticed it and in the submitted test program is still present when I test them with UBsan enabled.

0 Kudos
Mayur_P_Intel
Moderator
2,529 Views

This case has been now escalated as a bug report to the Compiler team. 

0 Kudos
Mayur_P_Intel
Moderator
2,197 Views

The Issue has been fixed, and the fix will be available in the compiler release 2025.3


0 Kudos
fvanderhave
Beginner
2,153 Views

That is good news. Thanks!

0 Kudos
Reply