<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 - Segfault when using std::atomic"
   href="https://bugs.llvm.org/show_bug.cgi?id=44348">44348</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>Segfault when using std::atomic
          </td>
        </tr>

        <tr>
          <th>Product</th>
          <td>clang
          </td>
        </tr>

        <tr>
          <th>Version</th>
          <td>trunk
          </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>enhancement
          </td>
        </tr>

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

        <tr>
          <th>Component</th>
          <td>LLVM Codegen
          </td>
        </tr>

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

        <tr>
          <th>Reporter</th>
          <td>leonardchan@google.com
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>llvm-bugs@lists.llvm.org, neeilans@live.com, richard-llvm@metafoo.co.uk
          </td>
        </tr></table>
      <p>
        <div>
        <pre>We're hitting a segfault when using std::atomic:

```
[20356/55012] CXX
user-x64-clang/obj/system/ulib/backtrace-request/test/backtrace-request-test.backtrace-request-test.cc.o
FAILED:
user-x64-clang/obj/system/ulib/backtrace-request/test/backtrace-request-test.backtrace-request-test.cc.o 
/b/s/w/ir/cache/goma/client/gomacc 
../../prebuilt/third_party/clang/linux-x64/bin/clang++ -MD -MF
user-x64-clang/obj/system/ulib/backtrace-request/test/backtrace-request-test.backtrace-request-test.cc.o.d
-o
user-x64-clang/obj/system/ulib/backtrace-request/test/backtrace-request-test.backtrace-request-test.cc.o
-DTOOLCHAIN_VERSION=s8C8xEGKRekKT76tFnfhh2IBpFFwv2m3x8YJL9FN2usC
-DZX_ASSERT_LEVEL=2 -DWITH_FRAME_POINTERS=1
-D_LIBCPP_ENABLE_THREAD_SAFETY_ANNOTATIONS=1 -D_ALL_SOURCE
-I../../zircon/system/public
-I../../zircon/system/ulib/backtrace-request/include
-I../../zircon/system/ulib/fdio/include
-I../../zircon/system/ulib/zircon/include -Iuser.vdso-x64-clang.shlib/gen
-I../../zircon/system/ulib/zx/include -I../../zircon/system/ulib/fbl/include
-I../../zircon/system/ulib/fit/include
-I../../zircon/system/ulib/zxtest/include -I../../zircon/system/ulib/c/include
-fno-common --target=x86_64-fuchsia -mcx16 -march=x86-64
-fcrash-diagnostics-dir=clang-crashreports -fcolor-diagnostics
-fdebug-prefix-map=/b/s/w/ir/k/fuchsia=../.. -no-canonical-prefixes -O2 -g3
-Wall -Wextra -Wno-unused-parameter -Wno-address-of-packed-member -Wnewline-eof
-Wno-unknown-warning-option -Wno-c99-designator -Wno-int-in-bool-context
-fno-omit-frame-pointer -ffunction-sections -fdata-sections -Wthread-safety
-Wimplicit-fallthrough -fvisibility=hidden -ftrivial-auto-var-init=pattern
-Werror -Wno-error=deprecated-declarations -idirafter
../../zircon/third_party/ulib/musl/include -Wno-unused-function -idirafter
../../zircon/third_party/ulib/musl/include -std=c++17 -Wconversion
-Wno-sign-conversion -Wextra-semi -Wno-deprecated-copy
-ftemplate-backtrace-limit=0 -fno-exceptions -fno-rtti -fno-threadsafe-statics
-fvisibility-inlines-hidden -c
../../zircon/system/ulib/backtrace-request/test/backtrace-request-test.cc
clang++: error: unable to execute command: Segmentation fault
clang++: error: clang frontend command failed due to signal (use -v to see
invocation)
Fuchsia clang version 10.0.0
(<a href="https://fuchsia.googlesource.com/a/third_party/llvm-project">https://fuchsia.googlesource.com/a/third_party/llvm-project</a>
fc31b58eff9da4447f9f332f07de3cd07ab4b56c)
Target: x86_64-unknown-fuchsia
Thread model: posix
InstalledDir: ../../prebuilt/third_party/clang/linux-x64/bin
clang++: note: diagnostic msg: PLEASE submit a bug report to
<a href="https://bugs.llvm.org/">https://bugs.llvm.org/</a> and include the crash backtrace, preprocessed source,
and associated run script.
clang++: note: diagnostic msg: 
********************

PLEASE ATTACH THE FOLLOWING FILES TO THE BUG REPORT:
Preprocessed source(s) and associated run script(s) are located at:
clang++: note: diagnostic msg:
clang-crashreports/backtrace-request-test-a56ca4.cpp
clang++: note: diagnostic msg:
clang-crashreports/backtrace-request-test-a56ca4.sh
clang++: note: diagnostic msg: 

********************
```

Reproduced with a 2-stage ToT clang:

```
$ cmake -G Ninja \
  -DLLVM_ENABLE_LTO=OFF \
  -DLLVM_ENABLE_PROJECTS="clang;clang-tools-extra;lld" \
  -DLLVM_ENABLE_RUNTIMES="compiler-rt;libcxx;libcxxabi;libunwind" \
  -DCMAKE_INSTALL_PREFIX= \
  -C ${LLVM_SRCDIR}/clang/cmake/caches/Fuchsia-stage2.cmake \
  ${LLVM_SRCDIR}/llvm
$ env DESTDIR=`pwd`/install ninja install-distribution-stripped
$ ./install/bin/clang++ "-cc1" "-triple" "x86_64-unknown-fuchsia" "-emit-obj"
"--mrelax-relocations" "-disable-free" "-disable-llvm-verifier"
"-discard-value-names" "-main-file-name" "backtrace-request-test.cc"
"-mrelocation-model" "pic" "-pic-level" "2" "-pic-is-pie" "-mthread-model"
"posix" "-mframe-pointer=all" "-masm-verbose" "-mconstructor-aliases"
"-munwind-tables" "-fuse-init-array" "-target-cpu" "x86-64" "-target-feature"
"+cx16" "-dwarf-column-info" "-debug-info-kind=limited" "-dwarf-version=4"
"-debugger-tuning=gdb" "-ffunction-sections" "-fdata-sections"
"-sys-header-deps" "-D"
"TOOLCHAIN_VERSION=s8C8xEGKRekKT76tFnfhh2IBpFFwv2m3x8YJL9FN2usC" "-D"
"ZX_ASSERT_LEVEL=2" "-D" "WITH_FRAME_POINTERS=1" "-D"
"_LIBCPP_ENABLE_THREAD_SAFETY_ANNOTATIONS=1" "-D" "_ALL_SOURCE" "-O2" "-Wall"
"-Wextra" "-Wno-unused-parameter" "-Wno-address-of-packed-member"
"-Wnewline-eof" "-Wno-unknown-warning-option" "-Wno-c99-designator"
"-Wno-int-in-bool-context" "-Wthread-safety" "-Wimplicit-fallthrough" "-Werror"
"-Wno-error=deprecated-declarations" "-Wno-unused-function" "-Wconversion"
"-Wno-sign-conversion" "-Wextra-semi" "-Wno-deprecated-copy" "-std=c++17"
"-fdeprecated-macro"
"-fdebug-prefix-map=/usr/local/google/home/cpu/src/fuchsia/out/default.zircon=."
"-fdebug-prefix-map=/usr/local/google/home/cpu/src/fuchsia/out=.."
"-fdebug-prefix-map=/usr/local/google/home/cpu/src/fuchsia=../.."
"-ferror-limit" "19" "-ftemplate-backtrace-limit" "0" "-fmessage-length" "0"
"-fvisibility" "hidden" "-fvisibility-inlines-hidden" "-fsanitize=safe-stack"
"-stack-protector" "2" "-ftrivial-auto-var-init=pattern" "-fno-rtti"
"-fgnuc-version=4.2.1" "-fno-threadsafe-statics" "-fobjc-runtime=gcc"
"-fno-common" "-fdiagnostics-show-option" "-fcolor-diagnostics"
"-vectorize-loops" "-vectorize-slp" "-faddrsig" "-x" "c++"
~/misc/backtrace-request-test-108348.cpp
```

Reproducer is too big, so I'm sharing it via google drive:
<a href="https://drive.google.com/a/google.com/file/d/1BPXld8AvUDbU05l84STBEY6z2EsxG56-/view?usp=sharing">https://drive.google.com/a/google.com/file/d/1BPXld8AvUDbU05l84STBEY6z2EsxG56-/view?usp=sharing</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>