Project

General

Profile

バグ #1342

mastodonプラグイン: 長時間放置すると落ちる

Added by cob odo 2 months ago. Updated 2 months ago.

Status:
終了
Priority:
通常
Assignee:
Target version:
プラグイン名:
mastodon
ブランチ:
topic/1342-weak-store-add-during-iteration
クラッシュする:
Yes

Description

低確率で発生するのだと思います。
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>'

Associated revisions

Revision 0efbfdc1 (diff)
Added by toshi_a 初音 2 months ago

多分治ったと思うからmergeしようぜ refs #1342

Revision 4652a7e0 (diff)
Added by toshi_a 初音 2 months ago

type_strictでクラッシュする時、原因となった値も送る refs #1342

Revision 5756e5cb (diff)
Added by toshi_a 初音 2 months ago

[weakstorage] ObjectSpaceを利用するのをやめ、WeakRefを用いる refs #1342

Revision 549497a8 (diff)
Added by toshi_a 初音 2 months ago

WeakStorageが開放された参照にアクセスしようとした時に、他の開放済み参照を全て破棄する refs #1342

History

#1

Updated by toshi_a 初音 2 months ago

  • Status changed from 分類待ち to 実装待ち

同様の問題がちょくちょく報告されています。
WeakStorageは内部で使っている @_storage には外からアクセスしないので、この問題が起こるということはWeakStorageの実装に問題がありそうです。
しかしTwitterなどでもこれが使われているので、問題は思い当たりません。

#2

Updated by toshi_a 初音 2 months ago

  • Status changed from 実装待ち to レビュー待ち
  • Assignee set to cob odo
  • ブランチ set to topic/1342-weak-store-add-during-iteration

こういうこと(0efbfdc1)なんじゃないかなぁと思うんですが、どう思いますか

#3

Updated by toshi_a 初音 2 months ago

今度は値をWeakStorageから取り出すときにtype_strictでエラーが発生するようになったので、原因となった値をもう少し丁寧に解析できるような感じにしてみた。
多分オブジェクト開放時にObjectSpaceのコールバックが正しく呼ばれておらず、同じobject idが全く違うオブジェクトに再利用されたのだと思う。

#4

Updated by toshi_a 初音 2 months ago

この問題、多くの人に試用してもらって情報を集める他ないので、一度developにmergeしますが、調査は引き続き行います。

#5

Updated by cob odo 2 months ago

次のエラーです。ご査収ください(エラー送信ダイアログ表示されず)

/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>'
#6

Updated by cob odo 2 months ago

別の経路からのエラーです。

/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>'
#7

Updated by toshi_a 初音 2 months ago

  • Status changed from レビュー待ち to 実装待ち
  • Assignee changed from cob odo to toshi_a 初音

cob odo さんは書きました:

別の経路からのエラーです。

[...]

ありがとうございます。 #1342-4 のバックトレースは #1342-5#1342-6 と同じです。これだけ方針を決めれば解決ですね。

#8

Updated by toshi_a 初音 2 months ago

  • Status changed from 実装待ち to レビュー待ち
  • Assignee changed from toshi_a 初音 to cob odo

WeakRefのコードを読んだところ、そちらのほうがObjectSpaceを使うよりも筋が良さそうだったので、WeakStorageの内部実装を変更しました。

#9

Updated by toshi_a 初音 2 months ago

developにmergeしました。これで使ってみてレビューしてください。

#10

Updated by cob odo 2 months ago

ありがとうございます。今日の午後は1時間おきに落ちているような始末でしたが今は安定しているように見受けられます。
1~2日様子を見てみます。

#11

Updated by cob odo 2 months ago

  • Status changed from レビュー待ち to 終了

丸2日落ちなかったので大丈夫そうです。すでにdevelopにマージ済みですので、終了にしておきますね。

Also available in: Atom PDF