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

File.flock does not work on Solaris #3254

Closed
oblutak opened this Issue Aug 14, 2015 · 5 comments

Comments

Projects
None yet
3 participants
@oblutak
Copy link

oblutak commented Aug 14, 2015

This fails on jruby on solaris
File.open('/tmp/test', File::RDWR|File::CREAT) { |f| f.flock(File::LOCK_EX) }

Java::JavaLang::UnsatisfiedLinkError: unknown
    from jnr.ffi.provider.jffi.AsmRuntime.newUnsatisifiedLinkError(AsmRuntime.java:40)
    from jnr.posix.SolarisLibC$jnr$ffi$0.flock(Unknown Source)
    from jnr.posix.BaseNativePOSIX.flock(BaseNativePOSIX.java:423)
    from jnr.posix.CheckedPOSIX.flock(CheckedPOSIX.java:325)
    from jnr.posix.LazyPOSIX.flock(LazyPOSIX.java:327)
    from org.jruby.RubyFile.flock(RubyFile.java:271)
    from org.jruby.RubyFile$INVOKER$i$1$0$flock.call(RubyFile$INVOKER$i$1$0$flock.gen)
    from org.jruby.runtime.callsite.CachingCallSite.cacheAndCall(CachingCallSite.java:326)
    from org.jruby.runtime.callsite.CachingCallSite.call(CachingCallSite.java:170)
    from org.jruby.ast.CallOneArgNode.interpret(CallOneArgNode.java:57)
    from org.jruby.ast.NewlineNode.interpret(NewlineNode.java:105)
    from org.jruby.evaluator.ASTInterpreter.INTERPRET_BLOCK(ASTInterpreter.java:112)
    from org.jruby.runtime.Interpreted19Block.evalBlockBody(Interpreted19Block.java:206)
    from org.jruby.runtime.Interpreted19Block.yield(Interpreted19Block.java:157)
    from org.jruby.runtime.Block.yield(Block.java:142)
    from org.jruby.RubyIO.open(RubyIO.java:1181)
... 130 levels...
    from org.jruby.ast.BlockNode.interpret(BlockNode.java:71)
    from org.jruby.evaluator.ASTInterpreter.INTERPRET_METHOD(ASTInterpreter.java:74)
    from org.jruby.internal.runtime.methods.InterpretedMethod.call(InterpretedMethod.java:182)
    from org.jruby.internal.runtime.methods.DefaultMethod.call(DefaultMethod.java:198)
    from java.lang.invoke.MethodHandle.invokeWithArguments(MethodHandle.java:625)
    from org.jruby.runtime.invokedynamic.InvocationLinker.invocationFallback(InvocationLinker.java:157)
    from $_dot_.jirb.__file__(./jirb:13)
    from $_dot_.jirb.load(./jirb)
    from org.jruby.Ruby.runScript(Ruby.java:854)
    from org.jruby.Ruby.runScript(Ruby.java:847)
    from org.jruby.Ruby.runNormally(Ruby.java:716)
    from org.jruby.Ruby.runFromMain(Ruby.java:565)
    from org.jruby.Main.doRunFromMain(Main.java:395)
    from org.jruby.Main.internalRun(Main.java:290)
    from org.jruby.Main.run(Main.java:217)
    from org.jruby.Main.main(Main.java:197)irb(main):010:0> quit
@oblutak

This comment has been minimized.

Copy link
Author

oblutak commented Aug 14, 2015

I came across the issue trying to install any gem in jruby-9.0.0.0. Seems like rubygems introduced a flock in 2.2, so I never noticed the problems on my older install, but the same test fails on jruby 1.7.13

@headius

This comment has been minimized.

Copy link
Member

headius commented Aug 18, 2015

Ok thanks. We recently started using native flock, which must not exist on Solaris.

@headius

This comment has been minimized.

Copy link
Member

headius commented Aug 18, 2015

Ok, so flock on solaris needs to use fcntl: http://www.perkin.org.uk/posts/solaris-portability-flock.html

There's some behavioral differences, but I'm guessing MRI already has the right code.

@headius

This comment has been minimized.

Copy link
Member

headius commented Aug 18, 2015

I'm going to file an issue to fix jnr-posix, but modify JRuby to just use normal Java file-locking logic in the interim.

@headius

This comment has been minimized.

Copy link
Member

headius commented Sep 20, 2016

I have just pushed f8da225 for #4162, which implements flock like MRI using Ruby FFI. This should now be fixed.

Please test a build from http://ci.jruby.org once there's an updated snapshot.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.