You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Fiddle::DLError: cannot find the function: RegQueryInfoKey() #7106
jruby-head (jruby 9.4.0.0-SNAPSHOT (3.1.0) 2022-02-08 3562498 OpenJDK 64-Bit Server VM 25.322-b06 on 1.8.0_322-b06 +jit [mswin32-x86_64])
Microsoft Windows Server 2022 (10.0.20348)
This is a friendly heads-up about edge jruby on windows, which idnx tests against, and started failing, due to some missing expected API (RegQueryInfoKey()) when requiring win32ole.
$ ruby -ropen-uri -e 'puts URI.send(:open, %{[https://rubygems.org/})](https://rubygems.org/%7D)) { |f| f.read(1024) }'
Fiddle::DLError: cannot find the function: RegQueryInfoKey()
import_function at D:/a/jruby-dev-builder/jruby-dev-builder/jruby-head/lib/ruby/stdlib/fiddle/import.rb:297
extern at D:/a/jruby-dev-builder/jruby-dev-builder/jruby-head/lib/ruby/stdlib/fiddle/import.rb:170
API at D:/a/jruby-dev-builder/jruby-dev-builder/jruby-head/lib/ruby/stdlib/win32/registry.rb:243
each at org/jruby/RubyArray.java:1988
<module:API> at D:/a/jruby-dev-builder/jruby-dev-builder/jruby-head/lib/ruby/stdlib/win32/registry.rb:242
<class:Registry> at D:/a/jruby-dev-builder/jruby-dev-builder/jruby-head/lib/ruby/stdlib/win32/registry.rb:226
<module:Win32> at D:/a/jruby-dev-builder/jruby-dev-builder/jruby-head/lib/ruby/stdlib/win32/registry.rb:74
<main> at D:/a/jruby-dev-builder/jruby-dev-builder/jruby-head/lib/ruby/stdlib/win32/registry.rb:4
require at org/jruby/RubyKernel.java:1017
require at D:/a/jruby-dev-builder/jruby-dev-builder/jruby-head/lib/ruby/stdlib/rubygems/core_ext/kernel_require.rb:85
<main> at D:/a/jruby-dev-builder/jruby-dev-builder/jruby-head/lib/ruby/stdlib/win32/resolv.rb:7
require at org/jruby/RubyKernel.java:1017
require at D:/a/jruby-dev-builder/jruby-dev-builder/jruby-head/lib/ruby/stdlib/rubygems/core_ext/kernel_require.rb:85
<class:Hosts> at D:/a/jruby-dev-builder/jruby-dev-builder/jruby-head/lib/ruby/stdlib/resolv.rb:175
<class:Resolv> at D:/a/jruby-dev-builder/jruby-dev-builder/jruby-head/lib/ruby/stdlib/resolv.rb:172
<main> at D:/a/jruby-dev-builder/jruby-dev-builder/jruby-head/lib/ruby/stdlib/resolv.rb:38
require at org/jruby/RubyKernel.java:1017
require at D:/a/jruby-dev-builder/jruby-dev-builder/jruby-head/lib/ruby/stdlib/rubygems/core_ext/kernel_require.rb:85
<main> at D:/a/jruby-dev-builder/jruby-dev-builder/jruby-head/lib/ruby/stdlib/net/http.rb:25
require at org/jruby/RubyKernel.java:1017
require at D:/a/jruby-dev-builder/jruby-dev-builder/jruby-head/lib/ruby/stdlib/rubygems/core_ext/kernel_require.rb:85
open_http at D:/a/jruby-dev-builder/jruby-dev-builder/jruby-head/lib/ruby/stdlib/open-uri.rb:268
buffer_open at D:/a/jruby-dev-builder/jruby-dev-builder/jruby-head/lib/ruby/stdlib/open-uri.rb:741
open_loop at D:/a/jruby-dev-builder/jruby-dev-builder/jruby-head/lib/ruby/stdlib/open-uri.rb:212
catch at org/jruby/RubyKernel.java:1238
open_loop at D:/a/jruby-dev-builder/jruby-dev-builder/jruby-head/lib/ruby/stdlib/open-uri.rb:210
open_uri at D:/a/jruby-dev-builder/jruby-dev-builder/jruby-head/lib/ruby/stdlib/open-uri.rb:151
open at D:/a/jruby-dev-builder/jruby-dev-builder/jruby-head/lib/ruby/stdlib/open-uri.rb:721
open at D:/a/jruby-dev-builder/jruby-dev-builder/jruby-head/lib/ruby/stdlib/open-uri.rb:29
<main> at -e:1
Was only noticed now due to #7182 hiding the error.
The problem with RegQueryInfoKey seems to be that it simply does not exist. Like most of win32 APIs that deal with strings, this function is split into RegQueryInfoKeyW for wide strings and RegQueryInfoKeyA for 7-bit ASCII strings.
However... CRuby's binding of these same functions does not use the W, so something is happening there to route the bare name to the correct function.
My recommendation for now would be for us to add the W to the appropriate functions in registry.rb. Two are clearly supposed to be there, and the third probably should be there.
I pushed #7281 to add W to the functions in question, and also added a comment on https://bugs.ruby-lang.org/issues/10820 asking why this change was not done for RegQueryInfoKey and also asking how CRuby manages to find a function when it is using the incorrect name.
I also pinged the Fiddle master, @tenderlove, to see if he has any information on how this function can possibly be binding.
Just to follow up, I am very unfamiliar with the Windows side of things here. I don't have a Windows machine to test with, so any guidance from someone that knows better than me would be appreciated 🙇🏻♀️
Run ruby -ropen-uri -e 'puts URI.send(:open, %{[https://rubygems.org/})](https://rubygems.org/%7D)) { |f| f.read(1024) }'
ArgumentError: cannot convert parameter to native pointer
OpenKey at D:/a/jruby-dev-builder/jruby-dev-builder/jruby-head/lib/ruby/stdlib/win32/registry.rb:289
open at D:/a/jruby-dev-builder/jruby-dev-builder/jruby-head/lib/ruby/stdlib/win32/registry.rb:431
open at D:/a/jruby-dev-builder/jruby-dev-builder/jruby-head/lib/ruby/stdlib/win32/registry.rb:542
get_hosts_dir at D:/a/jruby-dev-builder/jruby-dev-builder/jruby-head/lib/ruby/stdlib/win32/resolv.rb:142
get_hosts_path at D:/a/jruby-dev-builder/jruby-dev-builder/jruby-head/lib/ruby/stdlib/win32/resolv.rb:15
<class:Hosts> at D:/a/jruby-dev-builder/jruby-dev-builder/jruby-head/lib/ruby/stdlib/resolv.rb:176
<class:Resolv> at D:/a/jruby-dev-builder/jruby-dev-builder/jruby-head/lib/ruby/stdlib/resolv.rb:172
<main> at D:/a/jruby-dev-builder/jruby-dev-builder/jruby-head/lib/ruby/stdlib/resolv.rb:38
require at org/jruby/RubyKernel.java:1018
require at D:/a/jruby-dev-builder/jruby-dev-builder/jruby-head/lib/ruby/stdlib/rubygems/core_ext/kernel_require.rb:85
<main> at D:/a/jruby-dev-builder/jruby-dev-builder/jruby-head/lib/ruby/stdlib/net/http.rb:25
require at org/jruby/RubyKernel.java:1018
require at D:/a/jruby-dev-builder/jruby-dev-builder/jruby-head/lib/ruby/stdlib/rubygems/core_ext/kernel_require.rb:85
open_http at D:/a/jruby-dev-builder/jruby-dev-builder/jruby-head/lib/ruby/stdlib/open-uri.rb:268
buffer_open at D:/a/jruby-dev-builder/jruby-dev-builder/jruby-head/lib/ruby/stdlib/open-uri.rb:741
open_loop at D:/a/jruby-dev-builder/jruby-dev-builder/jruby-head/lib/ruby/stdlib/open-uri.rb:212
catch at org/jruby/RubyKernel.java:1239
open_loop at D:/a/jruby-dev-builder/jruby-dev-builder/jruby-head/lib/ruby/stdlib/open-uri.rb:210
open_uri at D:/a/jruby-dev-builder/jruby-dev-builder/jruby-head/lib/ruby/stdlib/open-uri.rb:151
open at D:/a/jruby-dev-builder/jruby-dev-builder/jruby-head/lib/ruby/stdlib/open-uri.rb:721
open at D:/a/jruby-dev-builder/jruby-dev-builder/jruby-head/lib/ruby/stdlib/open-uri.rb:29
<main> at -e:1
I think the new issue is not directly related to this one, so I'm closing this again.
The new issue has probably always existed: our Fiddle implementation does not properly handle converting parameters to the appropriate target type on the function signature, due to it being a very thin shim over FFI. It was not observed before because our registry.rb used our FFI-based win32api, but that changed as part of updating to 3.1 and it now attempts to use Fiddle.
Activity
headius commentedon Mar 17, 2022
Ahh good old win32ole. We have not spent time maintaining that library for many years, and I'm sure there are methods missing.
Unfortunately I'm not sure when we will get around to this.
@enebo Perhaps after 9.4 we can pair up on some win32ole work.
eregon commentedon Jun 26, 2022
Also fails in https://github.com/ruby/jruby-dev-builder/runs/7060585691?check_suite_focus=true
It seems to mean
resolv.rbdoes not work on JRuby Windows, and neithernet/http.Was only noticed now due to #7182 hiding the error.
headius commentedon Aug 1, 2022
The problem with
RegQueryInfoKeyseems to be that it simply does not exist. Like most of win32 APIs that deal with strings, this function is split intoRegQueryInfoKeyWfor wide strings andRegQueryInfoKeyAfor 7-bit ASCII strings.However... CRuby's binding of these same functions does not use the
W, so something is happening there to route the bare name to the correct function.headius commentedon Aug 1, 2022
I found this issue in CRuby where they fixed two other functions to use
Wbut not this one: https://bugs.ruby-lang.org/issues/10820I have not yet figured out how CRuby locates the appropriate version of the function when it is clearly trying to import the bare name.
headius commentedon Aug 1, 2022
My recommendation for now would be for us to add the
Wto the appropriate functions in registry.rb. Two are clearly supposed to be there, and the third probably should be there.Use the wide versions of these functions always
headius commentedon Aug 1, 2022
I pushed #7281 to add
Wto the functions in question, and also added a comment on https://bugs.ruby-lang.org/issues/10820 asking why this change was not done forRegQueryInfoKeyand also asking how CRuby manages to find a function when it is using the incorrect name.I also pinged the Fiddle master, @tenderlove, to see if he has any information on how this function can possibly be binding.
HoneyryderChuck commentedon Aug 1, 2022
awesome, thx for following up 👏
tenderlove commentedon Aug 3, 2022
Just to follow up, I am very unfamiliar with the Windows side of things here. I don't have a Windows machine to test with, so any guidance from someone that knows better than me would be appreciated 🙇🏻♀️
headius commentedon Aug 3, 2022
@HoneyryderChuck Are you able to test #7281 on Windows? I currently do not have access to a Windows machine (work machines in transition).
headius commentedon Aug 3, 2022
I have gone ahead with merging the "W" change in #7281. This should be fixed now and will be released in 9.3.7.0.
eregon commentedon Aug 6, 2022
Thanks, that fixes it for setup-ruby on GitHub Actions.
eregon commentedon Aug 6, 2022
I spoke too soon, it still fails for jruby-head:
https://github.com/ruby/jruby-dev-builder/runs/7697355232?check_suite_focus=true
I think it's simply because #7281 wasn't merged to master, only to jruby-9.3
Use RegQueryInfoKeyW
eregon commentedon Aug 6, 2022
I ported the fix to master: 58fffdf
eregon commentedon Aug 8, 2022
This still doesn't work on master, probably it needs more fixes:
https://github.com/ruby/jruby-dev-builder/runs/7715080311?check_suite_focus=true
eregon commentedon Aug 10, 2022
@headius @enebo Could you take another look at this? It means
jruby-headis very outdated due to this issue (failing since April 27).headius commentedon Aug 12, 2022
The new issue looks different but I'll have a look.
headius commentedon Aug 12, 2022
I think the new issue is not directly related to this one, so I'm closing this again.
The new issue has probably always existed: our Fiddle implementation does not properly handle converting parameters to the appropriate target type on the function signature, due to it being a very thin shim over FFI. It was not observed before because our registry.rb used our FFI-based win32api, but that changed as part of updating to 3.1 and it now attempts to use Fiddle.
I will open a separate issue.
Update README to remove JRuby version notes
Update README to remove JRuby version notes