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

    <tr>
        <th>Summary</th>
        <td>
            [libc] __support.File.platform_file_test.__unit__ fails
        </td>
    </tr>

    <tr>
      <th>Labels</th>
      <td>
            new issue
      </td>
    </tr>

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

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

<pre>
    Using git-bisect the following commit introduced the issue: https://github.com/llvm/llvm-project/commit/a09bec6459331e7f949c2ed3df6102de52d25f5d

```
[ RUN      ] LlvmLibcPlatformFileTest.CreateWriteCloseAndReadBack
[       OK ] LlvmLibcPlatformFileTest.CreateWriteCloseAndReadBack (took 0 ms)
[ RUN      ] LlvmLibcPlatformFileTest.CreateWriteSeekAndReadBack
[       OK ] LlvmLibcPlatformFileTest.CreateWriteSeekAndReadBack (took 0 ms)
[ RUN      ] LlvmLibcPlatformFileTest.CreateAppendCloseAndReadBack
[       OK ] LlvmLibcPlatformFileTest.CreateAppendCloseAndReadBack (took 0 ms)
[ RUN      ] LlvmLibcPlatformFileTest.CreateAppendSeekAndReadBack
[       OK ] LlvmLibcPlatformFileTest.CreateAppendSeekAndReadBack (took 0 ms)
[ RUN      ] LlvmLibcPlatformFileTest.LargeFile
[       OK ] LlvmLibcPlatformFileTest.LargeFile (took 0 ms)
[ RUN      ] LlvmLibcPlatformFileTest.ReadSeekCurAndRead
[       OK ] LlvmLibcPlatformFileTest.ReadSeekCurAndRead (took 0 ms)
[ RUN      ] LlvmLibcPlatformFileTest.IncorrectOperation
[       OK ] LlvmLibcPlatformFileTest.IncorrectOperation (took 0 ms)
[ RUN      ] LlvmLibcPlatformFileTest.StdOutStdErrSmokeTest
[       OK ] LlvmLibcPlatformFileTest.StdOutStdErrSmokeTest (took 0 ms)
Ran 8 tests.  PASS: 8  FAIL: 0
zsh: segmentation fault (core dumped)  
```

bt:
```
gef➤  bt
#0  0x00007ffff7a96857 in fflush () from /usr/lib64/libc.so.6
#1  0x00007ffff7d43d22 in std::basic_ostream<char, std::char_traits<char> >::flush() () from /usr/lib/gcc/x86_64-pc-linux-gnu/13/libstdc++.so.6
#2  0x00007ffff7cc5e8e in std::ios_base::Init::~Init() () from /usr/lib/gcc/x86_64-pc-linux-gnu/13/libstdc++.so.6
#3  0x00007ffff7a5ff71 in __cxa_finalize () from /usr/lib64/libc.so.6
#4  0x00007ffff7cb01b3 in ?? () from /usr/lib/gcc/x86_64-pc-linux-gnu/13/libstdc++.so.6
#5  0x00007ffff7fa7040 in ?? ()
#6  0x00007ffff7fcc0e2 in _dl_call_fini (closure_map=0x7fffffffdd20, closure_map@entry=0x7ffff7fa7040) at dl-call_fini.c:43
#7  0x00007ffff7fcfe9d in _dl_fini () at dl-fini.c:114
#8  0x00007ffff7a60505 in ?? () from /usr/lib64/libc.so.6
#9  0x00007ffff7a6065a in exit () from /usr/lib64/libc.so.6
#10 0x00007ffff7a489d1 in ?? () from /usr/lib64/libc.so.6
#11 0x00007ffff7a48a85 in __libc_start_main () from /usr/lib64/libc.so.6
#12 0x000055555555bc91 in _start ()
```

Configuration:
```
export SYSROOT="./sysroot"

cmake ../llvm  \
   -G Ninja  \
   -DLLVM_ENABLE_PROJECTS="clang;libc;lld;compiler-rt"   \
   -DCMAKE_BUILD_TYPE=Debug  \
   -DCMAKE_C_COMPILER=clang \
   -DCMAKE_CXX_COMPILER=clang++ \
   -DCMAKE_C_FLAGS="--no-default-config" \
   -DCMAKE_CXX_FLAGS="--no-default-config" \
   -DLLVM_LIBC_FULL_BUILD=ON \
   -DLLVM_LIBC_INCLUDE_SCUDO=ON \
   -DCOMPILER_RT_BUILD_SCUDO_STANDALONE_WITH_LLVM_LIBC=ON \
   -DCOMPILER_RT_BUILD_GWP_ASAN=OFF                       \
   -DCOMPILER_RT_SCUDO_STANDALONE_BUILD_SHARED=OFF        \
   -DCLANG_DEFAULT_LINKER=lld \
   -DCLANG_DEFAULT_RTLIB=compiler-rt \
   -DDEFAULT_SYSROOT=$SYSROOT \
   -DCMAKE_INSTALL_PREFIX=$SYSROOT
```
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJy0l12Torgexj9NvElpQQIoF16gQK9nGO1S-8zsVSokQbMdwCJht2cuzmc_FaTt0ba3xukeyhJCHn55_nkP1VruKiGmwJ8BPx7Q1uzrZkpV0Qhe1IO85t-mD1pWO7iTZphLLZiBZi9gUStV_2MzWF2W0kBZmabmLRO8y5datwLgCO6NOWiAI4BSgNKdNPs2H7G6BChV6u_n2_DQ1H8JZgBKjzyAUuqEuWCB54cYu2JchF7IkOCYF4HrIC58xJFf-Bw4MXCi_j9w-t8x6c_g-mEJuwv4MczU32Umc3avqCnqpkylEluhzWjeCGrEl0YaMVe1FlHF14LyGWWPL6jjtfr0yygI0MTU9SN0YKkBCt_hciPE48eYvCB9jMfocBAV_5iqvM76SJ8fUplXUe91mdFmJ2zqVk-nD9_rwEZig5q3TR_XrVZeE97raVGxumkEM6uDaKiRdXWrp9eE93raGL5qzcbwpGk2Zf3Yvb3V1lXIdWdrWsEJNEIbPYLwPtps7HQ7gTCNFpl97OfA73pvU1rsSlGZY6gFbVWHZXUjIG_Lg-AAhRBen0W7_9zYWfxa_k4UIEEgTEDkQZg_B42wA6Hz5DiOMy6KohjTMJj4YygrWBSq1XtrwJZaNHUJAUpb3djlQOaBd7yzka5HwQnnnuO4hzlCFqcNt95wlFMtGam1aQQtAZ6zPW0Amr8I7AtiGiqNfs7GCQQ4OWZ3tnpXb5mzqxhjAKVPk4AE3vDAhkpW7dNwV7UApS4-yrThDKAZQLPzINB5EIz5YiLOgpC1JjnV4phaVNIcn_7XPf5Wc_iiwfyiGLvWHCHsiZJCVlTJ7-LWhvMuYs4dN8cWC3AKcPq7ovHPiy3o2PGcV8We5MGFnDFHdN2LcEUYVcrGL7tRo2rdNoKU9ABw7Dx1HxRFwTlybHf7Md9zRGWa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