Skip to content

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

Closed

Description

@HoneyryderChuck

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.

Activity

  1. headius commented on Mar 17, 2022

    @headius
    Member

    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.

  2. eregon commented on Jun 26, 2022

    @eregon
    Contributor

    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.

  3. headius commented on Aug 1, 2022

    @headius
    Member

    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.

  4. headius commented on Aug 1, 2022

    @headius
    Member

    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.

  5. headius commented on Aug 1, 2022

    @headius
    Member

    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.

  6. added a commit that references this issue on Aug 1, 2022
    85213d3
  7. headius commented on Aug 1, 2022

    @headius
    Member

    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.

  8. HoneyryderChuck commented on Aug 1, 2022

    @HoneyryderChuck
    Author

    awesome, thx for following up 👏

  9. tenderlove commented on Aug 3, 2022

    @tenderlove
    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 🙇🏻‍♀️

  10. headius commented on Aug 3, 2022

    @headius
    Member

    @HoneyryderChuck Are you able to test #7281 on Windows? I currently do not have access to a Windows machine (work machines in transition).

  11. headius commented on Aug 3, 2022

    @headius
    Member

    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.

  12. eregon commented on Aug 6, 2022

    @eregon
    Contributor

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

  13. eregon commented on Aug 6, 2022

    @eregon
    Contributor

    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

  14. added a commit that references this issue on Aug 6, 2022
  15. eregon commented on Aug 6, 2022

    @eregon
    Contributor

    I ported the fix to master: 58fffdf

  16. eregon commented on Aug 8, 2022

    @eregon
    Contributor

    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
    
  17. reopened this on Aug 8, 2022
  18. eregon commented on Aug 10, 2022

    @eregon
    Contributor

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

  19. headius commented on Aug 12, 2022

    @headius
    Member

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

  20. headius commented on Aug 12, 2022

    @headius
    Member

    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.

  21. added this to the JRuby 9.4.0.0 milestone on Aug 12, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions