[llvm-bugs] [Bug 47618] New: compile-time segfault with C code when using `-g`

via llvm-bugs llvm-bugs at lists.llvm.org
Tue Sep 22 16:53:11 PDT 2020


https://bugs.llvm.org/show_bug.cgi?id=47618

            Bug ID: 47618
           Summary: compile-time segfault with C code when using `-g`
           Product: OpenMP
           Version: unspecified
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: Clang Compiler Support
          Assignee: unassignedclangbugs at nondot.org
          Reporter: bertoni at anl.gov
                CC: llvm-bugs at lists.llvm.org

Hello,

I see a compile-time segfault if I compile a simple C OpenMP offload code with
`-g` (see reproducer below). It will compile and run properly without `-g`, and
it will also compile and run properly if it's renamed as a C++ file (test.cpp)
and compiled with clang++. This is a minor issue, since it has so many
workarounds.

# Steps to reproduce:
```
$ cat test.c
#include "stdio.h"
int main()
{
  int n = 0;
#pragma omp target map(from:n)
  n = 9;
  printf( "Expected: 9, Got: %d\n", n);
  return 0;
}


$ clang -fopenmp -fopenmp-targets=nvptx64-nvidia-cuda -g test.c
clang-12: error: unable to execute command: Segmentation fault
clang-12: error: ptxas command failed due to signal (use -v to see invocation)
clang version 12.0.0
(/gpfs/jlse-fs0/users/yeluo/opt/llvm-clang/llvm-project/clang
66bcb14312a08b5d7e1197d23d748b2e23c4d852)
Target: x86_64-unknown-linux-gnu
Thread model: posix
InstalledDir: /soft/compilers/llvm/master-nightly/bin
clang-12: note: diagnostic msg: Error generating preprocessed source(s).

```

It works fine without `-g`, so looks like it has something to do with that:
```
$ clang -fopenmp -fopenmp-targets=nvptx64-nvidia-cuda test.c
(base) [bertoni at gpu00 tmp]$ ./a.out 
Expected: 9, Got: 9

``` 

# Compiler version:
All the versions I tried fail:
```
$ clang -v
clang version 12.0.0
(/gpfs/jlse-fs0/users/yeluo/opt/llvm-clang/llvm-project/clang
66bcb14312a08b5d7e1197d23d748b2e23c4d852)
Target: x86_64-unknown-linux-gnu
Thread model: posix
InstalledDir: /soft/compilers/llvm/master-nightly/bin
Found candidate GCC installation:
/soft/compilers/gcc/7.4.0/linux-rhel7-x86_64/lib/gcc/x86_64-pc-linux-gnu/7.4.0
Selected GCC installation:
/soft/compilers/gcc/7.4.0/linux-rhel7-x86_64/lib/gcc/x86_64-pc-linux-gnu/7.4.0
Candidate multilib: .;@m64
Selected multilib: .;@m64
Found CUDA installation: /soft/compilers/cuda/cuda-10.0.130, version 10.0

```
also
```
$ clang -v
clang version 12.0.0
(/gpfs/jlse-fs0/users/yeluo/opt/llvm-clang/llvm-project/clang
6313f5561945930e9a5ec63cb187605ce741bb61)
Target: x86_64-unknown-linux-gnu
Thread model: posix
InstalledDir: /soft/compilers/llvm/master-latest/bin
Found candidate GCC installation:
/soft/compilers/gcc/7.4.0/linux-rhel7-x86_64/lib/gcc/x86_64-pc-linux-gnu/7.4.0
Selected GCC installation:
/soft/compilers/gcc/7.4.0/linux-rhel7-x86_64/lib/gcc/x86_64-pc-linux-gnu/7.4.0
Candidate multilib: .;@m64
Selected multilib: .;@m64
Found CUDA installation: /soft/compilers/cuda/cuda-10.0.130, version 10.0
```

# Platform:
x86 + Nvidia V100

Thanks,
Colleen

-- 
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20200922/2dc0e244/attachment.html>


More information about the llvm-bugs mailing list