Project

General

Profile

Bug #12924

Fiddle::TestFunction#test_nogvl_poll fails on macOS 10.12-10.12.1 Sierra

Added by kimuraw (Wataru Kimura) over 3 years ago. Updated about 3 years ago.

Status:
Third Party's Issue
Priority:
Normal
Assignee:
-
Target version:
-
ruby -v:
ruby 2.4.0dev (2016-11-12 trunk 56725) [x86_64-darwin16]
[ruby-dev:49871]

Description

macOS 10.12.1上でFiddle::TestFunction#test_nogvl_pollが失敗します。OS X 10.11では問題ありません。
2.4-preview3およびtrunk(r56725)で確認しました。

  1) Failure: 
Fiddle::TestFunction#test_nogvl_poll [/.../ruby-2.4.0-preview3/test/fiddle/test_function.rb:91]: 
slept correct amount of time. 
Expected |200 - 0| (200) to be <= 100.

おそらくruby側の問題ではなく、poll(2)の動作が10.12で変わったようです。
pollへ渡したnfdsの値が0のとき、待たずにすぐ抜けてしまいます。
参考: https://github.com/curl/curl/issues/1057

opensource.apple.comにはまだ10.12のソースコードが上がっていないため
実際にpollが変更されたかは確認できていません。

以下のコードで確認してみました。

require 'fiddle/import'
require 'tempfile'

include Fiddle

libc = dlopen('/usr/lib/libc.dylib')
@func = Function.new(libc['poll'], [TYPE_VOIDP, TYPE_INT, TYPE_INT], TYPE_INT)

def test_poll(fds, nfds)
    t0 = Process.clock_gettime(Process::CLOCK_MONOTONIC, :millisecond)
    n1 = @func.call(fds&.to_ptr, nfds, 200)
    t1 = Process.clock_gettime(Process::CLOCK_MONOTONIC, :millisecond)
    puts "fd=#{fds ? fds.fd : "(nil)"}, nfds=#{nfds}, slept=#{t1 - t0}"
end

fds = Fiddle::Importer.struct(["int fd", "short events", "short revents"]).malloc
file = Tempfile.open('test_poll')
begin
    fds.fd = file.fileno
    fds.events = 0
    fds.revents = 0

    puts RUBY_DESCRIPTION
    puts `uname -sr`.chomp
    test_poll(fds, 0) # not block on macOS Sierra
    test_poll(fds, 1)
    test_poll(nil, 0) # not block on macOS Sierra
    test_poll(nil, 1)
ensure
    file.unlink
end

結果は次の通りです。

# trunk on 10.12 Sierra 
ruby 2.4.0dev (2016-11-12 trunk 56725) [x86_64-darwin16]
Darwin 16.1.0
fd=7, nfds=0, slept=0       ###
fd=7, nfds=1, slept=201
fd=(nil), nfds=0, slept=0   ###
fd=(nil), nfds=1, slept=0

# 2.4-preview3 on 10.12 Sierra 
ruby 2.4.0preview3 (2016-11-07 trunk 56661) [x86_64-darwin16]
Darwin 16.1.0
fd=7, nfds=0, slept=0       ###
fd=7, nfds=1, slept=205
fd=(nil), nfds=0, slept=0   ###
fd=(nil), nfds=1, slept=0

# 2.4-preview3 on 10.11 El Capitan 
ruby 2.4.0preview3 (2016-11-07 trunk 56661) [x86_64-darwin15]
Darwin 15.6.0
fd=7, nfds=0, slept=206     ###
fd=7, nfds=1, slept=206
fd=(nil), nfds=0, slept=206 ###
fd=(nil), nfds=1, slept=0

Updated by kimuraw (Wataru Kimura) over 3 years ago

  • Subject changed from Fiddle::TestFunction#test_nogvl_poll fails on macOS 10.12 Sierra to Fiddle::TestFunction#test_nogvl_poll fails on macOS 10.12-10.12.1 Sierra

@hsbtさんから教えてもらったのですが、10.12.2 betaで直っているようです。
私の手元でも確認しました。

Third Party's Issueで閉じてもらってもよいでしょうか。

% sw_vers
ProductName:    Mac OS X
ProductVersion: 10.12.2
BuildVersion:   16C41b
% ruby2.4 poll_sierra.rb
ruby 2.4.0preview3 (2016-11-07 trunk 56661) [x86_64-darwin16]
Darwin 16.3.0
fds=7, nfds=0, slept=206
fds=7, nfds=1, slept=206
fds=(nil), nfds=0, slept=206 # Fixed!
fds=(nil), nfds=1, slept=0

Updated by znz (Kazuhiro NISHIYAMA) over 3 years ago

  • Status changed from Open to Third Party's Issue

Updated by crb002 (Chad Brewbaker) about 3 years ago

Close? Seems to be fixed. OSX Sierra introduced breaking changes for loading dynamic libraries. Haskell 8 was broken until they released the Darwin source in late November 2016, and Valgrind is still broken on OSX Sierra.
$ sw_vers
ProductName: Mac OS X
ProductVersion: 10.12.2
BuildVersion: 16C67

$ ruby test.rb -v
ruby 2.4.0p0 (2016-12-24 revision 57164) [x86_64-darwin16]
Darwin 16.3.0
fd=7, nfds=0, slept=202
fd=7, nfds=1, slept=201
fd=(nil), nfds=0, slept=205
fd=(nil), nfds=1, slept=1

Updated by shyouhei (Shyouhei Urabe) about 3 years ago

Yes. This issue is marked "Third Party's Issue", which means we have nothing to do. This state is kind of close.

Also available in: Atom PDF