dotnet / dotnet/linker

Potential broken recursion in CompilerGeneratedState

Open
#2,857 0 comments 0 reactions 0 assignees View on GitHub
area-Linker: Diagnostic
Dominant language
C#
Stars
392
Forks
128
Avg merge
2d 10h
Merged PRs (30d)
2

Description

There's a potential recursion in the `CompilerGeneratedState` which could lead to stack overflow.

Populating the cache for a type in `PopulateCacheForType` may end up producing warnings, for example here:
https://github.com/dotnet/linker/blob/17033869c8e75e3805ba42af4c5509af72c8bb72/src/linker/Linker/CompilerGeneratedState.cs#L176

But the logging infra will go check for warning suppressions which will end up calling `CompilerGeneratedState.TryGetOwningMethodForCompilerGeneratedMember` which can call back to `PopulateCacheForType`:
https://github.com/dotnet/linker/blob/17033869c8e75e3805ba42af4c5509af72c8bb72/src/linker/Linker/CompilerGeneratedState.cs#L404

If this happens on the same type, it could lead to endless recursion.

I didn't try to come up with a repro as it probably involves handcrafting IL...

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.