Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NullPointerException with PTY.open returning null (not nil) #5654

Closed
byteit101 opened this issue Mar 15, 2019 · 3 comments
Closed

NullPointerException with PTY.open returning null (not nil) #5654

byteit101 opened this issue Mar 15, 2019 · 3 comments

Comments

@byteit101
Copy link
Member

@byteit101 byteit101 commented Mar 15, 2019

Environment

  • jruby 9.2.6.0 (2.5.3) 2019-02-11 15ba00b Java HotSpot(TM) 64-Bit Server VM 25.144-b01 on 1.8.0_144-b01 +jit [linux-x86_64]
  • RHEL 7.6 & macOS High Sierra
  • rvm 1.29.7-next (master) by Michal Papis, Piotr Kuczynski, Wayne E. Seguin [https://rvm.io]

Expected Behavior

PTY.open returns two IO objects
MRI behavior:

2.5.3 :001 > require 'pty'
 => true 
2.5.3 :002 > q = PTY.open; 5
 => 5 
2.5.3 :003 > q
 => [#<IO:masterpty:/dev/pts/10>, #<File:/dev/pts/10>] 
2.5.3 :004 > 

Actual Behavior

PTY.open returns null (not nil!) and jruby doesn't know how to deal with it
Fresh RVM jruby install:

jruby-9.2.6.0 :001 > require 'pty'
 => true 
jruby-9.2.6.0 :002 > q = PTY.open; 5
 => 5 
jruby-9.2.6.0 :003 > q
Traceback (most recent call last):
       16: from org.jruby.runtime.IRBlockBody.call(IRBlockBody.java:79)
       15: from org.jruby.runtime.MixedModeIRBlockBody.commonYieldPath(MixedModeIRBlockBody.java:151)
       14: from org.jruby.ir.interpreter.Interpreter.INTERPRET_BLOCK(Interpreter.java:128)
       13: from org.jruby.ir.interpreter.StartupInterpreterEngine.interpret(StartupInterpreterEngine.java:72)
       12: from org.jruby.ir.interpreter.InterpreterEngine.processCall(InterpreterEngine.java:346)
       11: from org.jruby.runtime.callsite.CachingCallSite.call(CachingCallSite.java:141)
       10: from org.jruby.runtime.callsite.CachingCallSite.cacheAndCall(CachingCallSite.java:325)
        9: from org.jruby.RubyArray$INVOKER$i$0$0$inspect.call(RubyArray$INVOKER$i$0$0$inspect.gen)
        8: from org.jruby.RubyArray.inspect(RubyArray.java:1686)
        7: from org.jruby.specialized.RubyArrayTwoObject.inspectAry(RubyArrayTwoObject.java:158)
        6: from org.jruby.RubyObject.inspect(RubyObject.java:427)
        5: from org.jruby.RubyBasicObject.rbInspect(RubyBasicObject.java:1177)
        4: from org.jruby.runtime.callsite.CachingCallSite.call(CachingCallSite.java:141)
        3: from org.jruby.runtime.callsite.CachingCallSite.cacheAndCall(CachingCallSite.java:325)
        2: from org.jruby.RubyFile$INVOKER$i$0$0$inspect.call(RubyFile$INVOKER$i$0$0$inspect.gen)
        1: from org.jruby.RubyFile.inspect(RubyFile.java:497)
Java::JavaLang::NullPointerException ()
jruby-9.2.6.0 :004 > 

Same thing happens in a file with p PTY.open

There seems to be two issues here: one is that a null is returned and not properly wrapped in a nil object, blowing up with an actual NPE, and the other is that PTY.open isn't working and returning correct results. Please split this issue if appropriate.

@byteit101
Copy link
Member Author

@byteit101 byteit101 commented Mar 15, 2019

Appears to be a regression in 9.2.0.0 as 9.1.17.0 succeeds with:

jruby-9.1.17.0 :001 > require 'pty'
 => true 
jruby-9.1.17.0 :002 > q = PTY.open; 5
 => 5 
jruby-9.1.17.0 :003 > q
 => [#<IO:fd 16>, #<File:null>] 

(seems to work despite the null inspect result)
and 9.2.0.0 gives the same NPE as originally reported

kares added a commit to kares/jruby that referenced this issue Mar 20, 2019
@kares
Copy link
Member

@kares kares commented Mar 20, 2019

the NPE cause is expected to be resolved with: d795d72

@kares kares closed this Mar 20, 2019
@kares kares added this to the JRuby 9.2.7.0 milestone Mar 20, 2019
@BobBlank12
Copy link

@BobBlank12 BobBlank12 commented Nov 11, 2019

Would this bug cause jruby to not be able to write to /dev/null?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
3 participants