<p dir="auto">The following program triggers this:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="use std::thread::Thread;

fn main() {
    Thread::spawn(move || { println!(&quot;Hello&quot;); }).join();
    println!(&quot;After join&quot;);
}"><pre class="notranslate"><code class="notranslate">use std::thread::Thread;

fn main() {
    Thread::spawn(move || { println!("Hello"); }).join();
    println!("After join");
}
</code></pre></div>
<p dir="auto">When compiled on DragonFly with most recent rust (and all versions since the <a href="https://github.com/rust-lang/rust/pull/19654" data-hovercard-type="pull_request" data-hovercard-url="/rust-lang/rust/pull/19654/hovercard">removal of rustrt</a>), it fails with:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="hello
thread '&lt;main&gt;' panicked at 'assertion failed: `(left == right) &amp;&amp; (right == left)` (left: `22`, right: `0`)',
/home/..../rust/src/libstd/sys/unix/mutex.rs:53"><pre class="notranslate"><code class="notranslate">hello
thread '&lt;main&gt;' panicked at 'assertion failed: `(left == right) &amp;&amp; (right == left)` (left: `22`, right: `0`)',
/home/..../rust/src/libstd/sys/unix/mutex.rs:53
</code></pre></div>
<p dir="auto">The code that fails is:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="let r = ffi::pthread_mutex_destory(self.inner.get());
debug_assert_eq!(r, 0);"><pre class="notranslate"><code class="notranslate">let r = ffi::pthread_mutex_destory(self.inner.get());
debug_assert_eq!(r, 0);
</code></pre></div>
<p dir="auto">It returns with error code 22 (EINVAL) instead of 0. To me it seems that Mutex::destroy() is called twice! It might be related to the new TLS thread_local code and destructor support, but it's pretty hard to understand, so any ideas how to track the bug further down and fix it is welcomed.</p>
<p dir="auto">See <a href="http://doc.rust-lang.org/std/primitive.char.html#method.into_searcher" rel="nofollow">http://doc.rust-lang.org/std/primitive.char.html#method.into_searcher</a> as an example, <code class="notranslate">CharEqPattern</code> goes nowhere</p>