Project

General

Profile

Bug #14686

Windows - uninitialized constant Fiddle::Function::STDCALL, test issue

Added by MSP-Greg (Greg L) 6 months ago. Updated 6 months ago.

Status:
Closed
Priority:
Normal
Assignee:
-
Target version:
-
ruby -v:
ruby 2.6.0dev (2018-04-12 trunk 63140) [x64-mingw32]
[ruby-core:86536]

Description

While testing the test/ruby folder with frozen-string, I came across a few issues. More later...

I had the following failures in test_rubyoptions.rb, which were due to output on stderr:

  3) Failure:
TestRubyOptions#test_frozen_string_literal_debug [E:/GitHub/ruby/test/ruby/test_rubyoptions.rb:986]:
[["--disable=gems", "--enable-frozen-string-literal", "--debug"], "+\"foo\#{123}bar\" << \"bar\""].

1. [2/2] Assertion for "stderr"
   | <[]> expected but was
   | <["Exception `NameError' at C:/ruby26_64/lib/ruby/2.6.0/fiddle/import.rb:160 - uninitialized constant Fiddle::Function::STDCALL"]>.

  4) Failure:
TestRubyOptions#test_debug [E:/GitHub/ruby/test/ruby/test_rubyoptions.rb:83]:

1. [2/2] Assertion for "stderr"
   | <[]> expected but was
   | <["Exception `NameError' at C:/ruby26_64/lib/ruby/2.6.0/fiddle/import.rb:160 - uninitialized constant Fiddle::Function::STDCALL"]>.

The code in questions is https://github.com/ruby/ruby/blob/trunk/ext/fiddle/lib/fiddle/import.rb#L158-L164, as follows:

CALL_TYPE_TO_ABI = Hash.new { |h, k|
  raise RuntimeError, "unsupported call type: #{k}"
}.merge({ :stdcall => (Function::STDCALL rescue Function::DEFAULT),
          :cdecl   => Function::DEFAULT,
          nil      => Function::DEFAULT
        }).freeze
private_constant :CALL_TYPE_TO_ABI

Changing it to the following removed failures:

CALL_TYPE_TO_ABI = Hash.new { |h, k|
  raise RuntimeError, "unsupported call type: #{k}"
}.merge({ :stdcall => defined?(Function::STDCALL) ? Function::STDCALL :
                      Function::DEFAULT,
          :cdecl   => Function::DEFAULT,
          nil      => Function::DEFAULT
        }).freeze
private_constant :CALL_TYPE_TO_ABI

I haven't worked much with Fiddle, but I checked for the existence of STDCALL in the listed ruby-loco build, the 2.5.1 RubyInstaller2 build, and a recent local vc14 trunk build. It did not exist in any of the three builds. Hence, I don't know if this is a correct fix...

Patch attached. Thanks, Greg

fiddle_import.rb.patch (666 Bytes) fiddle_import.rb.patch defined?(Function::STDCALL) MSP-Greg (Greg L), 04/13/2018 12:53 AM
fiddle_import.rb.patch (666 Bytes) fiddle_import.rb.patch Function.const_defined?(:STDCALL) MSP-Greg (Greg L), 04/13/2018 01:00 AM

Associated revisions

Revision eb02a846
Added by nobu (Nobuyoshi Nakada) 6 months ago

fiddle/import.rb: suppress warning

  • ext/fiddle/lib/fiddle/import.rb: suppress exception report when $DEBUG is enabled. [Bug #14686]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@63205 b2dd03c8-39d4-4d8f-98ff-823fe69b080e

Revision 63205
Added by nobu (Nobuyoshi Nakada) 6 months ago

fiddle/import.rb: suppress warning

  • ext/fiddle/lib/fiddle/import.rb: suppress exception report when $DEBUG is enabled. [Bug #14686]

Revision 5a5c9a70
Added by nobu (Nobuyoshi Nakada) 6 months ago

fiddle/test_import.rb: fix warnings by rubygems

[Bug #14686]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@63206 b2dd03c8-39d4-4d8f-98ff-823fe69b080e

Revision 63206
Added by nobu (Nobuyoshi Nakada) 6 months ago

fiddle/test_import.rb: fix warnings by rubygems

[Bug #14686]

History

#1 [ruby-core:86537] Updated by MSP-Greg (Greg L) 6 months ago

Probably better to use Function.const_defined?(:STDCALL) than defined?(Function::STDCALL)

#2 Updated by nobu (Nobuyoshi Nakada) 6 months ago

  • Status changed from Open to Closed

Applied in changeset trunk|r63205.


fiddle/import.rb: suppress warning

  • ext/fiddle/lib/fiddle/import.rb: suppress exception report when $DEBUG is enabled. [Bug #14686]

Also available in: Atom PDF