History | Log In     View a printable version of the current page.  
Issue Details (XML | Word | Printable)

Key: JRUBY-2418
Type: Bug Bug
Status: Closed Closed
Resolution: Fixed
Priority: Major Major
Assignee: Charles Oliver Nutter
Reporter: Irfan Baig
Votes: 2
Watchers: 3
Operations

If you were logged in you would be able to see more operations.
JRuby

protected method bug: plugin will_paginate shows symptoms

Created: 19/Apr/08 05:57 PM   Updated: 04/Jul/08 09:07 AM
Component/s: Java Integration
Affects Version/s: JRuby 1.1RC3
Fix Version/s: JRuby 1.1.2

Time Tracking:
Not Specified

File Attachments: 1. File issue.rb (0.5 kb)
2. File patch_2418.diff (1 kb)
3. File test_frame_self.rb (0.7 kb)

Environment: rails 2.0.2 jruby 1.1rc3 ubuntu


 Description  « Hide
This bug was also reported to the author of 'will_paginate'
http://err.lighthouseapp.com/projects/466/tickets/207

This affects the simplest use case:

<%= will_paginate @models %>



 All   Comments   Work Log   Change History      Sort Order: Ascending order - Click to sort in descending order
Stuart Ellidge - 29/Apr/08 11:17 AM
I can confirm that the same issue exists with JRuby 1.1.1

Steen Lehmann - 06/May/08 08:54 AM
Script that works in MRI, fails in JRuby 1.1.1, thus reproducing the issue

Charles Oliver Nutter - 06/May/08 10:39 AM
Confirmed...really weird.

Steen Lehmann - 06/May/08 04:12 PM
In CallSite.java:102 the call to method.isCallableFrom fails because the current frame has erroneously had its self object set to the string passed into the method (="current"). It would seem highly likely that the code below is the culprit, as it is evaluated prior to isCallableFrom failing:

CallBlock.java:82

public IRubyObject yield(ThreadContext context, IRubyObject value, IRubyObject self,
RubyModule klass, boolean aValue, Binding binding, Block.Type type) {
if (klass == null) { self = binding.getSelf(); // FIXME: We never set this back! binding.getFrame().setSelf(self); }

return callback.call(context, new IRubyObject[] {value}, Block.NULL_BLOCK);
}


Steen Lehmann - 06/May/08 04:18 PM
Sorry, that's (from CallBlock.java:82 in trunk):
public IRubyObject yield(ThreadContext context, IRubyObject value, IRubyObject self, 
            RubyModule klass, boolean aValue, Binding binding, Block.Type type) {
        if (klass == null) {
            self = binding.getSelf();
            // FIXME: We never set this back!
            binding.getFrame().setSelf(self);
        }
        
        return callback.call(context, new IRubyObject[] {value}, Block.NULL_BLOCK);
    }

Steen Lehmann - 06/May/08 04:31 PM
Attaching a patch which seems to fix the issue, while keeping the tests running.

Steen Lehmann - 09/May/08 05:03 AM
Testcase for inclusion in the unit test suite.

Charles Oliver Nutter - 11/May/08 02:20 AM
I committed a slightly modified version of this patch that uses try/finally to guarantee the frame self gets set back. Thanks Steen!

Steen Lehmann - 11/May/08 02:40 AM
Thanks Charlie! You could even take out the line "// FIXME: We never set this back!" since now we do