Skip to content

Infinite recursion in EquatableArray<T>.Equals(obj) crashes ServiceHub.RoslynCodeAnalysisService.exe #84

@mdavis

Description

@mdavis

I've seen that you have an updated version of this code elsewhere that appears to not have this problem, but I apparently found this one instead and spent days pulling my hair out trying to figure out why the Roslyn code analysis service kept crashing on me.

In this line:

return obj is EquatableArray<T> array && Equals(this, array);

the call to Equals(this, array) will end up recursively calling Equals(object), creating an infinite recursion and eventual stack overflow. In VS, this will cause the ServiceHub.RoslynCodeAnalysisService.exe process to crash, and a bunch of "Feature 'x' is currently unavailable due to an internal error" messages will appear (and frequently VS will hang and restart itself soon afterward if you keep trying to edit code). Regular builds aren't affected, presumably because the equality methods never get called in a standalone build.

Your newer version calls the Equals(EquatableArray<T>) overload, so it should be fine: https://github.com/andrewlock/NetEscapades.EnumGenerators/blob/81c2bb340665f379a2af752360cad6df90d51d29/src/NetEscapades.EnumGenerators/EquatableArray.cs#L36

I at least wanted to document this for the sake of anyone else who finds this code and tries to use it. It might also be helpful if you could update this copy of the code to fix the bug and/or redirect people to the fixed version in the other repository somehow.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions