Make base-type collection stack-safe for deep inheritance chains

Aperta
#4,357 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
4/5
Tempo stimato
3-5 giorni
Idoneità per principianti
55/100
Tipo di issue
Bug
Chiarezza
Specificata chiaramente
Stato di attività
Attiva
Stack tecnologico
csharp
Ambito
backend

Direzione di ricerca

Start with BaseTypeCollector.CollectBaseTypes() and the GetNonInterfaceBaseTypes() callsites mentioned for deconstruction and BAML. Trace how collection currently detects cycles and orders base types, then find the relevant test project and add coverage for a deep acyclic inheritance chain. Done means traversal completes without stack overflow while preserving cycle detection and base-before-derived ordering.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

Follow-up to PR #4336 and finding ANT-2026-OLTG8WBX.

PR #4336 fixes the reported short cyclic-base walks by using GetNonInterfaceBaseTypes(). That helper delegates to recursive BaseTypeCollector.CollectBaseTypes(), so sufficiently deep inheritance chains can still exhaust the process stack before traversal completes (or before a long cycle is detected). The PR's deconstruction and BAML callsites now use this recursive path.

Reproduced against PR head 94b35ee08da199645594783cd3ec93c3e6afbcd5 on .NET 11: a metadata assembly with 150,000 classes in one inheritance chain (T0 : System.Object, each subsequent Tn : Tn-1) causes T149999.GetNonInterfaceBaseTypes().Count() to terminate with Stack overflow, after about 47,575 repeated BaseTypeCollector.CollectBaseTypes() frames. The previous iterative DirectBaseTypes walk completed and counted 150,001 types.

Consider making base-type collection iterative while preserving its cycle detection and base-before-derived ordering, and add coverage for a deep acyclic chain (and, if useful, a long cycle).

Assisted-by: OpenCode:gpt-6-luna:OpenCode

Lingua principale
C#
Stelle
27.1k
Fork
3.8k
Merge medio
1g 23h
PR unite (30g)
44

Preparare l'ambiente

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di icsharpcode/ILSpy

Tutte le issue di icsharpcode/ILSpy

Issue simili

Altre issue su C#

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.