Unity-Technologies / Unity-Technologies/com.unity.netcode.gameobjects
Please error, or at least warn, when a managed type is included in INetworkSerializeByMemcpy
還沒有人認領這個 Issue。
- 主要語言
- C#
- 星號
- 2.3k
- 分支
- 461
- 平均合併
- 3 天 16 小時
- 30 天內合併 PR
- 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 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
- Fork 儲存庫,在一個分支上完成修改。
- 送出 Pull Request,並在描述裡引用這個 Issue 編號。
研究方向
首先定位 INetworkSerializeByMemcpy 的定義及其驗證或序列化測試。追蹤實作該介面的型別在編譯期間或執行階段如何受到檢查,然後為 string 欄位和其他受管理欄位新增涵蓋;當此類型別產生建置錯誤或警告,而不是進行不安全的 memcpy 序列化時,即表示完成。
由索引模型根據 Issue 內容生成。
評估
- 技術堆疊
- csharp
- 領域
- networking
- Issue 類型
- 功能
- 難度
- 4/5
- 預估耗時
- 3-5 天
- 活躍度
- 冷清
- 描述清晰度
- 基本清楚
- 新手友好度
- 48/100