Scanning a just-removed custom Python consolidator can crash the engine
Los mantenedores suelen responder en 1 día
Nadie ha tomado este issue todavía.
Evaluación
- Dificultad
- 3/5
- Tiempo estimado
- 1-2 días
- Aptitud para principiantes
- 77/100
Línea de trabajo
Start with Common/Data/SubscriptionManager.cs around ScanPastConsolidators, then trace removal through ConsolidatorWrapper.cs and its disposed guard. Run the supplied NUnit reproduction using Python.Runtime and QuantConnect.Tests.Engine.DataFeeds; done means removing a custom Python consolidator before its first scan does not access it again, and the scan completes without an active registration.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
Problem
On master at 8a0c6494f, adding a custom Python consolidator and removing it before its first scan leaves a disposed entry in _consolidatorsToAdd. The next ScanPastConsolidators calls AdvanceScanTime on that entry before checking Disposed. AdvanceScanTime reads WorkingData through the disposed Python adapter, which can crash the process.
This requires only one registration, not duplicate registration or sharing a consolidator between indicators.
Reproduction
The following uses Lean's existing NUnit test support (Python.Runtime, QuantConnect.Tests.Engine.DataFeeds):
using var gil = Py.GIL();
using var module = PyModule.FromString("pending_scan_removal", @"
from AlgorithmImports import *
class CustomConsolidator(PythonConsolidator):
def __init__(self):
self.consolidated = None
self.working_data = None
self.input_type = TradeBar
self.output_type = TradeBar
def update(self, data):
pass
def scan(self, time):
pass
def prepare(algorithm):
symbol = algorithm.add_equity('SPY').symbol
source = CustomConsolidator()
algorithm.subscription_manager.add_consolidator(symbol, source)
algorithm.subscription_manager.remove_consolidator(symbol, source)
");
var algorithm = new AlgorithmStub();
using var pyAlgorithm = algorithm.ToPython();
using var result = module.GetAttr("prepare").Invoke(pyAlgorithm);
algorithm.SubscriptionManager.ScanPastConsolidators(
algorithm.UtcTime.AddDays(1), algorithm);
Observed against the base implementation: the test host crashes during the final call. The add/remove calls are made from Python, so this does not depend on reusing a disposed C# PyObject handle.
Cause and required outcome
Common/Data/SubscriptionManager.cs:350-355advances every pending scan entry unconditionally.- Removal marks its
ConsolidatorWrapperdisposed, but does not remove it from that pending collection. Common/Data/ConsolidatorWrapper.cs:127reads the disposed adapter'sWorkingData.- The disposed-entry guard in
ScanPastConsolidatorsonly runs later, when dequeuing from the priority queue.
Removing a consolidator before its first scan must not read or invoke it again, and the next scan must complete without a retained active registration. A suggested fix is to discard disposed pending entries before advancing/enqueuing them, with regression coverage for a custom Python consolidator removed before its first scan.
Priority P2: confirmed process termination in an early-cleanup case, without evidence of widespread impact.
- Lenguaje dominante
- C#
- Estrellas
- 22.6k
- Forks
- 5.4k
- Merge medio
- 11 h 39 min
- PR fusionados (30 d)
- 104
Preparar el entorno
Inicia el contenedor de desarrollo del proyecto en tu navegador, con tu propia cuenta de GitHub.
- Incluye un Dockerfile o un archivo de Docker Compose
- Tiene una plantilla de pull request
- Leer la guía de contribución
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Más de QuantConnect/Lean
-
priority:p2
Dificultad 2/5 1-3 horas Aptitud para principiantes 72/100
QuantConnect/Lean#10216 ·
Los mantenedores suelen responder en 1 día
-
priority:p2
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
QuantConnect/Lean#10206 ·
Los mantenedores suelen responder en 1 día
-
priority:p2
Dificultad 2/5 1-3 horas Aptitud para principiantes 85/100
QuantConnect/Lean#10199 ·
Los mantenedores suelen responder en 1 día
-
priority:p2
Dificultad 2/5 1-3 horas Aptitud para principiantes 76/100
QuantConnect/Lean#10198 ·
Los mantenedores suelen responder en 1 día
-
priority:p2
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
QuantConnect/Lean#10197 ·
Los mantenedores suelen responder en 1 día
Todos los issues de QuantConnect/Lean
Issues similares
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 66/100
dotnet-outdated/dotnet-outdated#871 ·
Los mantenedores suelen responder en 1 día
-
triage/untriaged
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
unoplatform/uno#26676 ·
Los mantenedores suelen responder en 1 día
-
.NET bug
Dificultad 2/5 1-3 horas Aptitud para principiantes 84/100
Los mantenedores suelen responder en 1 día
-
[问题] 导出文件时,提示后面还有1243390911步Abiertobug
Dificultad 2/5 1-3 horas Aptitud para principiantes 62/100
jhaizhou-ops/S2Arm#2177 · 3 comentarios ·
Los mantenedores suelen responder en 1 día
-
area-CodeGen-coreclr untriaged
Dificultad 2/5 1-3 horas Aptitud para principiantes 65/100
dotnet/runtime#138181 · 1 comentario ·
Los mantenedores suelen responder en 1 día