Skip to content

[clang] Segmentation fault with static_assert(__builtin_is_implicit_lifetime(int __attribute__((btf_type_tag("user"))) *)) #106864

Closed
@Zingam

Description

@Zingam

The following libc++ lit test causes a segmentation fault:

#include <cassert>

template <typename T>
constexpr void test1() {
    assert(true);
    static_assert(__builtin_is_implicit_lifetime(int __attribute__((btf_type_tag("user"))) *));
}

constexpr bool test() {
  test1<int>();
  return true;
}

int main(int, char**) {
  test();
  static_assert(test());

  return 0;
}
# .---command stderr------------
# | PLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace, preprocessed source, and associated run script.
# | Stack dump:
# | 0.  Program arguments: /usr/lib/llvm-20/bin/clang -cc1 -triple x86_64-unknown-linux-gnu -emit-obj -dumpdir /home/h/Projects/llvm-project/build/default.debug.libcxx.clang-20/test/std/utilities/meta/meta.unary/meta.unary.prop/Output/is_implicit.pass.cpp.dir/t.tmp.exe- -disable-free -clear-ast-before-backend -disable-llvm-verifier -discard-value-names -main-file-name is_implicit.pass.cpp -mrelocation-model pic -pic-level 2 -pic-is-pie -mframe-pointer=all -fmath-errno -ffp-contract=on -fno-rounding-math -mconstructor-aliases -funwind-tables=2 -target-cpu x86-64 -tune-cpu generic -debugger-tuning=gdb -fdebug-compilation-dir=/home/h/Projects/llvm-project/build/default.debug.libcxx.clang-20/test/std/utilities/meta/meta.unary/meta.unary.prop -fcoverage-compilation-dir=/home/h/Projects/llvm-project/build/default.debug.libcxx.clang-20/test/std/utilities/meta/meta.unary/meta.unary.prop -nostdinc++ -resource-dir /usr/lib/llvm-20/lib/clang/20 -I /home/h/Projects/llvm-project/build/default.debug.libcxx.clang-20/include/c++/v1 -I /home/h/Projects/llvm-project/build/default.debug.libcxx.clang-20/include/c++/v1 -I /home/h/Projects/llvm-project/libcxx/test/support -D _LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER -D _LIBCPP_ENABLE_EXPERIMENTAL -D _LIBCPP_HARDENING_MODE=_LIBCPP_HARDENING_MODE_DEBUG -internal-isystem /usr/lib/llvm-20/lib/clang/20/include -internal-isystem /usr/local/include -internal-isystem /usr/lib/gcc/x86_64-linux-gnu/14/../../../../x86_64-linux-gnu/include -internal-externc-isystem /usr/include/x86_64-linux-gnu -internal-externc-isystem /include -internal-externc-isystem /usr/include -Werror -Wall -Wctad-maybe-unsupported -Wextra -Wshadow -Wundef -Wunused-template -Wno-unused-command-line-argument -Wno-attributes -Wno-pessimizing-move -Wno-noexcept-type -Wno-atomic-alignment -Wno-reserved-module-identifier -Wdeprecated-copy -Wdeprecated-copy-dtor -Wno-user-defined-literals -Wno-tautological-compare -Wsign-compare -Wunused-variable -Wunused-parameter -Wunreachable-code -Wno-unused-local-typedef -Wno-local-type-template-args -Wno-c++11-extensions -Wno-unknown-pragmas -Wno-pass-failed -Wno-mismatched-new-delete -Wno-redundant-move -Wno-self-move -Werror=thread-safety -Wuser-defined-warnings -std=c++26 -fdeprecated-macro -ferror-limit 19 -pthread -fgnuc-version=4.2.1 -fno-implicit-modules -fskip-odr-check-in-gmf -fcxx-exceptions -fexceptions -faddrsig -D__GCC_HAVE_DWARF2_CFI_ASM=1 -o /tmp/lit-tmp-azt46ovm/is_implicit-847fa8.o -x c++ /home/h/Projects/llvm-project/libcxx/test/std/utilities/meta/meta.unary/meta.unary.prop/is_implicit.pass.cpp
# | 1.  /home/h/Projects/llvm-project/libcxx/test/std/utilities/meta/meta.unary/meta.unary.prop/is_implicit.pass.cpp:10:14: current parser token ')'
# | 2.  /home/h/Projects/llvm-project/libcxx/test/std/utilities/meta/meta.unary/meta.unary.prop/is_implicit.pass.cpp:9:23: parsing function body 'test'
# | 3.  /home/h/Projects/llvm-project/libcxx/test/std/utilities/meta/meta.unary/meta.unary.prop/is_implicit.pass.cpp:9:23: in compound statement ('{}')
# | 4.  /home/h/Projects/llvm-project/libcxx/test/std/utilities/meta/meta.unary/meta.unary.prop/is_implicit.pass.cpp:4:16: instantiating function definition 'test1<int>'
# | #0 0x00007fd805f4babf llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/usr/lib/llvm-20/bin/../lib/libLLVM.so.20.0+0xf62abf)
# | #1 0x00007fd805f497d9 llvm::sys::RunSignalHandlers() (/usr/lib/llvm-20/bin/../lib/libLLVM.so.20.0+0xf607d9)
# | #2 0x00007fd805f4c210 (/usr/lib/llvm-20/bin/../lib/libLLVM.so.20.0+0xf63210)
# | #3 0x00007fd804a7f320 (/lib/x86_64-linux-gnu/libc.so.6+0x45320)
# | #4 0x00007fd80e3fea20 clang::ObjCObjectTypeLoc::initializeLocal(clang::ASTContext&, clang::SourceLocation) (/usr/lib/llvm-20/bin/../lib/libclang-cpp.so.20.0+0x1333a20)
# | #5 0x00007fd80de35242 clang::ASTContext::getTrivialTypeSourceInfo(clang::QualType, clang::SourceLocation) const (/usr/lib/llvm-20/bin/../lib/libclang-cpp.so.20.0+0xd6a242)
# | #6 0x00007fd80ef17ff5 clang::Sema::SubstType(clang::QualType, clang::MultiLevelTemplateArgumentList const&, clang::SourceLocation, clang::DeclarationName) (/usr/lib/llvm-20/bin/../lib/libclang-cpp.so.20.0+0x1e4cff5)
# | #7 0x000055c21f13384c
# | clang++-20: error: unable to execute command: Segmentation fault
# | clang++-20: error: clang frontend command failed due to signal (use -v to see invocation)
# | Ubuntu clang version 20.0.0 (++20240828081755+22e55ba3293f-1~exp1~20240828081902.377)
# | Target: x86_64-unknown-linux-gnu
# | Thread model: posix
# | InstalledDir: /usr/lib/llvm-20/bin
# | clang++-20: note: diagnostic msg:
# | ********************
# |
# | PLEASE ATTACH THE FOLLOWING FILES TO THE BUG REPORT:
# | Preprocessed source(s) and associated run script(s) are located at:
# | clang++-20: note: diagnostic msg: /tmp/lit-tmp-azt46ovm/is_implicit-3295e8.cpp
# | clang++-20: note: diagnostic msg: /tmp/lit-tmp-azt46ovm/is_implicit-3295e8.sh
# | clang++-20: note: diagnostic msg:
# |
# | ********************
# `-----------------------------
# error: command failed with exit status: 1

Metadata

Metadata

Assignees

No one assigned

    Labels

    clang:frontendLanguage frontend issues, e.g. anything involving "Sema"crashPrefer [crash-on-valid] or [crash-on-invalid]

    Type

    No type

    Projects

    Status

    Done

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions