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

Fiddle::DLError: cannot find the function: RegQueryInfoKey() #7106

Closed
HoneyryderChuck opened this issue Feb 18, 2022 · 17 comments · Fixed by #7281
Closed

Fiddle::DLError: cannot find the function: RegQueryInfoKey() #7106

HoneyryderChuck opened this issue Feb 18, 2022 · 17 comments · Fixed by #7281
Labels
Milestone

Comments

@HoneyryderChuck
Copy link

HoneyryderChuck commented Feb 18, 2022

Environment Information

Provide at least:

  • 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.

@headius
Copy link
Member

headius commented 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
Copy link
Member

eregon commented Jun 26, 2022

Also fails in https://github.com/ruby/jruby-dev-builder/runs/7060585691?check_suite_focus=true
It seems to mean resolv.rb does not work on JRuby Windows, and neither net/http.

$ 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.

@headius
Copy link
Member

headius commented Aug 1, 2022

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.

@headius
Copy link
Member

headius commented Aug 1, 2022

I found this issue in CRuby where they fixed two other functions to use W but not this one: https://bugs.ruby-lang.org/issues/10820

I 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
Copy link
Member

headius commented Aug 1, 2022

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.

headius added a commit to headius/jruby that referenced this issue Aug 1, 2022
The two delete functions were modified to be wide in CRuby in
response to https://bugs.ruby-lang.org/issues/10820 seven years
ago. The query function was mentioned here but not updated to be
wide. I am unsure how CRuby is locating the appropriate `A` or `W`
function given the bare name, but since we have largely forked
this file and always want to use the wide version, this change
seems appropriate.

Fixes jruby#7106
@headius
Copy link
Member

headius commented Aug 1, 2022

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.

@HoneyryderChuck
Copy link
Author

awesome, thx for following up 👏

@tenderlove
Copy link
Contributor

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
Copy link
Member

headius commented 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 headius linked a pull request Aug 3, 2022 that will close this issue
@headius
Copy link
Member

headius commented 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.

@headius headius closed this as completed Aug 3, 2022
@eregon
Copy link
Member

eregon commented Aug 6, 2022

Thanks, that fixes it for setup-ruby on GitHub Actions.

@eregon
Copy link
Member

eregon commented 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

eregon added a commit that referenced this issue Aug 6, 2022
@eregon
Copy link
Member

eregon commented Aug 6, 2022

I ported the fix to master: 58fffdf

@eregon
Copy link
Member

eregon commented 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

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

@eregon
Copy link
Member

eregon commented Aug 10, 2022

@headius @enebo Could you take another look at this? It means jruby-head is very outdated due to this issue (failing since April 27).

@headius
Copy link
Member

headius commented Aug 12, 2022

The new issue looks different but I'll have a look.

@headius
Copy link
Member

headius commented 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.

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

Successfully merging a pull request may close this issue.

4 participants