Multiplayer
Multiplayer copied to clipboard
Fixed potential infinite recursion `ISyncSimple` crashes
Calls to SyncSerialization.CanHandle
can cause a crash due to infinite recursion when used with a subtype of ISyncSimple
.
The crash would happen when a subtype of ISyncSimple
would have a ISyncSimple
field. The CanHandle
checks all fields of a type implementing ISyncSimple
, as well as all its subtypes, to see if they can be synced. However, as it encounters ISyncSimple
during the check, it would then check if it can sync ISyncSimple
, which would then check if it can sync ISyncSimple
again and again until a crash.
I've originally attempted to fix this by modifying the conditions to skip in specific situations, like the type being an interface, or for recursively checking subtypes of self, etc. - this ended up very messy, and I would just end up finding another example that would cause a crash. I've opted out for this solution as it should handle all of the weird edge cases we may encounter.
Some simple examples of types that would cause a crash:
class TestSync : ISyncSimple
{
ISyncSimple test;
}
class TestSync : ISyncSimple
{
List<ISyncSimple> test;
}