Unity-Technologies / Unity-Technologies/com.unity.netcode.gameobjects

Please error, or at least warn, when a managed type is included in INetworkSerializeByMemcpy

Ouverte
#3,830 7 commentaires 0 réactions 0 personnes assignées Voir sur GitHub

Personne n'a encore pris cette issue.

Tracking type:feature
Langage dominant
C#
Étoiles
2.3k
Forks
461
Merge moyen
3 j 16 h
PR mergées (30 j)
20

Description

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.

Guide de contribution

Ouvrir le guide de contribution

Par où commencer

  1. Lisez l'issue en entier, puis le guide de contribution du projet.
  2. Signalez en commentaire que vous la prenez — cela évite que deux personnes fassent le même travail.
  3. Forkez le dépôt et travaillez sur une branche.
  4. Ouvrez une pull request qui référence le numéro de l'issue.

Piste de recherche

Commencez par localiser la définition de INetworkSerializeByMemcpy ainsi que ses tests de validation ou de sérialisation. Suivez la manière dont les types qui l’implémentent sont vérifiés lors de la compilation ou de l’exécution, puis ajoutez une couverture pour les champs de type string et les autres champs managés ; le travail sera considéré comme terminé lorsque ces types produiront une erreur ou un avertissement de build au lieu d’une sérialisation memcpy non sûre.

Rédigé par le modèle d'indexation à partir du texte de l'issue.

Évaluation

Stack technique
csharp
Domaine
networking
Type d'issue
Fonctionnalité
Difficulté
4/5
Temps estimé
3-5 jours
Activité
Calme
Clarté
Plutôt claire
Accessibilité débutants
48/100

Recevez les nouvelles issues par e-mail

Un résumé court des issues GitHub adaptées aux débutants.