From: Eric Wong Date: 2017-11-15T07:12:42+00:00 Subject: [ruby-core:83779] Re: [Ruby trunk Bug#14108] Seg Fault with MinGW on svn 60769 "U.NAKAMURA" wrote: > Hi, Eric > > In message "[ruby-core:83774] Re: [Ruby trunk Bug#14108] Seg Fault with MinGW on svn 60769" > on Wed, 15 Nov 2017 04:14:37 +0000, normalperson@yhbt.net wrote: > > Oops, I will need to modify (or revert) r60769 anyways. > > It may be possible for concurrent threads to share Dir objects > > and we were relying on GVL for protect pure-Ruby code from > > stepping over each other. > > I've not checked this problem deeply yet. > > You can see our implementation of readdir on Windows in > win32/win32.c (rb_w32_readdir). > I doubt the second argument (rb_encoding *enc) is the cause. Right, enc is no problem. The problem is using DIR * from stdio is not reentrant or thread-safe. readdir_r is deprecated, even, and so it is up to the application to provide thread-safety when reading directories. Usually on modern platforms (but not guaranteed), readdir on different DIR * pointers is safe from multiple threads, so maybe we can add a mutex to "struct dir_data". I will revert r60772, r60770, and r60769 for now... Unsubscribe: