<table border="1" cellspacing="0" cellpadding="8">
    <tr>
        <th>Issue</th>
        <td>
            <a href=https://github.com/llvm/llvm-project/issues/84482>84482</a>
        </td>
    </tr>

    <tr>
        <th>Summary</th>
        <td>
            msan tests FAIL on FreeBSD 14/amd64
        </td>
    </tr>

    <tr>
      <th>Labels</th>
      <td>
            compiler-rt:msan,
            platform:freebsd
      </td>
    </tr>

    <tr>
      <th>Assignees</th>
      <td>
      </td>
    </tr>

    <tr>
      <th>Reporter</th>
      <td>
          rorth
      </td>
    </tr>
</table>

<pre>
    When trying to build LLVM 18.1.0 on FreeBSD 14.0/amd64 with `test-release.sh`, the failure of two msan tests badly broke `llvm-lit`s summary of the test results for the complete `ninja check-all`.
```
FAIL: MemorySanitizer-Unit :: ./Msan-x86_64-Test/5/9 (77408 of 97112)
FAIL: MemorySanitizer-Unit :: ./Msan-x86_64-with-call-Test/5/9 (77455 of 97112)
```
The primary problem with those failures is that both tests produce 0-byte `*.json` files, which cause `llvm-lit` to throw an exception and abort summarizing the run (will report that separately).

For both tests, the log shows
```
[...]
[ RUN      ] MemorySanitizer.m128
[       OK ] MemorySanitizer.m128 (0 ms)
[ RUN      ] MemorySanitizer.dlopenFailed
MemorySanitizer:DEADLYSIGNAL
==87117==ERROR: MemorySanitizer: SEGV on unknown address 0x000000000038 (pc 0x0000002ea290 bp 0x7fffffffe0b0 sp 0x7fffffffe020 T144217)
==87117==The signal is caused by a READ memory access.
==87117==Hint: address points to the zero page.
 #0 0x2ea290 in __sanitizer::ForEachMappedRegion(link_map*, void (*)(void const*, unsigned long)) /var/llvm/reltest/llvm-18.1.0/final/llvm-project/compiler-rt/lib/sanitizer_common/sanitizer_linux.cpp:1238:35
 #1 0x329424 in dlopen /var/llvm/reltest/llvm-18.1.0/final/llvm-project/compiler-rt/lib/msan/../sanitizer_common/sanitizer_common_interceptors.inc:6343:3
 #2 0x4910b0 in MemorySanitizer_dlopenFailed_Test::TestBody() /var/llvm/reltest/llvm-18.1.0/final/llvm-project/compiler-rt/lib/msan/tests/msan_test.cpp:3238:15
 #3 0x6901bc in void testing::internal::HandleSehExceptionsInMethodIfSupported<testing::Test, void>(testing::Test*, void (testing::Test::*)(), char const*) /var/llvm/reltest/llvm-18.1.0/final/llvm-project/runtimes/../third-party/unittest/googletest/src/gtest.cc:2612:10
 #4 0x6901bc in void testing::internal::HandleExceptionsInMethodIfSupported<testing::Test, void>(testing::Test*, void (testing::Test::*)(), char const*) /var/llvm/reltest/llvm-18.1.0/final/llvm-project/runtimes/../third-party/unittest/googletest/src/gtest.cc:2648:14
 #5 0x68fc8c in testing::Test::Run() /var/llvm/reltest/llvm-18.1.0/final/llvm-project/runtimes/../third-party/unittest/googletest/src/gtest.cc:2687:5
 #6 0x6974ab in testing::TestInfo::Run() /var/llvm/reltest/llvm-18.1.0/final/llvm-project/runtimes/../third-party/unittest/googletest/src/gtest.cc:2836:11
 #7 0x69cbe6 in testing::TestSuite::Run() /var/llvm/reltest/llvm-18.1.0/final/llvm-project/runtimes/../third-party/unittest/googletest/src/gtest.cc:3015:30
 #8 0x6fcd21 in testing::internal::UnitTestImpl::RunAllTests() /var/llvm/reltest/llvm-18.1.0/final/llvm-project/runtimes/../third-party/unittest/googletest/src/gtest.cc:5920:44
 #9 0x6fa85b in bool testing::internal::HandleSehExceptionsInMethodIfSupported<testing::internal::UnitTestImpl, bool>(testing::internal::UnitTestImpl*, bool (testing::internal::UnitTestImpl::*)(), char const*) /var/llvm/reltest/llvm-18.1.0/final/llvm-project/runtimes/../third-party/unittest/googletest/src/gtest.cc:2612:10
 #10 0x6fa85b in bool testing::internal::HandleExceptionsInMethodIfSupported<testing::internal::UnitTestImpl, bool>(testing::internal::UnitTestImpl*, bool (testing::internal::UnitTestImpl::*)(), char const*) /var/llvm/reltest/llvm-18.1.0/final/llvm-project/runtimes/../third-party/unittest/googletest/src/gtest.cc:2648:14
 #11 0x6f9f2e in testing::UnitTest::Run() /var/llvm/reltest/llvm-18.1.0/final/llvm-project/runtimes/../third-party/unittest/googletest/src/gtest.cc:5484:10
 #12 0x603e4b in RUN_ALL_TESTS() /var/llvm/reltest/llvm-18.1.0/final/llvm-project/runtimes/../third-party/unittest/googletest/include/gtest/gtest.h:2317:73
 #13 0x603e4b in main /var/llvm/reltest/llvm-18.1.0/final/llvm-project/compiler-rt/lib/msan/tests/msan_test_main.cpp:19:10
 #14 0x800b7faf9 in __libc_start1 /usr/src/lib/libc/csu/libc_start1.c:157:7
    #15 0x2df13f in _start /usr/src/lib/csu/amd64/crt1_s.S:83

MemorySanitizer can not provide additional info.
SUMMARY: MemorySanitizer: SEGV /var/llvm/reltest/llvm-18.1.0/final/llvm-project/runtimes/../third-party/unittest/googletest/src/gtest.cc:2612:10 in void testing::internal::HandleSehExceptionsInMethodIfSupported<testing::Test, void>(testing::Test*, void (testing::Test::*)(), char const*)
==87117==ABORTING

--
exit: 1
--
shard JSON output does not exist: /var/llvm/reltest/llvm-18.1.0/final/Phase3/Release/llvmCore-18.1.0-final.obj/runtimes/runtimes-bins/compiler-rt/lib/msan/tests/./Msan-x86_64-with-call-Test-MemorySanitizer-Unit-37844-5-9.json
```
To allow making any progress with the build/test at all, I've disabled msan on FreeBSD wholesale:
```
-- compiler-rt/cmake/config-ix.cmake.dist       2024-02-27 18:18:54.000000000 +0100
+++ compiler-rt/cmake/config-ix.cmake   2024-03-08 10:13:59.131220000 +0100
@@ -774,7 +774,7 @@ if (COMPILER_RT_HAS_SANITIZER_COMMON AND MSAN_SUPPORTE
 endif()
 
 if (COMPILER_RT_HAS_SANITIZER_COMMON AND MSAN_SUPPORTED_ARCH AND
-    OS_NAME MATCHES "Linux|FreeBSD|NetBSD")
+    OS_NAME MATCHES "Linux|NetBSD")
 set(COMPILER_RT_HAS_MSAN TRUE)
 else()
   set(COMPILER_RT_HAS_MSAN FALSE)
```
Just a hack, of course, but the alternative is worse (@DimitryAndric, @brooksdavis).
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJzsWVtz4yoS_jXkhZIKo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