# Simple thread in MINGW32 c extension cannot be joined

**URL:** <https://www.ruby-forum.com/t/simple-thread-in-mingw32-c-extension-cannot-be-joined/230099>\
**Category:** Ruby\
**Created:** [May 30, 2014, 3:30pm UTC](https://www.ruby-forum.com/t/simple-thread-in-mingw32-c-extension-cannot-be-joined/230099 "2014-05-30T15:30:55Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![jason\_sam](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/7993a0/32.png) [@jason\_sam](https://www.ruby-forum.com/u/jason_sam)\
**Post date:** [May 30, 2014, 3:30pm UTC](https://www.ruby-forum.com/t/simple-thread-in-mingw32-c-extension-cannot-be-joined/230099/1 "2014-05-30T15:30:55Z")

</div>

Hallo List,

I’m currently trying to build a cross platform C++ Ruby Extension  
module.

All works with Linux, but when trying to build under MINGW32 for Windows  
I have the problem that I cannot join a std::thread that was created in  
my extension module earlier.

The extension module code is fairly simple (stripped down to show the  
problem isolated):

class SayHello  
{  
public:  
void operator()() const {  
std::cout\<\< “hello” \<\< std::endl;  
}  
};

VALUE method\_test1(VALUE self) {  
std::thread t((SayHello()));  
t.join();  
return rb\_str\_new2(“success”);  
}

void Init\_test() {  
mTest = rb\_define\_class(“Test”, rb\_cObject);  
rb\_define\_method(mTest, “test1”, (VALUE (\*)(…)) method\_test1, 0);  
}

Environment is: Windows 7, 32bit, Ruby 1.9.3-p545 (download from  
[rubyinstaller.org](http://rubyinstaller.org)), MingW i686-4.8.3-release-posix-sjlj-rt\_v3-rev0  
(download from MingW-w64 project), MSYS2

The thread starts up and finishes, but the join is blocking  
indefinitely.

Please let me know what further information you might need to maybe help  
me nailing down the problem.

Is there some interaction with the thread magic that ruby itself does in  
thread\_win32.c? Are there any symbols / functions exported from the ruby  
dll or interpreter that might interfere with my usage in the extension  
module?

My thread here is completely independant and doesn’t need any  
interaction  
with ruby itself.

Thanks

Tino

---

<div class="post-metadata">

**Author:** ![Tino\_Lange](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/8797f3/32.png) [@Tino\_Lange](https://www.ruby-forum.com/u/Tino_Lange)\
**Post date:** [June 2, 2014, 1:50am UTC](https://www.ruby-forum.com/t/simple-thread-in-mingw32-c-extension-cannot-be-joined/230099/2 "2014-06-02T01:50:49Z")

</div>

KINDLY UN SUBSCRIBE ME

On Fri, May 30, 2014 at 6:33 PM, Tino Lange  
[removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)

---

<div class="post-metadata">

**Author:** ![Tino\_Lange](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/8797f3/32.png) [@Tino\_Lange](https://www.ruby-forum.com/u/Tino_Lange)\
**Post date:** [June 2, 2014, 1:55am UTC](https://www.ruby-forum.com/t/simple-thread-in-mingw32-c-extension-cannot-be-joined/230099/3 "2014-06-02T01:55:33Z")

</div>

-----BEGIN PGP SIGNED MESSAGE-----  
Hash: SHA512

To unsubscribe, send an email with the subject ‘unsubscribe’ (no  
quotes) to [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid). Follow instructions  
throughout the process.

On 5/31/2014 03:26, Vishal Bisht wrote:

> module.
> 
> [rubyinstaller.org](http://rubyinstaller.org) [http://rubyinstaller.org](http://rubyinstaller.org)), MingW  
> does in thread\_win32.c? Are there any symbols / functions exported

* * *

Rylee F.  
[removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
-----BEGIN PGP SIGNATURE-----  
Version: GnuPG v2.0.22 (MingW32)  
Comment: Using GnuPG with Thunderbird - [http://www.enigmail.net/](http://www.enigmail.net/)

iQEcBAEBCgAGBQJTi71GAAoJEAWmNCH2N+MzYPQIAJoxYzWLam7Fz4BvHVnnHeNv  
jmhdQg3bXJ0G9G6z3CSIONaIDpSmU4R7zSMXk/uPavGHASIjr4N6RS4h0UYrGNLa  
WIthKCGbQPEEbeAKwkQW6M2awca+FcjJcgF9FBldF/w0bQNAec4gDx8fstBJ+Q6w  
Y20i4BDkVanA637YD7rEnmtRkn8xc6fmTs093wsZpdBa3bJLwsAdxFzufawHRH5z  
zVHy9GpU/QjoKHl2+89ODz1FPRNU68fNq/lprNEvVWighjjpPpWm2B3zA9GaPOZ5  
+kbXgW+w2iS0lb85pNhLUGfDCNnMA4RJY/EOoGd4YmopEKKlKGtTwXkSi7b1N/E=  
=T+Uv  
-----END PGP SIGNATURE-----
