<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" "http://www.w3.org/TR/REC-html40/loose.dtd">
<html lang="en">
<head>
<meta content="text/html; charset=US-ASCII" http-equiv="Content-Type">
<title>
GitLab
</title>

<style data-premailer="ignore" type="text/css">
a { color: #1068bf; }
</style>

<style>img {
max-width: 100%; height: auto;
}
body {
font-size: 0.875rem;
}
body {
-webkit-text-shadow: rgba(255,255,255,0.01) 0 0 1px;
}
body {
font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Noto Sans", Ubuntu, Cantarell, "Helvetica Neue", sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji"; font-size: inherit;
}
</style>
</head>
<body style='font-size: inherit; -webkit-text-shadow: rgba(255,255,255,0.01) 0 0 1px; font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Noto Sans", Ubuntu, Cantarell, "Helvetica Neue", sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji";'>
<div class="content">

<p style="color: #777777;">
<a href="https://gitlab.com/cybear" style="color: #1068bf;">Bjørn Christensen</a>
commented on a
<a href="https://gitlab.com/gnutls/gnutls/-/issues/1380#note_1004078015" style="color: #1068bf;">discussion</a>:
</p>
<div class="md" style="color: #303030; word-wrap: break-word;">
<p dir="auto" style="color: #303030; margin: 0 0 16px;" align="initial">Good point Daiki,</p>
<p dir="auto" style="color: #303030; margin: 0 0 16px;" align="initial">And if I change the __declspec(thread) to __thread my sample program works.</p>
<p dir="auto" style="color: #303030; margin: 0 0 16px;" align="initial">When I examined the crash I looked at the disassembly and I could not see that the access to rnd_initialized was guarded.</p>
<div class="gl-relative markdown-code-block js-markdown-code">
<pre class="code highlight js-syntax-highlight language-plaintext" lang="plaintext" data-canonical-lang="" v-pre="true" style='display: block; font-size: 13px; color: #303030; line-height: 1.6em; overflow-x: auto; border-radius: 2px; position: relative; font-family: "Menlo", "DejaVu Sans Mono", "Liberation Mono", "Consolas", "Ubuntu Mono", "Courier New", "andale mono", "lucida console", monospace; word-break: break-all; word-wrap: break-word; background-color: #fafafa; margin: 0 0 16px; padding: 12px; border: 1px solid #dbdbdb;'><code style='font-size: inherit; color: inherit; word-wrap: normal; word-break: keep-all; background-color: inherit; border-radius: 4px; white-space: pre; margin-top: 0; font-family: "Menlo", "DejaVu Sans Mono", "Liberation Mono", "Consolas", "Ubuntu Mono", "Courier New", "andale mono", "lucida console", monospace; overflow-wrap: normal; padding: unset;'><span id="LC1" class="line" lang="plaintext" style="margin-top: 0;">          00000000773B165A  mov         qword ptr [rbp-8],0 </span>
<span id="LC2" class="line" lang="plaintext"></span>
<span id="LC3" class="line" lang="plaintext">          00000000773B1662  mov         rax,qword ptr [rbp-10h] </span>
<span id="LC4" class="line" lang="plaintext"></span>
<span id="LC5" class="line" lang="plaintext">          00000000773B1666  mov         qword ptr [rbp-8],rax </span></code></pre>
<copy-code></copy-code>
</div>
<p dir="auto" style="color: #303030; margin: 0 0 16px;" align="initial">L3:           00000000773B166A  cmp         qword ptr [rbp-8],0                                 // 131</p>
<div class="gl-relative markdown-code-block js-markdown-code">
<pre class="code highlight js-syntax-highlight language-plaintext" lang="plaintext" data-canonical-lang="" v-pre="true" style='display: block; font-size: 13px; color: #303030; line-height: 1.6em; overflow-x: auto; border-radius: 2px; position: relative; font-family: "Menlo", "DejaVu Sans Mono", "Liberation Mono", "Consolas", "Ubuntu Mono", "Courier New", "andale mono", "lucida console", monospace; word-break: break-all; word-wrap: break-word; background-color: #fafafa; margin: 0 0 16px; padding: 12px; border: 1px solid #dbdbdb;'><code style='font-size: inherit; color: inherit; word-wrap: normal; word-break: keep-all; background-color: inherit; border-radius: 4px; white-space: pre; margin-top: 0; font-family: "Menlo", "DejaVu Sans Mono", "Liberation Mono", "Consolas", "Ubuntu Mono", "Courier New", "andale mono", "lucida console", monospace; overflow-wrap: normal; padding: unset;'><span id="LC1" class="line" lang="plaintext" style="margin-top: 0;">          00000000773B166F  jne         _gnutls_rnd_deinit+25h (0773B1624h) L2              // 131</span>
<span id="LC2" class="line" lang="plaintext"></span>
<span id="LC3" class="line" lang="plaintext">          00000000773B1671  mov         qword ptr [head (077618568h)],0 </span></code></pre>
<copy-code></copy-code>
</div>
<p dir="auto" style="color: #303030; margin: 0 0 16px;" align="initial">L1:           00000000773B167C  lea         rcx,[gnutls_mutex_unlock+8h (077551380h)]</p>
<div class="gl-relative markdown-code-block js-markdown-code">
<pre class="code highlight js-syntax-highlight language-plaintext" lang="plaintext" data-canonical-lang="" v-pre="true" style='display: block; font-size: 13px; color: #303030; line-height: 1.6em; overflow-x: auto; border-radius: 2px; position: relative; font-family: "Menlo", "DejaVu Sans Mono", "Liberation Mono", "Consolas", "Ubuntu Mono", "Courier New", "andale mono", "lucida console", monospace; word-break: break-all; word-wrap: break-word; background-color: #fafafa; margin: 0 0 16px; padding: 12px; border: 1px solid #dbdbdb;'><code style='font-size: inherit; color: inherit; word-wrap: normal; word-break: keep-all; background-color: inherit; border-radius: 4px; white-space: pre; margin-top: 0; font-family: "Menlo", "DejaVu Sans Mono", "Liberation Mono", "Consolas", "Ubuntu Mono", "Courier New", "andale mono", "lucida console", monospace; overflow-wrap: normal; padding: unset;'><span id="LC1" class="line" lang="plaintext" style="margin-top: 0;">          00000000773B1683  call        _fpreset+190h (07754A420h)    </span>
<span id="LC2" class="line" lang="plaintext"></span>
<span id="LC3" class="line" lang="plaintext">          00000000773B1688  mov         dword ptr [rax],0 </span>
<span id="LC4" class="line" lang="plaintext"></span>
<span id="LC5" class="line" lang="plaintext">          00000000773B168E  call        _rnd_system_entropy_deinit (07748BCB2h) </span>
<span id="LC6" class="line" lang="plaintext"></span>
<span id="LC7" class="line" lang="plaintext">          00000000773B1693  nop </span>
<span id="LC8" class="line" lang="plaintext"></span>
<span id="LC9" class="line" lang="plaintext">          00000000773B1694  add         rsp,30h </span>
<span id="LC10" class="line" lang="plaintext"></span>
<span id="LC11" class="line" lang="plaintext">          00000000773B1698  pop         rbp </span></code></pre>
<copy-code></copy-code>
</div>
<p dir="auto" style="color: #303030; margin: 0 0 16px;" align="initial">Maybe the call to _fpreset+0x190 is the setup of TLS memory.</p>
<p dir="auto" style="color: #303030; margin: 0 0 16px;" align="initial">Thanks for the help I will investigate a bit further.</p>
<p dir="auto" style="color: #303030; margin: 0 0 16px;" align="initial">/bhc</p>
<details style="margin-bottom: 0;"><summary style="margin-top: 0;">...</summary>
<p style="color: #303030; margin: 0 0 16px 1rem;">From: <a href="mailto:gitlab@mg.gitlab.com" style="color: #1068bf; margin-top: 0;">gitlab@mg.gitlab.com</a> <a href="mailto:gitlab@mg.gitlab.com" style="color: #1068bf;">gitlab@mg.gitlab.com</a>
Sent: Friday, 24 June 2022 10.29
To: <a href="mailto:bhc@insight.dk" style="color: #1068bf;">bhc@insight.dk</a>
Subject: Re: GnuTLS | Crash (0xC0000005) when closing application. (<a href="https://gitlab.com/gnutls/gnutls/-/issues/1380" data-original="#1380" data-link="false" data-link-reference="false" data-project="179611" data-issue="110609792" data-project-path="gnutls/gnutls" data-iid="1380" data-issue-type="issue" data-reference-type="issue" data-container="body" data-placement="top" title="Crash (0xC0000005) when closing application." class="gfm gfm-issue" style="color: #1068bf;">#1380</a>)</p>
<p style="color: #303030; margin: 0 0 16px 1rem;">Daiki Ueno <a href="https://gitlab.com/dueno" style="color: #1068bf; margin-top: 0;">https://gitlab.com/dueno</a>  commented on a discussion <a href="https://gitlab.com/gnutls/gnutls/-/issues/1380#note_1004040111" data-original="https://gitlab.com/gnutls/gnutls/-/issues/1380#note_1004040111" data-link="false" data-link-reference="true" data-project="179611" data-issue="110609792" data-project-path="gnutls/gnutls" data-iid="1380" data-issue-type="issue" data-reference-type="issue" data-container="body" data-placement="top" title="Crash (0xC0000005) when closing application." class="gfm gfm-issue" style="color: #1068bf;">#1380 (comment 1004040111)</a> :</p>
<p style="color: #303030; margin: 0 0 16px 1rem;">GnuTLS usage of __declspec(thread) is guarded <a href="https://gitlab.com/gnutls/gnutls/-/blob/master/lib/gthreads.h" style="color: #1068bf; margin-top: 0;">https://gitlab.com/gnutls/gnutls/-/blob/master/lib/gthreads.h</a>  with #ifdef _MSC_VER. If you see the macro expanded, that means_MSC_VER is defined somewhere, while it shouldn't be if you are using g++: <a href="https://sourceforge.net/p/mingw-w64/bugs/282/#3996" rel="nofollow noreferrer noopener" target="_blank" style="color: #1068bf;">https://sourceforge.net/p/mingw-w64/bugs/282/#3996</a></p>
<p style="color: #303030; margin: 0 0 16px 1rem;">—
Reply to this email directly or view it on GitLab <a href="https://gitlab.com/gnutls/gnutls/-/issues/1380#note_1004040111" data-original="https://gitlab.com/gnutls/gnutls/-/issues/1380#note_1004040111" data-link="false" data-link-reference="true" data-project="179611" data-issue="110609792" data-project-path="gnutls/gnutls" data-iid="1380" data-issue-type="issue" data-reference-type="issue" data-container="body" data-placement="top" title="Crash (0xC0000005) when closing application." class="gfm gfm-issue" style="color: #1068bf; margin-top: 0;">#1380 (comment 1004040111)</a> .
You're receiving this email because of your account on gitlab.com. If you'd like to receive fewer emails, you can unsubscribe <a href="https://gitlab.com/-/sent_notifications/REDACTED/unsubscribe" style="color: #1068bf;">https://gitlab.com/-/sent_notifications/REDACTED/unsubscribe</a>  from this thread or adjust your notification settings.</p>
</details>
</div>


</div>
<div class="footer" style="margin-top: 10px;">
<p style="font-size: small; color: #666;">

<br>
Reply to this email directly or <a href="https://gitlab.com/gnutls/gnutls/-/issues/1380#note_1004078015" style="color: #1068bf;">view it on GitLab</a>.
<br>
You're receiving this email because of your account on gitlab.com.
If you'd like to receive fewer emails, you can
<a href="https://gitlab.com/-/sent_notifications/60de2afd1843a60f3b273f9a22beeac1/unsubscribe" style="color: #1068bf;">unsubscribe</a>
from this thread or
adjust your notification settings.
<script type="application/ld+json">{"@context":"http://schema.org","@type":"EmailMessage","action":{"@type":"ViewAction","name":"View Issue","url":"https://gitlab.com/gnutls/gnutls/-/issues/1380#note_1004078015"}}</script>


</p>
</div>
</body>
</html>