-
Notifications
You must be signed in to change notification settings - Fork 36
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
Unexpected error code with WSAGetLastError even though the previous function calll was failed #72
Comments
It should be fixed in Fiddle ref. ruby/fiddle#72 Signed-off-by: Kentaro Hayashi <hayashi@clear-code.com>
It seems that Ruby 3.0's So calling |
Thanks, I'll try that way. |
What are you trying to do? Opening a PR? |
I've implemented them and released a new version. Could you report this to https://bugs.ruby-lang.org/ ? Resetting the last socket error may be a bug of Ruby 3.0. |
On Ruby 3.0, calling WSAGetLastError from Ruby script cannot get a correct error code because Ruby's internal code resets it. Use `Fiddle.win32_last_socket_error` instead if it's availbale. You need fiddle 1.0.8 or later to use it. In addition, when you use RubyInstaller, you need to specify the path of fiddle by `RUBYLIB` or `ruby -I` at this moment because it loads Ruby's bundled fiddle before initializing gem. This is the why we don't add a dependency to fiddle, just only installing fiddle doesn't take effect. e.g.) > gem install fiddle --version 1.0.8 > set RUBYLIB=C:/Ruby30-x64/lib/ruby/gems/3.0.0/gems/fiddle-1.0.8/lib > bundle exec rake spec See also: * ruby/fiddle#72 * https://bugs.ruby-lang.org/issues/17813 * https://github.com/oneclick/rubyinstaller2/blob/8225034c22152d8195bc0aabc42a956c79d6c712/lib/ruby_installer/build/dll_directory.rb Signed-off-by: Takuro Ashie <ashie@clear-code.com>
On Ruby 3.0, calling WSAGetLastError from Ruby script cannot get a correct error code because Ruby's internal code resets it. Use `Fiddle.win32_last_socket_error` instead if it's availbale. You need fiddle 1.0.8 or later to use it. In addition, when you use RubyInstaller, you need to specify the path of fiddle by `RUBYLIB` or `ruby -I` at this moment because it loads Ruby's bundled fiddle before initializing gem. This is the why we don't add a dependency to fiddle, just only installing fiddle doesn't take effect. e.g.) > gem install fiddle --version 1.0.8 > set RUBYLIB=C:/Ruby30-x64/lib/ruby/gems/3.0.0/gems/fiddle-1.0.8/lib > bundle exec rake spec See also: * ruby/fiddle#72 * https://bugs.ruby-lang.org/issues/17813 * https://github.com/oneclick/rubyinstaller2/blob/8225034c22152d8195bc0aabc42a956c79d6c712/lib/ruby_installer/build/dll_directory.rb Signed-off-by: Takuro Ashie <ashie@clear-code.com>
On Ruby 3.0, we need to use fiddle 1.0.8 or later to retrieve correct error code. In addition, we have to specify the path of fiddle by RUBYLIB because RubyInstaller loads Ruby's bundled fiddle before initializing gem. See also: * ruby/fiddle#72 * https://bugs.ruby-lang.org/issues/17813 * https://github.com/oneclick/rubyinstaller2/blob/8225034c22152d8195bc0aabc42a956c79d6c712/lib/ruby_installer/build/dll_directory.rb Fix fluent#3263 Signed-off-by: Takuro Ashie <ashie@clear-code.com>
The problem
There is a case that fiddle fails to get error code with
WSAGetLastEror
on Win32.This problem is observed with Ruby 3.0 only.
Expected result
WSAGetLastError returns correct error code when previous function call was failed.
Actual result
WSAGetLastError returns 0 even thought when previous function call was failed.
How to reproduce
Here is the sample code (test-wsagetlasterror.rb) to reproduce issue.
When using with Ruby 2.7 https://github.com/oneclick/rubyinstaller2/releases/download/RubyInstaller-2.7.2-1/rubyinstaller-2.7.2-1-x64.exe
WinSock.WSAGetLastError
returns10038
(expected)When using with Ruby 3.0 https://github.com/oneclick/rubyinstaller2/releases/download/RubyInstaller-3.0.0-1/rubyinstaller-3.0.0-1-x64.exe,
WinSock.WSAGetLastError
returns0
(not expected)The text was updated successfully, but these errors were encountered: