<html>
    <head>
      <base href="https://bugs.llvm.org/">
    </head>
    <body><table border="1" cellspacing="0" cellpadding="8">
        <tr>
          <th>Bug ID</th>
          <td><a class="bz_bug_link 
          bz_status_NEW "
   title="NEW - OpenMP profiling via ITT API is broken on Clang 11.x and 12.x (OpenMP runtime crashes)"
   href="https://bugs.llvm.org/show_bug.cgi?id=48644">48644</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>OpenMP profiling via ITT API is broken on Clang 11.x and 12.x (OpenMP runtime crashes)
          </td>
        </tr>

        <tr>
          <th>Product</th>
          <td>OpenMP
          </td>
        </tr>

        <tr>
          <th>Version</th>
          <td>unspecified
          </td>
        </tr>

        <tr>
          <th>Hardware</th>
          <td>PC
          </td>
        </tr>

        <tr>
          <th>OS</th>
          <td>Linux
          </td>
        </tr>

        <tr>
          <th>Status</th>
          <td>NEW
          </td>
        </tr>

        <tr>
          <th>Severity</th>
          <td>normal
          </td>
        </tr>

        <tr>
          <th>Priority</th>
          <td>P
          </td>
        </tr>

        <tr>
          <th>Component</th>
          <td>Runtime Library
          </td>
        </tr>

        <tr>
          <th>Assignee</th>
          <td>unassignedbugs@nondot.org
          </td>
        </tr>

        <tr>
          <th>Reporter</th>
          <td>vitaly.slobodskoy@huawei.com
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>llvm-bugs@lists.llvm.org
          </td>
        </tr></table>
      <p>
        <div>
        <pre>Created <span class=""><a href="attachment.cgi?id=24335" name="attach_24335" title="Simple ITT collector">attachment 24335</a> <a href="attachment.cgi?id=24335&action=edit" title="Simple ITT collector">[details]</a></span>
Simple ITT collector

Attempt to profile OpenMP application via ITT API (e.g. using VTune) leads to
crash within OpenMP runtime.

Steps to reproduce:
1) compile simple ITT collector (attached ittcollector.cpp):
g++ -std=c++11 -fPIC -g ./ittcollector.cpp -I <path to
llvm-project>/openmp/runtime/src/thirdparty/ittnotify/ -o libittc.so -shared
-ldl
2) compile the following OpenMP workload:
$ cat test.c
#include <stdio.h>

int main() {
    #pragma omp parallel
    {
            printf("Hello!\n");
    }
}
$ clang test.c -fopenmp -o test
3) run workload this way:
INTEL_LIBITTNOTIFY64=<absolute path>/libittc.so ./test
...
Hello!
Hello!
Hello!
Segmentation fault (core dumped)

Stack of crash:
Program received signal SIGSEGV, Segmentation fault.
0x000003fff7e74640 in __kmp_itt_frame_submit (gtid=0, begin=0, end=0,
imbalance=0, loc=0x400848, team_size=96, region=0)
    at /home/vslobods/llvm-project-main/openmp/runtime/src/kmp_itt.inl:287
287               loc->reserved_2 |= (frm + 1) << 16; // save "new" value
Missing separate debuginfos, use: debuginfo-install glibc-2.17-260.el7.aarch64
(gdb) bt
#0  0x000003fff7e74640 in __kmp_itt_frame_submit (gtid=0, begin=0, end=0,
imbalance=0, loc=0x400848, team_size=96, region=0)
    at /home/vslobods/llvm-project-main/openmp/runtime/src/kmp_itt.inl:287
#1  0x000003fff7ebba4c in __kmp_join_barrier (gtid=0) at
/home/vslobods/llvm-project-main/openmp/runtime/src/kmp_barrier.cpp:1874
#2  0x000003fff7e8d1b8 in __kmp_internal_join (id=0x400848, gtid=0,
team=0x44bc40)
    at /home/vslobods/llvm-project-main/openmp/runtime/src/kmp_runtime.cpp:7468
#3  0x000003fff7e80878 in __kmp_join_call (loc=0x400848, gtid=0,
fork_context=fork_context_intel, exit_teams=0)
    at /home/vslobods/llvm-project-main/openmp/runtime/src/kmp_runtime.cpp:2368
#4  0x000003fff7e6c120 in __kmpc_fork_call (loc=0x400848, argc=0,
microtask=0x40075c <.omp_outlined.>)
    at /home/vslobods/llvm-project-main/openmp/runtime/src/kmp_csupport.cpp:314
#5  0x000000000040074c in main ()

It fails on attempt to write to loc->reserved_2 which resides in read-only
segment.
This is a regression in LLVM 11 (LLVM 10 doesn't have this issue) which still
resides within LLVM 12. The regression was introduced by the following commit:
<a href="https://github.com/llvm/llvm-project/commit/9f4a92a4349ff1794379b706a4851c678899d5d2">https://github.com/llvm/llvm-project/commit/9f4a92a4349ff1794379b706a4851c678899d5d2</a></pre>
        </div>
      </p>


      <hr>
      <span>You are receiving this mail because:</span>

      <ul>
          <li>You are on the CC list for the bug.</li>
      </ul>
    </body>
</html>