Hacktoberfest 2026:メンテナが10月に向けて印を付けた、オープンで初心者向けの issue。 Hacktoberfest の issue を見る

Is JSON::Coder intended to be thread safe ?

オープン
#1,064 コメント 5 件 リアクション 0 件 担当者 0 名 GitHub で見る

まだ誰も着手していません。

評価

難易度
4/5
見積もり時間
3〜5日
初心者へのやさしさ
38/100
issue の種類
バグ
明瞭さ
おおむね明確
活発さ
活発
技術スタック
json, ruby
領域
backend

調査の方向性

activesupport/lib/active_support/json/encoding.rb の JSON::Coder の共有された作成・再利用箇所から始め、続いて JSON::Coder#dump と #generate の JRuby 上での並行動作を調査します。提供されていれば、報告されたスレッドを使った再現を利用して競合状態を確認します。スレッドセーフティの契約が決定され、動作が文書化されるか回帰テストでカバーされれば完了です。

索引モデルが issue の本文から書いたものです。

説明

In JRuby we hit a race condition: ActiveSupport uses a single shared JSON::Coder
instance and calls #dump on it from multiple threads.

ActiveSupport creates one shared Coder:
https://github.com/rails/rails/blob/v8.1.3.1/activesupport/lib/active_support/json/encoding.rb#L152

…and reuses it on every encode:
https://github.com/rails/rails/blob/v8.1.3.1/activesupport/lib/active_support/json/encoding.rb#L188

The error we got, on a flat object was

JSON::NestingError: nesting of 100 is too deep. Did you try to serialize objects with circular references?

Question: is a single JSON::Coder instance intended to be safe to call
concurrently from multiple threads (i.e. is #dump/#generate on one Coder
intended to be thread-safe)?

Versions: json 2.21.2 (java), JRuby 10.0.5.0, activesupport 8.1.3.1.

I have a small threaded reproduction I can add if useful.

主要言語
Ruby
スター
782
フォーク
383
平均マージ
1日 18時間
マージ済み PR(30日)
10

コントリビューションガイド

このリポジトリのコントリビューションガイドは索引されていません

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

ruby/json のほかの issue

ruby/json の issue をすべて見る

似ている issue

Ruby の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。