<table border="1" cellspacing="0" cellpadding="8">
    <tr>
        <th>Issue</th>
        <td>
            <a href=http://email.email.llvm.org/c/eJylVU1v4zYQ_TXyZRBBpj4sH3ywo7jYIkWLxLt7NChxZLOhSYGknKS_vkN6HW0WCVCggkCTQ82bNzOPdGvE6yqpst3RIhcNus7KwRv7KP9BMoPUQD9Kto5r6cloE7Z9m-87czoZ_c6kpB5faGw7gUPaDUOA6UZrUXv1CkduRWcEOvBHBEcuYPoQw3k7dh4GH5mQIQV49Nx6qQ_wLP0RDgEUWJoXwLUgf-kgEJA-yddJ1iTZdczvfmxAj32RZZz1y0Ul5r2oeFHlS6yWddZXXZkhzvO-7cvJcT36o7GECFtlrOQavqM8oYUkv-2f4zQpMoviyH1KUchncm64x-AK8IfR8PuogdUwL8iU5zSUObCMzSFhm4xl2eQ3zUAPXgWIu5fBWA-U86Uie9HejA4FuNdTa5SDUQti9dv9l83t_q-HL9_Wu5-I0DMtdqFSXCnz7EBIKrRsRy-Nph4YCMsBBLbj4RBKLXVv7ImHfegt5TdhhvqnzqRV7IcZPcjTwLvYodDNCQRfBrQSdYfpJ5zgAc8Sn1HctK8h3VtulXHwZ8IWjdGoVKh3F42flDuO1GLKbTDOyVZhyEegR3uSGqOoSF9BXqz-RV5sGWQ5ukCWZkLRJ2eyUnFpmbBbSvYJo8YmcdHG5Y1LII1p56kPTh40NUZqT5HWQxR1kjcg1Dngsfphd9_sm7vt-uv9LmAnjO3furq_kNy_UWP0yTXEf3jI4b0IAsAyyTdXDBkL8IMWmwdmelRq8HSWl5AsNlOwM1eR-TWNn1AAuDcn2e0dXQ-4t6j4CxLbOmHVNZe36yPmFDIlwPdkACz60eq4M5mTRfNhkS_j49gdgUN35PqA8GxGJWCweKYrBVoK_cTJLD--RsIVdrk5Lu4unYlVLpb5ks94POur02AU7_BpNlq1Ono_xJ6zLb0HEvrYRuGxrVLn68_NYM3f2HlaSudGdDQp2bJezo4rlhULNi8WPK_KuuoLnrc15201r0VdCixmireo3CopN0nZzP5_SEkhGcvmWTEvy7xYpG1dCFYTDWQFX1QLOkF44lKlASc19jCzqwhJ5zUcL0WXgps2uYuKxitDL72Ki3f_A2UDXx3Cp0IOhf_ob2UW2a8i9X8BV2wFbA>52989</a>
        </td>
    </tr>

    <tr>
        <th>Summary</th>
        <td>
            [libsanitizer] Use _thread_db_sizeof_pthread in ThreadDescriptorSize
        </td>
    </tr>

    <tr>
      <th>Labels</th>
      <td>
      </td>
    </tr>

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

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

<pre>
    `ThreadDescriptorSize` in `libsanitizer/sanitizer_common/sanitizer_linux_libcdep.cpp` currently hardcodes the size of `struct pthread`.  Starting with glibc 2.34 and this commit:

> commit fef400a2f976d1fd6a4639e6980f6c50ee13fbf5
> Author: Florian Weimer <fweimer@redhat.com>
> Date:   Mon Jun 28 14:33:53 2021 +0200

>  nptl: Export libthread_db-used symbols under GLIBC_PRIVATE
>    
> This allows distributions to strip debugging information from
>  libc.so.6 without impacting the debugging experience.
>    
>  Reviewed-by: Carlos O'Donell <carlos@redhat.com>

it is possible to determine `sizeof (struct pthread)` using `dl(v)sym`, like this:
```
  const unsigned int *psize = dlvsym(RTLD_DEFAULT, "_thread_db_sizeof_pthread",
                                     "GLIBC_PRIVATE");
  if (psize != nullptr) {
    val = *psize;
    atomic_store_relaxed(&thread_descriptor_size, val);
    return val;
  }
```

Such a change would prevent breakage if `struct pthread` in glibc changes.
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJyNVNFu6zYM_RrnhajhyHYSP-QhaZrhDh02tLnbYyBbdKxVlgxJTtp9_Sjlpr4dWmCGIUuUeXRIHrE24m2dLLJDZ5GLHbrGysEb-yz_QTKD1EAfJWvHtfRktAnbv8-Pjel7oz-YlNTjK411I3BIm2EIMM1oLWqv3qDjVjRGoAPfIThyAdOGM5y3Y-Nh8JEJGVKAZ8-tl_oEF-k7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