From: Motohiro KOSAKI Date: 2011-09-12T02:27:18+09:00 Subject: [ruby-core:39475] [Ruby 1.9 - Bug #5306] Application Hangs Due to Recent rb_thread_select Changes Issue #5306 has been updated by Motohiro KOSAKI. File old_thread_select.patch added > static void > rb_fd_rcopy(fd_set *dst, rb_fdset_t *src) > { > size_t size = howmany(rb_fd_max(src), NFDBITS) * sizeof(fd_mask); > if (size < sizeof(fd_set)) size = sizeof(fd_set); > memcpy(dst, rb_fd_ptr(src), size); > } If size > sizeof(fd_set), this code makes memory corruption. > static void > rb_fd_rcopy(fd_set *dst, rb_fdset_t *src) > { > memcpy(dst->fd_array, src->fdset->fd_array, > dst->fd_count * sizeof(dst->fd_array[0]); > dst->fd_count = src->fdset->fd_count; > } Bad indentation of coding style violation. Also, if src->fdset->fd_count > FD_SETSIZE, we should return an error or raise an exception. Attached new patch. It works both linux and windows. Can you please review it? ---------------------------------------- Bug #5306: Application Hangs Due to Recent rb_thread_select Changes http://redmine.ruby-lang.org/issues/5306 Author: Charlie Savage Status: Open Priority: High Assignee: Category: core Target version: 1.9.3 ruby -v: - This commit: 4e9438bc9153f7a1f4ea0af85c8dbe359e1a55d8 Changed the implementation of rb_thread_select. It causes eventmachine to hang on CentOS 5.5. Not sure what the issue is, but its easily reproduced by by running the test eventmachine/tests/test_epoll.rb. We noticed this because it also causes the tweetstream gem to hang. The same setup works on Fedora 14 and an up-to-date arch linux. Specific version information included below. We temporarily fixed this by reverting the commit. Since Centos is a common production environment (and the one we are using), this seems to us a blocker for 1.9.3. We are happy to provide any additional information or test fixes. Thanks - Charlie -------------- We are running this version of CentOS: Linux app1.zerista.com 2.6.18-238.19.1.el5.centos.plus #1 SMP Mon Jul 18 10:05:09 EDT 2011 x86_64 x86_64 x86_64 GNU/Linux And this version of Fedora: Linux ammonite.internal.zerista.com 2.6.35.14-95.fc14.x86_64 #1 SMP Tue Aug 16 21:01:58 UTC 2011 x86_64 x86_64 x86_64 GNU/Linux And this version of eventmachine: eventmachine (1.0.0.beta.3) And this version of tweetstream: tweetstream (1.0.4) -- http://redmine.ruby-lang.org