Details
-
Type:
Bug
-
Status:
Resolved
-
Priority:
Major
-
Resolution: Fixed
-
Affects Version/s: JRuby 1.7.0.pre1
-
Fix Version/s: JRuby 1.7.0.pre2
-
Component/s: Standard Library
-
Labels:None
-
Environment:Mac OSX 10.6.8, JDK 7
-
Testcase included:yes
-
Number of attachments :
Description
While browsing through the MRI source, I noticed the following code regarding Etc.group iteration:
etc.c
static void each_group(void) { if (group_blocking) { rb_raise(rb_eRuntimeError, "parallel group iteration"); } group_blocking = (int)Qtrue; rb_ensure(group_iterate, 0, group_ensure, 0); }
After running the attached test case, JRuby trunk goes into a high CPU loop. The C version prevents this by throwing a RuntimeError if you attempt a parallel loop. In essence the logic is:
- Check a group_blocking flag, and if it exists then throw a runtime error
- If it doesn't exist, set the flag to true
- Continue with the iteration
commit 9e4e5d5884353751e0772eb8ce2a445fa98d0450 Author: Charles Oliver Nutter <headius@headius.com> Date: Thu Aug 2 12:43:07 2012 -0500 Fix JRUBY-6056: High CPU Loop with parallel Etc.group iterrations Added the same check that MRI has here. :100644 100644 5e82105... bacf230... M src/org/jruby/ext/etc/RubyEtc.java