Introspection fails when called multiple times in threads
まだ誰も着手していません。
評価
- 難易度
- 4/5
- 見積もり時間
- 3〜5日
- 初心者へのやさしさ
- 30/100
- issue の種類
- バグ
- 明瞭さ
- 説明が足りない
- 活発さ
- 停滞
- 技術スタック
- ruby
調査の方向性
Start by running the provided multiple_dbus_calls.rb reproducer and inspect the reported paths in lib/dbus/bus.rb, lib/dbus/message_queue.rb, lib/dbus/marshall.rb, and lib/dbus/proxy_object.rb. Trace concurrent introspection through send_sync and message parsing; done means the reproducer no longer raises DBus::InvalidPacketException under multiple threads, with coverage for the failure.
索引モデルが issue の本文から書いたものです。
説明
I am trying to build a Rails application that regularly checks network status, Systemd service status etc. showing them on the UI. I need to use Puma which works with threads. When the application makes calls to DBus we start getting DBus::InvalidPacketException over and over during introspection. I am not sure if it is because of using threads, or if threads just makes it easier to reproduce (ex. calling DBus too fast).
I see it happen on OpenSUSE 42.3 and Ubuntu 16.04. Happens with Ruby 2.4.3 and 2.3.6, did not try other Ruby versions. This is reproducable with 2 threads too. Systemd is just an example, issue happens when calling NetworkManager too.
require 'dbus'
PARALLEL = 5
UNIT_NAME = 'ruby_dbus_test.service'
def local_service_unit_is_active(k)
puts "current thread #{Thread.current[:num]}\n"
sys_bus = DBus.system_bus
core_service = sys_bus.service('org.freedesktop.systemd1')
obj = core_service.object('/org/freedesktop/systemd1')
obj.default_iface = 'org.freedesktop.systemd1'
puts "before obj.introspect #{Thread.current[:num]}\n"
obj.introspect
puts "after obj.introspect #{Thread.current[:num]}\n"
obj
end
def build_thread(k)
Thread.new do
Thread.current.abort_on_exception = true
Thread.current[:num] = k
resp = local_service_unit_is_active(UNIT_NAME)
puts "\nFINISHED: result for #{k} active: #{resp.bus.inspect}\n"
end
end
threads = []
PARALLEL.times do |k|
puts "building thread #{k + 1} out of #{PARALLEL}"
threads << build_thread(k)
end
threads.each(&:join)
and the errors I get changes time to time but they all look like introspection data is not correct so it is not parsed properly
/home/zaburt/.rvm/gems/ruby-2.4.3@dbus_test/gems/ruby-dbus-0.14.1/lib/dbus/marshall.rb:183:in `do_parse': DBus::InvalidPacketException (DBus::InvalidPacketException)
from /home/zaburt/.rvm/gems/ruby-2.4.3@dbus_test/gems/ruby-dbus-0.14.1/lib/dbus/marshall.rb:62:in `block in unmarshall'
from /home/zaburt/.rvm/gems/ruby-2.4.3@dbus_test/gems/ruby-dbus-0.14.1/lib/dbus/marshall.rb:61:in `each'
from /home/zaburt/.rvm/gems/ruby-2.4.3@dbus_test/gems/ruby-dbus-0.14.1/lib/dbus/marshall.rb:61:in `unmarshall'
from /home/zaburt/.rvm/gems/ruby-2.4.3@dbus_test/gems/ruby-dbus-0.14.1/lib/dbus/message.rb:201:in `unmarshall_buffer'
from /home/zaburt/.rvm/gems/ruby-2.4.3@dbus_test/gems/ruby-dbus-0.14.1/lib/dbus/message_queue.rb:139:in `message_from_buffer_nonblock'
from /home/zaburt/.rvm/gems/ruby-2.4.3@dbus_test/gems/ruby-dbus-0.14.1/lib/dbus/message_queue.rb:38:in `pop'
from /home/zaburt/.rvm/gems/ruby-2.4.3@dbus_test/gems/ruby-dbus-0.14.1/lib/dbus/bus.rb:441:in `wait_for_message'
from /home/zaburt/.rvm/gems/ruby-2.4.3@dbus_test/gems/ruby-dbus-0.14.1/lib/dbus/bus.rb:458:in `send_sync'
from /home/zaburt/.rvm/gems/ruby-2.4.3@dbus_test/gems/ruby-dbus-0.14.1/lib/dbus/bus.rb:339:in `send_sync_or_async'
from /home/zaburt/.rvm/gems/ruby-2.4.3@dbus_test/gems/ruby-dbus-0.14.1/lib/dbus/bus.rb:365:in `introspect_data'
from /home/zaburt/.rvm/gems/ruby-2.4.3@dbus_test/gems/ruby-dbus-0.14.1/lib/dbus/proxy_object.rb:73:in `introspect'
from ./multiple_dbus_calls.rb:18:in `local_service_unit_is_active'
from ./multiple_dbus_calls.rb:28:in `block in build_thread'
/home/zaburt/.rvm/gems/ruby-2.4.3@dbus_test/gems/ruby-dbus-0.14.1/lib/dbus/marshall.rb:103:in `read_string': String is not nul-terminated (DBus::InvalidPacketException)
from /home/zaburt/.rvm/gems/ruby-2.4.3@dbus_test/gems/ruby-dbus-0.14.1/lib/dbus/marshall.rb:212:in `do_parse'
from /home/zaburt/.rvm/gems/ruby-2.4.3@dbus_test/gems/ruby-dbus-0.14.1/lib/dbus/marshall.rb:62:in `block in unmarshall'
from /home/zaburt/.rvm/gems/ruby-2.4.3@dbus_test/gems/ruby-dbus-0.14.1/lib/dbus/marshall.rb:61:in `each'
from /home/zaburt/.rvm/gems/ruby-2.4.3@dbus_test/gems/ruby-dbus-0.14.1/lib/dbus/marshall.rb:61:in `unmarshall'
from /home/zaburt/.rvm/gems/ruby-2.4.3@dbus_test/gems/ruby-dbus-0.14.1/lib/dbus/message.rb:227:in `unmarshall_buffer'
from /home/zaburt/.rvm/gems/ruby-2.4.3@dbus_test/gems/ruby-dbus-0.14.1/lib/dbus/message_queue.rb:139:in `message_from_buffer_nonblock'
from /home/zaburt/.rvm/gems/ruby-2.4.3@dbus_test/gems/ruby-dbus-0.14.1/lib/dbus/message_queue.rb:38:in `pop'
from /home/zaburt/.rvm/gems/ruby-2.4.3@dbus_test/gems/ruby-dbus-0.14.1/lib/dbus/bus.rb:441:in `wait_for_message'
from /home/zaburt/.rvm/gems/ruby-2.4.3@dbus_test/gems/ruby-dbus-0.14.1/lib/dbus/bus.rb:453:in `send_sync'
from /home/zaburt/.rvm/gems/ruby-2.4.3@dbus_test/gems/ruby-dbus-0.14.1/lib/dbus/bus.rb:339:in `send_sync_or_async'
from /home/zaburt/.rvm/gems/ruby-2.4.3@dbus_test/gems/ruby-dbus-0.14.1/lib/dbus/bus.rb:365:in `introspect_data'
from /home/zaburt/.rvm/gems/ruby-2.4.3@dbus_test/gems/ruby-dbus-0.14.1/lib/dbus/proxy_object.rb:73:in `introspect'
from ./multiple_dbus_calls.rb:18:in `local_service_unit_is_active'
from ./multiple_dbus_calls.rb:28:in `block in build_thread'
You can find the sample script to reproduce the issue (no Rails, just Ruby) and some info here too https://github.com/zaburt/ruby-dbus-test . I can try out any test code or suggestions.
- 主要言語
- Ruby
- スター
- 174
- フォーク
- 51
- PR マージ指標
- 30日以内にマージされた PR はありません
環境構築
このプロジェクトには開発コンテナ、Dockerfile、コントリビューションガイドがありません。まず README を読み、一般的な手順ははじめてのコントリビューションガイドを参照してください。
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
mvidner/ruby-dbus のほかの issue
-
難易度 3/5 1〜2日 初心者へのやさしさ 35/100
-
Rexml or Nokogiri?オープン
難易度 5/5 1週間以上 初心者へのやさしさ 25/100
-
NetworkManager.Settings.Connection cannot round-trip, calling Update with what GetSettings returnedオープン
難易度 4/5 3〜5日 初心者へのやさしさ 35/100
-
good first issue
難易度 2/5 1〜3時間 初心者へのやさしさ 45/100
-
難易度 5/5 1週間以上 初心者へのやさしさ 25/100
mvidner/ruby-dbus の issue をすべて見る
似ている issue
-
難易度 1/5 1〜3時間 初心者へのやさしさ 94/100
zerocracy/judges-action#2803 ·
メンテナーはふだん 5 日以内に返信
-
Again Fix typo in comment in formatOnboardingAlertMessage [File :- course utils]対応中かも @ThakuraAnki が今日担当しました。 オープンbug
難易度 1/5 1時間未満 初心者へのやさしさ 95/100
WikiEducationFoundation/WikiEduDashboard#7158 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
-
enhancement
難易度 2/5 半日 初心者へのやさしさ 70/100
ericsaupe/scavenger-hunt#367 ·
メンテナーはふだん 1 日以内に返信
-
Feature Feature Parity
難易度 2/5 1〜3時間 初心者へのやさしさ 82/100
valkey-io/valkey-glide-ruby#369 ·
メンテナーはふだん 2 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 85/100
メンテナーはふだん 1 日以内に返信