Unity-Technologies / Unity-Technologies/com.unity.netcode.gameobjects
Please error, or at least warn, when a managed type is included in INetworkSerializeByMemcpy
まだ誰も着手していません。
- 主要言語
- C#
- スター
- 2.3k
- フォーク
- 461
- 平均マージ
- 3日 16時間
- マージ済み PR(30日)
- 20
説明
Is your feature request related to a problem? Please describe.
My coworker was unfamiliar with INetworkSerializeByMemcpy and the FixedStringNNNBytes types, and added a string field to an existing INetworkSerializeByMemcpy struct. This caused me great headaches (it made it into a publicly released patch), trying to track down segfault heap corruption that only showed up in very specific multiplayer circumstances (the string was normally null, which probably masked the issue).
Describe the solution you'd like
Please cause a build error when a managed type (a class, a string, or the like) is included in an INetworkSerializeByMemcpy type. I cannot think of any use case where it would be valid or intended to serialize a managed GC pointer by memcpy. At least a warning if nothing else.
It doesn't have to be perfect, even just checking for string would be lovely - string specifically is such a massive footgun, it's so easy to accidentally include and think it'll work fine. The fact it crashes later on via unrelated segfault heap corruption bringing down the editor, instead of a C# Exception, is especially rough.
コントリビューションガイド
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
調査の方向性
まず INetworkSerializeByMemcpy の定義と、その検証またはシリアライズのテストを見つけます。実装する型がコンパイル時または実行時にどのようにチェックされるかを追跡し、その後、string フィールドやその他のマネージド フィールドのカバレッジを追加します。このような型が安全でない memcpy シリアライズを行う代わりに、ビルドエラーまたは警告を生成すれば完了です。
索引モデルが issue の本文から書いたものです。
評価
- 技術スタック
- csharp
- 領域
- networking
- issue の種類
- 機能追加
- 難易度
- 4/5
- 見積もり時間
- 3〜5日
- 活発さ
- 静か
- 明瞭さ
- おおむね明確
- 初心者へのやさしさ
- 48/100