-
-
Notifications
You must be signed in to change notification settings - Fork 928
Open
Labels
Milestone
Description
Environment Information
$ jruby -v
jruby 10.0.0.0 (3.4.2) 2025-04-13 6ed59bc847 OpenJDK 64-Bit Server VM 21.0.7+6-LTS on 21.0.7+6-LTS +indy +jit [x86_64-mswin32]
The same behavior is with jruby-9.4.8.0
.
Everything works fine on CRuby 3.4.3
.
https://github.com/ruby/logger
Expected Behavior
This script should write a logger header line into the test.log
without an error:
require 'bundler/inline'
gemfile do
source 'https://rubygems.org'
gem 'logger', '=1.6.3'
end
log_file_path = 'test.log'
if File.exist?(log_file_path)
File.delete(log_file_path)
end
Logger.new(log_file_path)
Actual Behavior
The execution fails with this error:
Unhandled Java exception: java.lang.UnsatisfiedLinkError: The specified procedure could not be found.
java.lang.UnsatisfiedLinkError: The specified procedure could not be found.
newUnsatisifiedLinkError at jnr/ffi/provider/jffi/AsmRuntime.java:48
flock at jnr/posix/WindowsLibC$jnr$ffi$0:-1
flock at jnr/posix/BaseNativePOSIX.java:599
flock at jnr/posix/CheckedPOSIX.java:460
flock at jnr/posix/LazyPOSIX.java:454
flock at org/jruby/util/io/PosixShim.java:222
run at org/jruby/util/io/OpenFile.java:2832
run at org/jruby/util/io/OpenFile.java:2829
executeTask at org/jruby/RubyThread.java:1791
executeTaskBlocking at org/jruby/RubyThread.java:1765
threadFlock at org/jruby/util/io/OpenFile.java:2829
flock at org/jruby/RubyFile.java:275
call at org/jruby/RubyFile$INVOKER$i$1$0$flock.gen:-1
cacheAndCall at org/jruby/runtime/callsite/CachingCallSite.java:466
call at org/jruby/runtime/callsite/CachingCallSite.java:244
processCall at org/jruby/ir/interpreter/InterpreterEngine.java:320
interpret at org/jruby/ir/interpreter/StartupInterpreterEngine.java:66
interpret at org/jruby/ir/interpreter/InterpreterEngine.java:88
INTERPRET_METHOD at org/jruby/internal/runtime/methods/MixedModeIRMethod.java:201
call at org/jruby/internal/runtime/methods/MixedModeIRMethod.java:188
call at org/jruby/internal/runtime/methods/DynamicMethod.java:225
cacheAndCall at org/jruby/runtime/callsite/CachingCallSite.java:466
call at org/jruby/runtime/callsite/CachingCallSite.java:244
processCall at org/jruby/ir/interpreter/InterpreterEngine.java:320
interpret at org/jruby/ir/interpreter/StartupInterpreterEngine.java:66
interpret at org/jruby/ir/interpreter/InterpreterEngine.java:88
INTERPRET_METHOD at org/jruby/internal/runtime/methods/MixedModeIRMethod.java:201
call at org/jruby/internal/runtime/methods/MixedModeIRMethod.java:188
call at org/jruby/internal/runtime/methods/DynamicMethod.java:225
cacheAndCall at org/jruby/runtime/callsite/CachingCallSite.java:466
call at org/jruby/runtime/callsite/CachingCallSite.java:244
processCall at org/jruby/ir/interpreter/InterpreterEngine.java:320
interpret at org/jruby/ir/interpreter/StartupInterpreterEngine.java:66
interpret at org/jruby/ir/interpreter/InterpreterEngine.java:88
INTERPRET_METHOD at org/jruby/internal/runtime/methods/MixedModeIRMethod.java:201
call at org/jruby/internal/runtime/methods/MixedModeIRMethod.java:188
call at org/jruby/internal/runtime/methods/DynamicMethod.java:225
cacheAndCall at org/jruby/runtime/callsite/CachingCallSite.java:466
call at org/jruby/runtime/callsite/CachingCallSite.java:244
processCall at org/jruby/ir/interpreter/InterpreterEngine.java:320
interpret at org/jruby/ir/interpreter/StartupInterpreterEngine.java:66
interpret at org/jruby/ir/interpreter/InterpreterEngine.java:94
INTERPRET_METHOD at org/jruby/internal/runtime/methods/MixedModeIRMethod.java:238
call at org/jruby/internal/runtime/methods/MixedModeIRMethod.java:225
cacheAndCall at org/jruby/runtime/callsite/CachingCallSite.java:481
call at org/jruby/runtime/callsite/CachingCallSite.java:308
newInstance at org/jruby/RubyClass.java:1036
call at org/jruby/RubyClass$INVOKER$i$newInstance.gen:-1
call at org/jruby/internal/runtime/methods/JavaMethod.java:375
cacheAndCall at org/jruby/runtime/callsite/CachingCallSite.java:476
call at org/jruby/runtime/callsite/CachingCallSite.java:293
processCall at org/jruby/ir/interpreter/InterpreterEngine.java:330
interpret at org/jruby/ir/interpreter/StartupInterpreterEngine.java:66
INTERPRET_METHOD at org/jruby/internal/runtime/methods/MixedModeIRMethod.java:128
call at org/jruby/internal/runtime/methods/MixedModeIRMethod.java:115
cacheAndCall at org/jruby/runtime/callsite/CachingCallSite.java:446
call at org/jruby/runtime/callsite/CachingCallSite.java:92
newInstance at org/jruby/RubyClass.java:1050
call at org/jruby/RubyClass$INVOKER$i$newInstance.gen:-1
performIndirectCall at org/jruby/ir/targets/indy/InvokeSite.java:860
invoke at org/jruby/ir/targets/indy/InvokeSite.java:785
run at logger-test.rb:-1
invokeWithArguments at java/lang/invoke/MethodHandle.java:733
load at org/jruby/ir/Compiler.java:114
runScript at org/jruby/Ruby.java:1221
runNormally at org/jruby/Ruby.java:1133
runFromMain at org/jruby/Ruby.java:978
internalRun at org/jruby/Main.java:282
run at org/jruby/Main.java:227
main at org/jruby/Main.java:199
Looking into the issue
The looger
gem is broken after this commit was introduced. Testing the changes on the same Windows machine, I got to this code:
file_path = 'test.txt'
f = File.new(file_path, mode: File::CREAT)
f.flock(File::LOCK_EX)
f = File.new(f.fileno, mode: File::WRONLY, path: file_path)
f.flock(File::LOCK_UN)
which fails with:
Unhandled Java exception: java.nio.channels.NonWritableChannelException
java.nio.channels.NonWritableChannelException: null
lock at sun/nio/ch/FileChannelImpl.java:1465
lock at org/jruby/util/io/PosixShim.java:658
flock at org/jruby/util/io/PosixShim.java:246
run at org/jruby/util/io/OpenFile.java:2832
run at org/jruby/util/io/OpenFile.java:2829
executeTask at org/jruby/RubyThread.java:1791
executeTaskBlocking at org/jruby/RubyThread.java:1765
threadFlock at org/jruby/util/io/OpenFile.java:2829
flock at org/jruby/RubyFile.java:275
call at org/jruby/RubyFile$INVOKER$i$1$0$flock.gen:-1
call at org/jruby/internal/runtime/methods/JavaMethod.java:841
performIndirectCall at org/jruby/ir/targets/indy/InvokeSite.java:860
invoke at org/jruby/ir/targets/indy/InvokeSite.java:785
run at flock-test.rb:-1
invokeWithArguments at java/lang/invoke/MethodHandle.java:733
load at org/jruby/ir/Compiler.java:114
runScript at org/jruby/Ruby.java:1221
runNormally at org/jruby/Ruby.java:1133
runFromMain at org/jruby/Ruby.java:978
internalRun at org/jruby/Main.java:282
run at org/jruby/Main.java:227
main at org/jruby/Main.java:199