Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Clang][Sema] Expose static inline functions from GMF #104701

Merged
merged 8 commits into from
Dec 31, 2024

Conversation

jiixyj
Copy link
Contributor

@jiixyj jiixyj commented Aug 18, 2024

In C, it is a common pattern to have static inline functions in headers to avoid ODR issues. Currently, when those headers are included in a GMF, the names are not found when two-phase name lookup and ADL is involved. Those names are removed by Sema::AddOverloadCandidate.

Similarly, in C++, sometimes people use templates with internal linkage in headers.

As the GMF was designed to be a transitional mechanism for headers, special case those functions in Sema::AddOverloadCandidate.

This fixes #98021.

They should be exposed even when two-phase name lookup and ADL are
involved.
@llvmbot llvmbot added clang Clang issues not falling into any other category clang:frontend Language frontend issues, e.g. anything involving "Sema" clang:modules C++20 modules and Clang Header Modules labels Aug 18, 2024
@llvmbot
Copy link
Member

llvmbot commented Aug 18, 2024

@llvm/pr-subscribers-clang

@llvm/pr-subscribers-clang-modules

Author: Jan Kokemüller (jiixyj)

Changes

In C, it is a common pattern to have static inline functions in headers to avoid ODR issues. Currently, when those headers are included in a GMF, the names are not found when two-phase name lookup and ADL is involved. Those names are removed by Sema::AddOverloadCandidate.

Similarly, in C++, sometimes people use templates with internal linkage in headers.

As the GMF was designed to be a transitional mechanism for headers, special case those functions in Sema::AddOverloadCandidate.

This fixes <#98021>.


Full diff: https://github.com/llvm/llvm-project/pull/104701.diff

6 Files Affected:

  • (modified) clang/lib/Sema/SemaOverload.cpp (+19-4)
  • (added) clang/test/Modules/expose-static-inline-from-gmf-1.cppm (+37)
  • (added) clang/test/Modules/expose-static-inline-from-gmf-2.cppm (+22)
  • (added) clang/test/Modules/expose-static-inline-from-gmf-3.cppm (+24)
  • (added) clang/test/Modules/expose-static-inline-from-gmf-4.cppm (+40)
  • (added) clang/test/Modules/expose-static-inline-from-gmf-5.cppm (+26)
diff --git a/clang/lib/Sema/SemaOverload.cpp b/clang/lib/Sema/SemaOverload.cpp
index 52f640eb96b73b..ca070d0e22d472 100644
--- a/clang/lib/Sema/SemaOverload.cpp
+++ b/clang/lib/Sema/SemaOverload.cpp
@@ -6926,11 +6926,26 @@ void Sema::AddOverloadCandidate(
     /// have linkage. So that all entities of the same should share one
     /// linkage. But in clang, different entities of the same could have
     /// different linkage.
-    NamedDecl *ND = Function;
-    if (auto *SpecInfo = Function->getTemplateSpecializationInfo())
+    const NamedDecl *ND = Function;
+    bool IsImplicitlyInstantiated = false;
+    if (auto *SpecInfo = Function->getTemplateSpecializationInfo()) {
       ND = SpecInfo->getTemplate();
-
-    if (ND->getFormalLinkage() == Linkage::Internal) {
+      IsImplicitlyInstantiated = SpecInfo->getTemplateSpecializationKind() ==
+                                 TSK_ImplicitInstantiation;
+    }
+
+    /// Don't remove inline functions with internal linkage from the overload
+    /// set if they are declared in a GMF.
+    /// The global module is meant to be a transition mechanism for C and C++
+    /// headers.
+    /// Inline functions with internal linkage are a common pattern in headers
+    /// to avoid ODR issues.
+    const bool IsInlineFunctionInGMF =
+          Function->getOwningModule() &&
+          Function->getOwningModule()->isGlobalModule() &&
+          (IsImplicitlyInstantiated || Function->isInlined());
+
+    if (ND->getFormalLinkage() == Linkage::Internal && !IsInlineFunctionInGMF) {
       Candidate.Viable = false;
       Candidate.FailureKind = ovl_fail_module_mismatched;
       return;
diff --git a/clang/test/Modules/expose-static-inline-from-gmf-1.cppm b/clang/test/Modules/expose-static-inline-from-gmf-1.cppm
new file mode 100644
index 00000000000000..4de9b583dac8da
--- /dev/null
+++ b/clang/test/Modules/expose-static-inline-from-gmf-1.cppm
@@ -0,0 +1,37 @@
+// RUN: rm -rf %t
+// RUN: mkdir -p %t
+// RUN: split-file %s %t
+//
+// RUN: %clang -std=c++20 %t/a.cppm --precompile -o %t/a.pcm \
+// RUN:   -DTEST_INLINE
+// RUN: %clang -std=c++20 %t/test.cc -fprebuilt-module-path=%t -fsyntax-only -Xclang -verify \
+// RUN:   -DTEST_INLINE
+//
+// RUN: %clang -std=c++20 %t/a.cppm --precompile -o %t/a.pcm
+// RUN: %clang -std=c++20 %t/test.cc -fprebuilt-module-path=%t -fsyntax-only -Xclang -verify
+
+//--- a.h
+#ifdef TEST_INLINE
+#define INLINE inline
+#else
+#define INLINE
+#endif
+static INLINE void func(long) {}
+template <typename T = long> void a() { func(T{}); }
+
+//--- a.cppm
+module;
+#include "a.h"
+export module a;
+export using ::a;
+
+//--- test.cc
+import a;
+auto m = (a(), 0);
+
+#ifdef TEST_INLINE
+// expected-no-diagnostics
+#else
+// [email protected]:7 {{no matching function for call to 'func'}}
+// [email protected]:2 {{in instantiation of function template specialization 'a<long>' requested here}}
+#endif
diff --git a/clang/test/Modules/expose-static-inline-from-gmf-2.cppm b/clang/test/Modules/expose-static-inline-from-gmf-2.cppm
new file mode 100644
index 00000000000000..c89b613f5074b1
--- /dev/null
+++ b/clang/test/Modules/expose-static-inline-from-gmf-2.cppm
@@ -0,0 +1,22 @@
+// RUN: rm -rf %t
+// RUN: mkdir -p %t
+// RUN: split-file %s %t
+//
+// RUN: %clang -std=c++20 %t/a.cppm --precompile -o %t/a.pcm
+// RUN: %clang -std=c++20 %t/test.cc -fprebuilt-module-path=%t -fsyntax-only -Xclang -verify
+
+//--- a.h
+template <typename G> static inline void func() {}
+template <typename T = long> void a() { func<T>(); }
+
+//--- a.cppm
+module;
+#include "a.h"
+export module a;
+export using ::a;
+
+//--- test.cc
+import a;
+auto m = (a(), 0);
+
+// expected-no-diagnostics
diff --git a/clang/test/Modules/expose-static-inline-from-gmf-3.cppm b/clang/test/Modules/expose-static-inline-from-gmf-3.cppm
new file mode 100644
index 00000000000000..dee7cddafdf701
--- /dev/null
+++ b/clang/test/Modules/expose-static-inline-from-gmf-3.cppm
@@ -0,0 +1,24 @@
+// RUN: rm -rf %t
+// RUN: mkdir -p %t
+// RUN: split-file %s %t
+//
+// RUN: %clang -std=c++20 %t/a.cppm --precompile -o %t/a.pcm
+// RUN: %clang -std=c++20 %t/test.cc -fprebuilt-module-path=%t -fsyntax-only -Xclang -verify
+
+//--- a.h
+namespace ns {
+template <typename G> static void func() {}
+template <typename T = long> void a() { func<T>(); }
+}
+
+//--- a.cppm
+module;
+#include "a.h"
+export module a;
+export using ns::a;
+
+//--- test.cc
+import a;
+auto m = (a(), 0);
+
+// expected-no-diagnostics
diff --git a/clang/test/Modules/expose-static-inline-from-gmf-4.cppm b/clang/test/Modules/expose-static-inline-from-gmf-4.cppm
new file mode 100644
index 00000000000000..09c6b1ffd9c797
--- /dev/null
+++ b/clang/test/Modules/expose-static-inline-from-gmf-4.cppm
@@ -0,0 +1,40 @@
+// RUN: rm -rf %t
+// RUN: mkdir -p %t
+// RUN: split-file %s %t
+//
+// RUN: %clang -std=c++20 %t/a.cppm --precompile -o %t/a.pcm \
+// RUN:   -DTEST_INLINE
+// RUN: %clang -std=c++20 %t/test.cc -fprebuilt-module-path=%t -fsyntax-only -Xclang -verify \
+// RUN:   -DTEST_INLINE
+//
+// RUN: %clang -std=c++20 %t/a.cppm --precompile -o %t/a.pcm
+// RUN: %clang -std=c++20 %t/test.cc -fprebuilt-module-path=%t -fsyntax-only -Xclang -verify
+
+//--- a.h
+#ifdef TEST_INLINE
+#define INLINE inline
+#else
+#define INLINE
+#endif
+namespace ns {
+template <typename G> static void func() {}
+template <> INLINE void func<long>() {}
+template <typename T = long> void a() { func<T>(); }
+}
+
+//--- a.cppm
+module;
+#include "a.h"
+export module a;
+export using ns::a;
+
+//--- test.cc
+import a;
+auto m = (a(), 0);
+
+#ifdef TEST_INLINE
+// expected-no-diagnostics
+#else
+// [email protected]:9 {{no matching function for call to 'func'}}
+// [email protected]:2 {{in instantiation of function template specialization 'ns::a<long>' requested here}}
+#endif
diff --git a/clang/test/Modules/expose-static-inline-from-gmf-5.cppm b/clang/test/Modules/expose-static-inline-from-gmf-5.cppm
new file mode 100644
index 00000000000000..334af845a693dd
--- /dev/null
+++ b/clang/test/Modules/expose-static-inline-from-gmf-5.cppm
@@ -0,0 +1,26 @@
+// RUN: rm -rf %t
+// RUN: mkdir -p %t
+// RUN: split-file %s %t
+//
+// RUN: %clang -std=c++20 %t/a.cppm --precompile -o %t/a.pcm
+// RUN: %clang -std=c++20 %t/test.cc -fprebuilt-module-path=%t -fsyntax-only -Xclang -verify
+
+//--- a.h
+namespace ns {
+namespace {
+template <typename G> void func() {}
+}
+template <typename T = long> void a() { func<T>(); }
+}
+
+//--- a.cppm
+module;
+#include "a.h"
+export module a;
+export using ns::a;
+
+//--- test.cc
+import a;
+auto m = (a(), 0);
+
+// expected-no-diagnostics

Copy link

github-actions bot commented Aug 18, 2024

✅ With the latest revision this PR passed the C/C++ code formatter.

Copy link
Member

@ChuanqiXu9 ChuanqiXu9 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM except comments.

clang/lib/Sema/SemaOverload.cpp Outdated Show resolved Hide resolved
Comment on lines 6937 to 6942
/// Don't remove inline functions with internal linkage from the overload
/// set if they are declared in a GMF.
/// The global module is meant to be a transition mechanism for C and C++
/// headers.
/// Inline functions with internal linkage are a common pattern in headers
/// to avoid ODR issues.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd like to make the comments to be more explicitly to mention the behavior is not strictly conforming the standard. Maybe we need to add a NOTE. BTW, maybe this worth a paper to WG21. WDYT?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sounds like a good idea! One direction could be to create an additional exception to basic.link#17 for exposure of inline TU-local entities declared in a GMF, so that the program would be no longer ill-formed in that case, right? depr.local's note would have to be changed to reflect this.

I will add to the comment that the proposed behavior violates basic.link#17.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I feel the better wording will add a clause to https://eel.is/c++draft/basic.link#14. There are already some exceptions.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry for the delay! I have now updated the comment to include the fact that this fix/workaround violates [basic.link]p17, strictly speaking. I've also merged the main branch. On my machine, the (new) tests in ./tools/clang/test/Modules still pass. Does this work for you? Thanks again for the review!

clang/lib/Sema/SemaOverload.cpp Show resolved Hide resolved
Copy link
Member

@ChuanqiXu9 ChuanqiXu9 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Thanks

@ChuanqiXu9
Copy link
Member

You may want to add a note in ReleaseNotes too. And if you want to write a paper to WG21, please CC me or I'd love to be a co-author with you.

@ChuanqiXu9 ChuanqiXu9 merged commit e50ec3e into llvm:main Dec 31, 2024
8 checks passed
@llvm-ci
Copy link
Collaborator

llvm-ci commented Dec 31, 2024

LLVM Buildbot has detected a new failure on builder clang-aarch64-quick running on linaro-clang-aarch64-quick while building clang at step 5 "ninja check 1".

Full details are available at: https://lab.llvm.org/buildbot/#/builders/65/builds/9952

Here is the relevant piece of the build log for the reference
Step 5 (ninja check 1) failure: stage 1 checked (failure)
******************** TEST 'Clangd Unit Tests :: ./ClangdTests/154/318' FAILED ********************
Script(shard):
--
GTEST_OUTPUT=json:/home/tcwg-buildbot/worker/clang-aarch64-quick/stage1/tools/clang/tools/extra/clangd/unittests/./ClangdTests-Clangd Unit Tests-3527952-154-318.json GTEST_SHUFFLE=0 GTEST_TOTAL_SHARDS=318 GTEST_SHARD_INDEX=154 /home/tcwg-buildbot/worker/clang-aarch64-quick/stage1/tools/clang/tools/extra/clangd/unittests/./ClangdTests
--

Script:
--
/home/tcwg-buildbot/worker/clang-aarch64-quick/stage1/tools/clang/tools/extra/clangd/unittests/./ClangdTests --gtest_filter=CompletionTest.EnableSpeculativeIndexRequest
--
ASTWorker building file /clangd-test/foo.cpp version null with command 
[/clangd-test]
clang -ffreestanding /clangd-test/foo.cpp
Driver produced command: cc1 -cc1 -triple aarch64-unknown-linux-gnu -fsyntax-only -disable-free -clear-ast-before-backend -main-file-name foo.cpp -mrelocation-model pic -pic-level 2 -pic-is-pie -mframe-pointer=non-leaf -fmath-errno -ffp-contract=on -fno-rounding-math -mconstructor-aliases -ffreestanding -target-cpu generic -target-feature +v8a -target-feature +fp-armv8 -target-feature +neon -target-abi aapcs -debugger-tuning=gdb -fdebug-compilation-dir=/clangd-test -fcoverage-compilation-dir=/clangd-test -resource-dir lib/clang/20 -internal-isystem lib/clang/20/include -internal-isystem /usr/local/include -internal-externc-isystem /include -internal-externc-isystem /usr/include -fdeprecated-macro -ferror-limit 19 -fno-signed-char -fgnuc-version=4.2.1 -fskip-odr-check-in-gmf -fcxx-exceptions -fexceptions -no-round-trip-args -target-feature -fmv -faddrsig -D__GCC_HAVE_DWARF2_CFI_ASM=1 -x c++ /clangd-test/foo.cpp
Building first preamble for /clangd-test/foo.cpp version null
Built preamble of size 705748 for file /clangd-test/foo.cpp version null in 0.06 seconds
Code complete: fuzzyFind({
  "AnyScope": false,
  "Limit": null,
  "PreferredTypes": [],
  "ProximityPaths": [
    "/clangd-test/foo.cpp"
  ],
  "Query": "ab",
  "RestrictForCodeCompletion": true,
  "Scopes": [
    "ns1::"
  ]
})
Code complete: sema context Symbol, query scopes [ns1::] (AnyScope=false), expected type <none>
Code complete: 1 results from Sema, 0 from Index, 0 matched, 0 from identifiers, 1 returned (incomplete).
Ignored diagnostic. /clangd-test/foo.cpp:4:23:no member named 'ab' in namespace 'ns1'
Code complete: fuzzyFind({
  "AnyScope": false,
  "Limit": null,
  "PreferredTypes": [],
  "ProximityPaths": [
    "/clangd-test/foo.cpp"
  ],
  "Query": "ab",
  "RestrictForCodeCompletion": true,
  "Scopes": [
    "ns1::"
  ]
})
Code complete: sema context Symbol, query scopes [ns1::] (AnyScope=false), expected type <none>
Code complete: 1 results from Sema, 0 from Index, 0 matched, 0 from identifiers, 1 returned (incomplete).
Code complete: fuzzyFind({
  "AnyScope": false,
  "Limit": null,
...

@llvm-ci
Copy link
Collaborator

llvm-ci commented Dec 31, 2024

LLVM Buildbot has detected a new failure on builder sanitizer-aarch64-linux-bootstrap-msan running on sanitizer-buildbot9 while building clang at step 2 "annotate".

Full details are available at: https://lab.llvm.org/buildbot/#/builders/94/builds/3306

Here is the relevant piece of the build log for the reference
Step 2 (annotate) failure: 'python ../sanitizer_buildbot/sanitizers/zorg/buildbot/builders/sanitizers/buildbot_selector.py' (failure)
...
llvm-lit: /home/b/sanitizer-aarch64-linux-bootstrap-msan/build/llvm-project/llvm/utils/lit/lit/llvm/config.py:506: note: using lld-link: /home/b/sanitizer-aarch64-linux-bootstrap-msan/build/llvm_build_msan/bin/lld-link
llvm-lit: /home/b/sanitizer-aarch64-linux-bootstrap-msan/build/llvm-project/llvm/utils/lit/lit/llvm/config.py:506: note: using ld64.lld: /home/b/sanitizer-aarch64-linux-bootstrap-msan/build/llvm_build_msan/bin/ld64.lld
llvm-lit: /home/b/sanitizer-aarch64-linux-bootstrap-msan/build/llvm-project/llvm/utils/lit/lit/llvm/config.py:506: note: using wasm-ld: /home/b/sanitizer-aarch64-linux-bootstrap-msan/build/llvm_build_msan/bin/wasm-ld
llvm-lit: /home/b/sanitizer-aarch64-linux-bootstrap-msan/build/llvm-project/llvm/utils/lit/lit/llvm/config.py:506: note: using ld.lld: /home/b/sanitizer-aarch64-linux-bootstrap-msan/build/llvm_build_msan/bin/ld.lld
llvm-lit: /home/b/sanitizer-aarch64-linux-bootstrap-msan/build/llvm-project/llvm/utils/lit/lit/llvm/config.py:506: note: using lld-link: /home/b/sanitizer-aarch64-linux-bootstrap-msan/build/llvm_build_msan/bin/lld-link
llvm-lit: /home/b/sanitizer-aarch64-linux-bootstrap-msan/build/llvm-project/llvm/utils/lit/lit/llvm/config.py:506: note: using ld64.lld: /home/b/sanitizer-aarch64-linux-bootstrap-msan/build/llvm_build_msan/bin/ld64.lld
llvm-lit: /home/b/sanitizer-aarch64-linux-bootstrap-msan/build/llvm-project/llvm/utils/lit/lit/llvm/config.py:506: note: using wasm-ld: /home/b/sanitizer-aarch64-linux-bootstrap-msan/build/llvm_build_msan/bin/wasm-ld
llvm-lit: /home/b/sanitizer-aarch64-linux-bootstrap-msan/build/llvm-project/llvm/utils/lit/lit/main.py:72: note: The test suite configuration requested an individual test timeout of 0 seconds but a timeout of 900 seconds was requested on the command line. Forcing timeout to be 900 seconds.
-- Testing: 85660 tests, 72 workers --
Testing:  0.. 10.. 20.. 30.. 40.. 50.. 60.. 70.. 80.. 90.
FAIL: lld :: ELF/icf-comdat.s (83938 of 85660)
******************** TEST 'lld :: ELF/icf-comdat.s' FAILED ********************
Exit Code: 1

Command Output (stderr):
--
RUN: at line 3: /home/b/sanitizer-aarch64-linux-bootstrap-msan/build/llvm_build_msan/bin/llvm-mc -filetype=obj -triple=x86_64-unknown-linux /home/b/sanitizer-aarch64-linux-bootstrap-msan/build/llvm-project/lld/test/ELF/icf-comdat.s -o /home/b/sanitizer-aarch64-linux-bootstrap-msan/build/llvm_build_msan/tools/lld/test/ELF/Output/icf-comdat.s.tmp
+ /home/b/sanitizer-aarch64-linux-bootstrap-msan/build/llvm_build_msan/bin/llvm-mc -filetype=obj -triple=x86_64-unknown-linux /home/b/sanitizer-aarch64-linux-bootstrap-msan/build/llvm-project/lld/test/ELF/icf-comdat.s -o /home/b/sanitizer-aarch64-linux-bootstrap-msan/build/llvm_build_msan/tools/lld/test/ELF/Output/icf-comdat.s.tmp
RUN: at line 4: /home/b/sanitizer-aarch64-linux-bootstrap-msan/build/llvm_build_msan/bin/ld.lld /home/b/sanitizer-aarch64-linux-bootstrap-msan/build/llvm_build_msan/tools/lld/test/ELF/Output/icf-comdat.s.tmp -o /dev/null --icf=all --print-icf-sections | /home/b/sanitizer-aarch64-linux-bootstrap-msan/build/llvm_build_msan/bin/FileCheck /home/b/sanitizer-aarch64-linux-bootstrap-msan/build/llvm-project/lld/test/ELF/icf-comdat.s
+ /home/b/sanitizer-aarch64-linux-bootstrap-msan/build/llvm_build_msan/bin/ld.lld /home/b/sanitizer-aarch64-linux-bootstrap-msan/build/llvm_build_msan/tools/lld/test/ELF/Output/icf-comdat.s.tmp -o /dev/null --icf=all --print-icf-sections
+ /home/b/sanitizer-aarch64-linux-bootstrap-msan/build/llvm_build_msan/bin/FileCheck /home/b/sanitizer-aarch64-linux-bootstrap-msan/build/llvm-project/lld/test/ELF/icf-comdat.s
PLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace.
 #0 0x0000acaf403e5a00 ___interceptor_backtrace /home/b/sanitizer-aarch64-linux-bootstrap-msan/build/llvm-project/compiler-rt/lib/msan/../sanitizer_common/sanitizer_common_interceptors.inc:4497:13
 #1 0x0000acaf405d2220 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) /home/b/sanitizer-aarch64-linux-bootstrap-msan/build/llvm-project/llvm/lib/Support/Unix/Signals.inc:727:7
 #2 0x0000acaf405ccc20 llvm::sys::RunSignalHandlers() /home/b/sanitizer-aarch64-linux-bootstrap-msan/build/llvm-project/llvm/lib/Support/Signals.cpp:106:18
 #3 0x0000acaf405d332c SignalHandler(int) /home/b/sanitizer-aarch64-linux-bootstrap-msan/build/llvm-project/llvm/lib/Support/Unix/Signals.inc:413:1
 #4 0x0000acaf40416b08 ~ScopedThreadLocalStateBackup /home/b/sanitizer-aarch64-linux-bootstrap-msan/build/llvm-project/compiler-rt/lib/msan/msan.h:352:37
 #5 0x0000acaf40416b08 SignalHandler(int) /home/b/sanitizer-aarch64-linux-bootstrap-msan/build/llvm-project/compiler-rt/lib/msan/msan_interceptors.cpp:1124:1
 #6 0x0000f000115508f8 (linux-vdso.so.1+0x8f8)
 #7 0x0000f00011032f5c (/lib/aarch64-linux-gnu/libc.so.6+0xa2f5c)
 #8 0x0000acaf404244e0 __msan::SetShadow(void const*, unsigned long, unsigned char) /home/b/sanitizer-aarch64-linux-bootstrap-msan/build/llvm-project/compiler-rt/lib/msan/msan_poisoning.cpp:217:12
 #9 0x0000acaf40423730 __msan::MsanThread::ClearShadowForThreadStackAndTLS() /home/b/sanitizer-aarch64-linux-bootstrap-msan/build/llvm-project/compiler-rt/lib/msan/msan_thread.cpp:31:7
#10 0x0000acaf40423898 malloc_storage /home/b/sanitizer-aarch64-linux-bootstrap-msan/build/llvm-project/compiler-rt/lib/msan/msan_thread.h:45:59
#11 0x0000acaf40423898 __msan::MsanThread::Init() /home/b/sanitizer-aarch64-linux-bootstrap-msan/build/llvm-project/compiler-rt/lib/msan/msan_thread.cpp:45:3
#12 0x0000acaf403ca520 MsanThreadStartFunc(void*) /home/b/sanitizer-aarch64-linux-bootstrap-msan/build/llvm-project/compiler-rt/lib/msan/msan_interceptors.cpp:1156:22
#13 0x0000f0001101597c (/lib/aarch64-linux-gnu/libc.so.6+0x8597c)
#14 0x0000f0001107ba4c (/lib/aarch64-linux-gnu/libc.so.6+0xeba4c)
MemorySanitizer:DEADLYSIGNAL
==1429578==ERROR: MemorySanitizer: SEGV on unknown address 0x60000020d000 (pc 0xf00011032f5c bp 0xf0000020d3e0 sp 0xf0000020d380 T1429879)
==1429578==The signal is caused by a WRITE memory access.
    #0 0xf00011032f5c  (/lib/aarch64-linux-gnu/libc.so.6+0xa2f5c) (BuildId: 32fa4d6f3a8d5f430bdb7af2eb779470cd5ec7c2)
    #1 0xacaf404244dc in __msan::SetShadow(void const*, unsigned long, unsigned char) /home/b/sanitizer-aarch64-linux-bootstrap-msan/build/llvm-project/compiler-rt/lib/msan/msan_poisoning.cpp:215:9
    #2 0xacaf4042372c in __msan::MsanThread::ClearShadowForThreadStackAndTLS() /home/b/sanitizer-aarch64-linux-bootstrap-msan/build/llvm-project/compiler-rt/lib/msan/msan_thread.cpp:30:3
    #3 0xacaf40423894 in __msan::MsanThread::Init() /home/b/sanitizer-aarch64-linux-bootstrap-msan/build/llvm-project/compiler-rt/lib/msan/msan_thread.cpp:44:3
    #4 0xacaf403ca51c in MsanThreadStartFunc(void*) /home/b/sanitizer-aarch64-linux-bootstrap-msan/build/llvm-project/compiler-rt/lib/msan/msan_interceptors.cpp:1155:6
    #5 0xf00011015978  (/lib/aarch64-linux-gnu/libc.so.6+0x85978) (BuildId: 32fa4d6f3a8d5f430bdb7af2eb779470cd5ec7c2)
    #6 0xf0001107ba48  (/lib/aarch64-linux-gnu/libc.so.6+0xeba48) (BuildId: 32fa4d6f3a8d5f430bdb7af2eb779470cd5ec7c2)

==1429578==Register values:
Step 11 (stage2/msan check) failure: stage2/msan check (failure)
...
llvm-lit: /home/b/sanitizer-aarch64-linux-bootstrap-msan/build/llvm-project/llvm/utils/lit/lit/llvm/config.py:506: note: using lld-link: /home/b/sanitizer-aarch64-linux-bootstrap-msan/build/llvm_build_msan/bin/lld-link
llvm-lit: /home/b/sanitizer-aarch64-linux-bootstrap-msan/build/llvm-project/llvm/utils/lit/lit/llvm/config.py:506: note: using ld64.lld: /home/b/sanitizer-aarch64-linux-bootstrap-msan/build/llvm_build_msan/bin/ld64.lld
llvm-lit: /home/b/sanitizer-aarch64-linux-bootstrap-msan/build/llvm-project/llvm/utils/lit/lit/llvm/config.py:506: note: using wasm-ld: /home/b/sanitizer-aarch64-linux-bootstrap-msan/build/llvm_build_msan/bin/wasm-ld
llvm-lit: /home/b/sanitizer-aarch64-linux-bootstrap-msan/build/llvm-project/llvm/utils/lit/lit/llvm/config.py:506: note: using ld.lld: /home/b/sanitizer-aarch64-linux-bootstrap-msan/build/llvm_build_msan/bin/ld.lld
llvm-lit: /home/b/sanitizer-aarch64-linux-bootstrap-msan/build/llvm-project/llvm/utils/lit/lit/llvm/config.py:506: note: using lld-link: /home/b/sanitizer-aarch64-linux-bootstrap-msan/build/llvm_build_msan/bin/lld-link
llvm-lit: /home/b/sanitizer-aarch64-linux-bootstrap-msan/build/llvm-project/llvm/utils/lit/lit/llvm/config.py:506: note: using ld64.lld: /home/b/sanitizer-aarch64-linux-bootstrap-msan/build/llvm_build_msan/bin/ld64.lld
llvm-lit: /home/b/sanitizer-aarch64-linux-bootstrap-msan/build/llvm-project/llvm/utils/lit/lit/llvm/config.py:506: note: using wasm-ld: /home/b/sanitizer-aarch64-linux-bootstrap-msan/build/llvm_build_msan/bin/wasm-ld
llvm-lit: /home/b/sanitizer-aarch64-linux-bootstrap-msan/build/llvm-project/llvm/utils/lit/lit/main.py:72: note: The test suite configuration requested an individual test timeout of 0 seconds but a timeout of 900 seconds was requested on the command line. Forcing timeout to be 900 seconds.
-- Testing: 85660 tests, 72 workers --
Testing:  0.. 10.. 20.. 30.. 40.. 50.. 60.. 70.. 80.. 90.
FAIL: lld :: ELF/icf-comdat.s (83938 of 85660)
******************** TEST 'lld :: ELF/icf-comdat.s' FAILED ********************
Exit Code: 1

Command Output (stderr):
--
RUN: at line 3: /home/b/sanitizer-aarch64-linux-bootstrap-msan/build/llvm_build_msan/bin/llvm-mc -filetype=obj -triple=x86_64-unknown-linux /home/b/sanitizer-aarch64-linux-bootstrap-msan/build/llvm-project/lld/test/ELF/icf-comdat.s -o /home/b/sanitizer-aarch64-linux-bootstrap-msan/build/llvm_build_msan/tools/lld/test/ELF/Output/icf-comdat.s.tmp
+ /home/b/sanitizer-aarch64-linux-bootstrap-msan/build/llvm_build_msan/bin/llvm-mc -filetype=obj -triple=x86_64-unknown-linux /home/b/sanitizer-aarch64-linux-bootstrap-msan/build/llvm-project/lld/test/ELF/icf-comdat.s -o /home/b/sanitizer-aarch64-linux-bootstrap-msan/build/llvm_build_msan/tools/lld/test/ELF/Output/icf-comdat.s.tmp
RUN: at line 4: /home/b/sanitizer-aarch64-linux-bootstrap-msan/build/llvm_build_msan/bin/ld.lld /home/b/sanitizer-aarch64-linux-bootstrap-msan/build/llvm_build_msan/tools/lld/test/ELF/Output/icf-comdat.s.tmp -o /dev/null --icf=all --print-icf-sections | /home/b/sanitizer-aarch64-linux-bootstrap-msan/build/llvm_build_msan/bin/FileCheck /home/b/sanitizer-aarch64-linux-bootstrap-msan/build/llvm-project/lld/test/ELF/icf-comdat.s
+ /home/b/sanitizer-aarch64-linux-bootstrap-msan/build/llvm_build_msan/bin/ld.lld /home/b/sanitizer-aarch64-linux-bootstrap-msan/build/llvm_build_msan/tools/lld/test/ELF/Output/icf-comdat.s.tmp -o /dev/null --icf=all --print-icf-sections
+ /home/b/sanitizer-aarch64-linux-bootstrap-msan/build/llvm_build_msan/bin/FileCheck /home/b/sanitizer-aarch64-linux-bootstrap-msan/build/llvm-project/lld/test/ELF/icf-comdat.s
PLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace.
 #0 0x0000acaf403e5a00 ___interceptor_backtrace /home/b/sanitizer-aarch64-linux-bootstrap-msan/build/llvm-project/compiler-rt/lib/msan/../sanitizer_common/sanitizer_common_interceptors.inc:4497:13
 #1 0x0000acaf405d2220 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) /home/b/sanitizer-aarch64-linux-bootstrap-msan/build/llvm-project/llvm/lib/Support/Unix/Signals.inc:727:7
 #2 0x0000acaf405ccc20 llvm::sys::RunSignalHandlers() /home/b/sanitizer-aarch64-linux-bootstrap-msan/build/llvm-project/llvm/lib/Support/Signals.cpp:106:18
 #3 0x0000acaf405d332c SignalHandler(int) /home/b/sanitizer-aarch64-linux-bootstrap-msan/build/llvm-project/llvm/lib/Support/Unix/Signals.inc:413:1
 #4 0x0000acaf40416b08 ~ScopedThreadLocalStateBackup /home/b/sanitizer-aarch64-linux-bootstrap-msan/build/llvm-project/compiler-rt/lib/msan/msan.h:352:37
 #5 0x0000acaf40416b08 SignalHandler(int) /home/b/sanitizer-aarch64-linux-bootstrap-msan/build/llvm-project/compiler-rt/lib/msan/msan_interceptors.cpp:1124:1
 #6 0x0000f000115508f8 (linux-vdso.so.1+0x8f8)
 #7 0x0000f00011032f5c (/lib/aarch64-linux-gnu/libc.so.6+0xa2f5c)
 #8 0x0000acaf404244e0 __msan::SetShadow(void const*, unsigned long, unsigned char) /home/b/sanitizer-aarch64-linux-bootstrap-msan/build/llvm-project/compiler-rt/lib/msan/msan_poisoning.cpp:217:12
 #9 0x0000acaf40423730 __msan::MsanThread::ClearShadowForThreadStackAndTLS() /home/b/sanitizer-aarch64-linux-bootstrap-msan/build/llvm-project/compiler-rt/lib/msan/msan_thread.cpp:31:7
#10 0x0000acaf40423898 malloc_storage /home/b/sanitizer-aarch64-linux-bootstrap-msan/build/llvm-project/compiler-rt/lib/msan/msan_thread.h:45:59
#11 0x0000acaf40423898 __msan::MsanThread::Init() /home/b/sanitizer-aarch64-linux-bootstrap-msan/build/llvm-project/compiler-rt/lib/msan/msan_thread.cpp:45:3
#12 0x0000acaf403ca520 MsanThreadStartFunc(void*) /home/b/sanitizer-aarch64-linux-bootstrap-msan/build/llvm-project/compiler-rt/lib/msan/msan_interceptors.cpp:1156:22
#13 0x0000f0001101597c (/lib/aarch64-linux-gnu/libc.so.6+0x8597c)
#14 0x0000f0001107ba4c (/lib/aarch64-linux-gnu/libc.so.6+0xeba4c)
MemorySanitizer:DEADLYSIGNAL
==1429578==ERROR: MemorySanitizer: SEGV on unknown address 0x60000020d000 (pc 0xf00011032f5c bp 0xf0000020d3e0 sp 0xf0000020d380 T1429879)
==1429578==The signal is caused by a WRITE memory access.
    #0 0xf00011032f5c  (/lib/aarch64-linux-gnu/libc.so.6+0xa2f5c) (BuildId: 32fa4d6f3a8d5f430bdb7af2eb779470cd5ec7c2)
    #1 0xacaf404244dc in __msan::SetShadow(void const*, unsigned long, unsigned char) /home/b/sanitizer-aarch64-linux-bootstrap-msan/build/llvm-project/compiler-rt/lib/msan/msan_poisoning.cpp:215:9
    #2 0xacaf4042372c in __msan::MsanThread::ClearShadowForThreadStackAndTLS() /home/b/sanitizer-aarch64-linux-bootstrap-msan/build/llvm-project/compiler-rt/lib/msan/msan_thread.cpp:30:3
    #3 0xacaf40423894 in __msan::MsanThread::Init() /home/b/sanitizer-aarch64-linux-bootstrap-msan/build/llvm-project/compiler-rt/lib/msan/msan_thread.cpp:44:3
    #4 0xacaf403ca51c in MsanThreadStartFunc(void*) /home/b/sanitizer-aarch64-linux-bootstrap-msan/build/llvm-project/compiler-rt/lib/msan/msan_interceptors.cpp:1155:6
    #5 0xf00011015978  (/lib/aarch64-linux-gnu/libc.so.6+0x85978) (BuildId: 32fa4d6f3a8d5f430bdb7af2eb779470cd5ec7c2)
    #6 0xf0001107ba48  (/lib/aarch64-linux-gnu/libc.so.6+0xeba48) (BuildId: 32fa4d6f3a8d5f430bdb7af2eb779470cd5ec7c2)

==1429578==Register values:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
clang:frontend Language frontend issues, e.g. anything involving "Sema" clang:modules C++20 modules and Clang Header Modules clang Clang issues not falling into any other category
Projects
None yet
Development

Successfully merging this pull request may close these issues.

C++ modules appear to be exceedignly strict with intrinsic headers
4 participants