Skip to content

Logger: Errno::EINVAL: Invalid argument with JRuby 9.x in Solaris #4162

@smk0621

Description

@smk0621

Environment

  • jruby 9.1.2.0 (2.3.0) 2016-05-26 7357c8f Java HotSpot(TM) 64-Bit Server VM 25.60-b23 on 1.8.0_60-b27 +jit [solaris-sparcv9]
  • SunOS s11 5.11 11.3 sun4v sparc sun4v

Our Rails4 App in Solaris cannot started because we need create log file.
And we test the follow codes alone:

require 'logger'

logger = Logger.new("/work/log.txt", 5, 1024)
logger.info("A" * 1024)
logger.info("B" * 1024)

Expected Behavior

  • Create 'log.txt' with 'B' and 'log.txt.1' with 'A'.*

Actual Behavior

  • Only create a empty file 'log.txt' without any characters in it and raise the follows error:
Errno::EINVAL: Invalid argument - /work/log.txt
           flock at org/jruby/RubyFile.java:335
  create_logfile at /work/jruby-9.1.2.0/lib/ruby/stdlib/logger.rb:712
    open_logfile at /work/jruby-9.1.2.0/lib/ruby/stdlib/logger.rb:705
         set_dev at /work/jruby-9.1.2.0/lib/ruby/stdlib/logger.rb:695
      initialize at /work/jruby-9.1.2.0/lib/ruby/stdlib/logger.rb:635
      initialize at /work/jruby-9.1.2.0/lib/ruby/stdlib/logger.rb:353
           <top> at /work/test_logger.rb:3
  • Then we test it with JRuby 1.7.26 and Ruby 2.1, they are OK.
  • And we test it with JRuby 9.0.0.0, it raise another error:
AsmRuntime.java:40:in `newUnsatisifiedLinkError': java.lang.UnsatisfiedLinkError: unknown
        from null:-1:in `flock'
        from BaseNativePOSIX.java:527:in `flock'
        from CheckedPOSIX.java:416:in `flock'
        from LazyPOSIX.java:412:in `flock'
        from PosixShim.java:177:in `flock'
        from OpenFile.java:2488:in `run'
        from OpenFile.java:2485:in `run'
        from RubyThread.java:1358:in `executeTask'
        from OpenFile.java:2485:in `threadFlock'
        from RubyFile.java:298:in `flock'
        from RubyFile$INVOKER$i$1$0$flock.gen:-1:in `call'
        from CachingCallSite.java:313:in `cacheAndCall'
        from CachingCallSite.java:163:in `call'
        from InterpreterEngine.java:289:in `processCall'
        from StartupInterpreterEngine.java:77:in `interpret'
        from InterpreterEngine.java:82:in `interpret'
        from MixedModeIRMethod.java:198:in `INTERPRET_METHOD'
        from MixedModeIRMethod.java:184:in `call'
        from DynamicMethod.java:201:in `call'
        from CachingCallSite.java:313:in `cacheAndCall'
        from CachingCallSite.java:163:in `call'
        from InterpreterEngine.java:289:in `processCall'
        from StartupInterpreterEngine.java:77:in `interpret'
        from InterpreterEngine.java:82:in `interpret'
        from MixedModeIRMethod.java:198:in `INTERPRET_METHOD'
        from MixedModeIRMethod.java:184:in `call'
        from DynamicMethod.java:201:in `call'
        from CachingCallSite.java:313:in `cacheAndCall'
        from CachingCallSite.java:163:in `call'
        from InterpreterEngine.java:289:in `processCall'
        from StartupInterpreterEngine.java:77:in `interpret'
        from MixedModeIRMethod.java:128:in `INTERPRET_METHOD'
        from MixedModeIRMethod.java:114:in `call'
        from CachingCallSite.java:273:in `cacheAndCall'
        from CachingCallSite.java:79:in `callBlock'
        from CachingCallSite.java:83:in `call'
        from RubyClass.java:881:in `newInstance'
        from RubyClass$INVOKER$i$newInstance.gen:-1:in `call'
        from CachingCallSite.java:273:in `cacheAndCall'
        from CachingCallSite.java:79:in `callBlock'
        from CachingCallSite.java:83:in `call'
        from CallBase.java:419:in `interpret'
        from InterpreterEngine.java:321:in `processCall'
        from StartupInterpreterEngine.java:77:in `interpret'
        from InterpreterEngine.java:94:in `interpret'
        from MixedModeIRMethod.java:268:in `INTERPRET_METHOD'
        from MixedModeIRMethod.java:254:in `call'
        from CachingCallSite.java:363:in `cacheAndCall'
        from CachingCallSite.java:237:in `callBlock'
        from CachingCallSite.java:241:in `call'
        from RubyClass.java:874:in `newInstance'
        from RubyClass$INVOKER$i$newInstance.gen:-1:in `call'
        from JavaMethod.java:345:in `call'
        from CachingCallSite.java:353:in `cacheAndCall'
        from CachingCallSite.java:227:in `call'
        from /work/test_logger.rb:-1:in `invokeOther5:new'
        from /work/test_logger.rb:3:in `RUBY$script'
        from MethodHandle.java:627:in `invokeWithArguments'
        from Compiler.java:111:in `load'
        from Ruby.java:821:in `runScript'
        from Ruby.java:813:in `runScript'
        from Ruby.java:751:in `runNormally'
        from Ruby.java:573:in `runFromMain'
        from Main.java:403:in `doRunFromMain'
        from Main.java:298:in `internalRun'
        from Main.java:225:in `run'
        from Main.java:197:in `main'

We found that if we delete 3 lines in /jruby-9.1.2.0/lib/ruby/stdlib/logger.rb, it's OK too.

712  logdev.flock(File::LOCK_EX)
715  logdev.flock(File::LOCK_UN)
755  lock.flock(File::LOCK_EX) # inter-process locking. will be unlocked at closing file

And we test the same codes with JRuby 9.1.2.0 in RedHat Enterprise 7.2, it's OK.
It seems that this is a JRuby bug in Solaris.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions