バグ #1342
完了
mastodonプラグイン: 長時間放置すると落ちる
cob odo さんが5年以上前に追加.
5年以上前に更新.
説明
低確率で発生するのだと思います。
mastodonプラグインの挙動の問題なのか、atomic
の問題なのか、weakstorage
の問題なのかはよくわかりません。
再現手順
(おそらく何らかのMastodon Worldを登録した状態で?)長時間放置する。
クラッシュ時のエラーメッセージは以下の通り。
/home/cobodo/.rbenv/versions/2.6.3/lib/ruby/2.6.0/monitor.rb:230:in `mon_synchronize': can't add a new key into hash during iteration (RuntimeError)
from /home/cobodo/repos/mikutter/core/lib/weakstorage.rb:29:in `atomic'
from /home/cobodo/repos/mikutter/core/lib/weakstorage.rb:195:in `[]='
from /home/cobodo/repos/mikutter/core/plugin/mastodon/model/status.rb:164:in `merge_or_create'
from /home/cobodo/repos/mikutter/core/plugin/mastodon/model/status.rb:117:in `json2status'
from /home/cobodo/repos/mikutter/core/plugin/mastodon/model/status.rb:96:in `block in build'
from /home/cobodo/repos/mikutter/core/plugin/mastodon/model/status.rb:95:in `map'
from /home/cobodo/repos/mikutter/core/plugin/mastodon/model/status.rb:95:in `build'
from /home/cobodo/repos/mikutter/core/plugin/mastodon_sse_streaming/mastodon_sse_streaming.rb:384:in `update_handler'
from /home/cobodo/repos/mikutter/core/plugin/mastodon_sse_streaming/mastodon_sse_streaming.rb:229:in `block (2 levels) in <top (required)>'
from /home/cobodo/repos/mikutter/vendor/bundle/ruby/2.6.0/gems/pluggaloid-1.1.2/lib/pluggaloid/listener.rb:25:in `call'
from /home/cobodo/repos/mikutter/vendor/bundle/ruby/2.6.0/gems/pluggaloid-1.1.2/lib/pluggaloid/event.rb:116:in `block (2 levels) in call_all_listeners'
from /home/cobodo/repos/mikutter/vendor/bundle/ruby/2.6.0/gems/pluggaloid-1.1.2/lib/pluggaloid/event.rb:115:in `each'
from /home/cobodo/repos/mikutter/vendor/bundle/ruby/2.6.0/gems/pluggaloid-1.1.2/lib/pluggaloid/event.rb:115:in `block in call_all_listeners'
from /home/cobodo/repos/mikutter/vendor/bundle/ruby/2.6.0/gems/pluggaloid-1.1.2/lib/pluggaloid/event.rb:114:in `catch'
from /home/cobodo/repos/mikutter/vendor/bundle/ruby/2.6.0/gems/pluggaloid-1.1.2/lib/pluggaloid/event.rb:114:in `call_all_listeners'
from /home/cobodo/repos/mikutter/vendor/bundle/ruby/2.6.0/gems/pluggaloid-1.1.2/lib/pluggaloid/event.rb:42:in `block in call'
from /home/cobodo/repos/mikutter/vendor/bundle/ruby/2.6.0/gems/delayer-0.0.2/lib/delayer/procedure.rb:24:in `run'
from /home/cobodo/repos/mikutter/vendor/bundle/ruby/2.6.0/gems/delayer-0.0.2/lib/delayer/extend.rb:58:in `run_once'
from /home/cobodo/repos/mikutter/vendor/bundle/ruby/2.6.0/gems/delayer-0.0.2/lib/delayer/extend.rb:30:in `run'
from /home/cobodo/repos/mikutter/vendor/bundle/ruby/2.6.0/gems/delayer-0.0.2/lib/delayer.rb:43:in `method_missing'
from /home/cobodo/repos/mikutter/core/plugin/gtk/delayer.rb:10:in `block in boot'
from /home/cobodo/repos/mikutter/core/plugin/gtk/mainloop.rb:7:in `main'
from /home/cobodo/repos/mikutter/core/plugin/gtk/mainloop.rb:7:in `block in mainloop'
from /home/cobodo/repos/mikutter/core/plugin/gtk/mainloop.rb:6:in `loop'
from /home/cobodo/repos/mikutter/core/plugin/gtk/mainloop.rb:6:in `mainloop'
from ./mikutter.rb:69:in `boot!'
from ./mikutter.rb:105:in `<main>'
同様の問題がちょくちょく報告されています。
WeakStorageは内部で使っている @_storage には外からアクセスしないので、この問題が起こるということはWeakStorageの実装に問題がありそうです。
しかしTwitterなどでもこれが使われているので、問題は思い当たりません。
- ステータス を 実装待ち から レビュー待ち に変更
- 担当者 を cob odo にセット
- ブランチ を topic/1342-weak-store-add-during-iteration にセット
こういうこと(0efbfdc1)なんじゃないかなぁと思うんですが、どう思いますか
今度は値をWeakStorageから取り出すときにtype_strictでエラーが発生するようになったので、原因となった値をもう少し丁寧に解析できるような感じにしてみた。
多分オブジェクト開放時にObjectSpaceのコールバックが正しく呼ばれておらず、同じobject idが全く違うオブジェクトに再利用されたのだと思う。
この問題、多くの人に試用してもらって情報を集める他ないので、一度developにmergeしますが、調査は引き続き行います。
次のエラーです。ご査収ください(エラー送信ダイアログ表示されず)
/home/cobodo/repos/mikutter/core/utils.rb:214:in `each': The #0 value does not matched constraint `Plugin::Mastodon::Status' (TypeStrictError)
from /home/cobodo/repos/mikutter/core/utils.rb:214:in `with_index'
from /home/cobodo/repos/mikutter/core/utils.rb:214:in `type_strict'
from /home/cobodo/repos/mikutter/core/lib/weakstorage.rb:186:in `[]'
from /home/cobodo/repos/mikutter/core/plugin/mastodon/model/status.rb:158:in `merge_or_create'
from /home/cobodo/repos/mikutter/core/plugin/mastodon/model/status.rb:117:in `json2status'
from /home/cobodo/repos/mikutter/core/plugin/mastodon/model/status.rb:96:in `block in build'
from /home/cobodo/repos/mikutter/core/plugin/mastodon/model/status.rb:95:in `map'
from /home/cobodo/repos/mikutter/core/plugin/mastodon/model/status.rb:95:in `build'
from /home/cobodo/repos/mikutter/core/plugin/mastodon_sse_streaming/mastodon_sse_streaming.rb:384:in `update_handler'
from /home/cobodo/repos/mikutter/core/plugin/mastodon_sse_streaming/mastodon_sse_streaming.rb:229:in `block (2 levels) in <top (required)>'
from /home/cobodo/repos/mikutter/vendor/bundle/ruby/2.6.0/gems/pluggaloid-1.1.2/lib/pluggaloid/listener.rb:25:in `call'
from /home/cobodo/repos/mikutter/vendor/bundle/ruby/2.6.0/gems/pluggaloid-1.1.2/lib/pluggaloid/event.rb:116:in `block (2 levels) in call_all_listeners'
from /home/cobodo/repos/mikutter/vendor/bundle/ruby/2.6.0/gems/pluggaloid-1.1.2/lib/pluggaloid/event.rb:115:in `each'
from /home/cobodo/repos/mikutter/vendor/bundle/ruby/2.6.0/gems/pluggaloid-1.1.2/lib/pluggaloid/event.rb:115:in `block in call_all_listeners'
from /home/cobodo/repos/mikutter/vendor/bundle/ruby/2.6.0/gems/pluggaloid-1.1.2/lib/pluggaloid/event.rb:114:in `catch'
from /home/cobodo/repos/mikutter/vendor/bundle/ruby/2.6.0/gems/pluggaloid-1.1.2/lib/pluggaloid/event.rb:114:in `call_all_listeners'
from /home/cobodo/repos/mikutter/vendor/bundle/ruby/2.6.0/gems/pluggaloid-1.1.2/lib/pluggaloid/event.rb:42:in `block in call'
from /home/cobodo/repos/mikutter/vendor/bundle/ruby/2.6.0/gems/delayer-0.0.2/lib/delayer/procedure.rb:24:in `run'
from /home/cobodo/repos/mikutter/vendor/bundle/ruby/2.6.0/gems/delayer-0.0.2/lib/delayer/extend.rb:58:in `run_once'
from /home/cobodo/repos/mikutter/vendor/bundle/ruby/2.6.0/gems/delayer-0.0.2/lib/delayer/extend.rb:30:in `run'
from /home/cobodo/repos/mikutter/vendor/bundle/ruby/2.6.0/gems/delayer-0.0.2/lib/delayer.rb:43:in `method_missing'
from /home/cobodo/repos/mikutter/core/plugin/gtk/delayer.rb:10:in `block in boot'
from /home/cobodo/repos/mikutter/core/plugin/gtk/mainloop.rb:7:in `main'
from /home/cobodo/repos/mikutter/core/plugin/gtk/mainloop.rb:7:in `block in mainloop'
from /home/cobodo/repos/mikutter/core/plugin/gtk/mainloop.rb:6:in `loop'
from /home/cobodo/repos/mikutter/core/plugin/gtk/mainloop.rb:6:in `mainloop'
from ./mikutter.rb:69:in `boot!'
from ./mikutter.rb:105:in `<main>'
別の経路からのエラーです。
/home/cobodo/repos/mikutter/core/utils.rb:216:in `block in type_strict': The #0 value does not matched constraint `Plugin::Mastodon::Account' (TypeStrictError)
from /home/cobodo/repos/mikutter/core/utils.rb:214:in `each'
from /home/cobodo/repos/mikutter/core/utils.rb:214:in `with_index'
from /home/cobodo/repos/mikutter/core/utils.rb:214:in `type_strict'
from /home/cobodo/repos/mikutter/core/lib/weakstorage.rb:186:in `[]'
from /home/cobodo/repos/mikutter/core/plugin/mastodon/model/account.rb:103:in `findbyacct'
from /home/cobodo/repos/mikutter/core/plugin/mastodon/model/status.rb:280:in `block in retweeted_by'
from /home/cobodo/repos/mikutter/core/plugin/mastodon/model/status.rb:280:in `map'
from /home/cobodo/repos/mikutter/core/plugin/mastodon/model/status.rb:280:in `retweeted_by'
from /home/cobodo/repos/mikutter/core/mui/cairo_sub_parts_share.rb:18:in `get_default_votes'
from /home/cobodo/repos/mikutter/core/mui/cairo_sub_parts_voter.rb:14:in `initialize'
from /home/cobodo/repos/mikutter/core/mui/cairo_sub_parts_helper.rb:22:in `new'
from /home/cobodo/repos/mikutter/core/mui/cairo_sub_parts_helper.rb:22:in `block in subparts'
from /home/cobodo/repos/mikutter/core/mui/cairo_sub_parts_helper.rb:22:in `map'
from /home/cobodo/repos/mikutter/core/mui/cairo_sub_parts_helper.rb:22:in `subparts'
from /home/cobodo/repos/mikutter/core/lib/uithreadonly.rb:22:in `block (2 levels) in singleton class'
from /home/cobodo/repos/mikutter/core/mui/cairo_sub_parts_helper.rb:42:in `_subparts_height'
from /home/cobodo/repos/mikutter/core/mui/cairo_sub_parts_helper.rb:35:in `subparts_height'
from /home/cobodo/repos/mikutter/core/lib/uithreadonly.rb:22:in `block (2 levels) in singleton class'
from /home/cobodo/repos/mikutter/core/mui/cairo_coordinate_module.rb:49:in `height'
from /home/cobodo/repos/mikutter/core/lib/uithreadonly.rb:22:in `block (2 levels) in singleton class'
from /home/cobodo/repos/mikutter/core/mui/cairo_cell_renderer_message.rb:145:in `render_message'
from /home/cobodo/repos/mikutter/core/mui/cairo_cell_renderer_message.rb:128:in `uri='
from /home/cobodo/repos/mikutter/core/plugin/gtk/mainloop.rb:7:in `main'
from /home/cobodo/repos/mikutter/core/plugin/gtk/mainloop.rb:7:in `block in mainloop'
from /home/cobodo/repos/mikutter/core/plugin/gtk/mainloop.rb:6:in `loop'
from /home/cobodo/repos/mikutter/core/plugin/gtk/mainloop.rb:6:in `mainloop'
from ./mikutter.rb:69:in `boot!'
from ./mikutter.rb:105:in `<main>'
- ステータス を レビュー待ち から 実装待ち に変更
- 担当者 を cob odo から toshi_a 初音 に変更
cob odo さんは書きました:
別の経路からのエラーです。
[...]
ありがとうございます。 #1342-4 のバックトレースは #1342-5 や #1342-6 と同じです。これだけ方針を決めれば解決ですね。
- ステータス を 実装待ち から レビュー待ち に変更
- 担当者 を toshi_a 初音 から cob odo に変更
WeakRefのコードを読んだところ、そちらのほうがObjectSpaceを使うよりも筋が良さそうだったので、WeakStorageの内部実装を変更しました。
developにmergeしました。これで使ってみてレビューしてください。
ありがとうございます。今日の午後は1時間おきに落ちているような始末でしたが今は安定しているように見受けられます。
1~2日様子を見てみます。
丸2日落ちなかったので大丈夫そうです。すでにdevelopにマージ済みですので、終了にしておきますね。
他の形式にエクスポート: Atom
PDF