You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
fix(stats): break EnsureFullStatsComputed recursion in errorstats/modelstats/predictionstats
Same bug class as the earlier BasicStats fix: the Calculate* method was
assigning to properties AND reading them back during its own body, but
the property getters call EnsureFullStatsComputed — which is still
running the Calculate* method. The _fullStatsComputed flag only flips
after Calculate* returns, so any intra-method property read re-enters
Calculate* unbounded. The test host crashes with StackOverflowException
before the test framework can report anything except "host process
exited unexpectedly."
Specific re-entry points the previous code had:
* ErrorStats.CalculateErrorStats
- RMSE = _numOps.Sqrt(MSE) ← re-enters via MSE getter
- AIC/BIC/AICAlt pass RSS ← re-enters via RSS getter
* ModelStats.CalculateModelStats
- VIFList = ... CalculateVIF(CorrelationMatrix, ...) ← CorrelationMatrix
- Mahalanobis block reads CovarianceMatrix thrice ← CovarianceMatrix
* PredictionStats.CalculatePredictionStats
- AdjustedR2 = ... CalculateAdjustedR2(R2, ...) ← R2
- PredictionIntervalCoverage = ... (PredictionInterval.Lower,
PredictionInterval.Upper) ← PredictionInterval
- ConfidenceInterval/CredibleInterval read BestDistributionFit
.DistributionType ← BestDistributionFit
All three methods are rewritten to compute every intermediate into a
local variable first; properties are only assigned once every dependency
is a local. No property reads happen inside Calculate*, so the lazy
getter never re-enters.
Observed failure path (Classification CI shard, PR #1156 run):
AdaBoostClassifierTests.Predict_ShouldBeDeterministic trains the
model, which computes ErrorStats, which stack-overflows the host.
Other crashed tests in the same shard:
- ExtraTreesClassifierTests.Clone_ShouldProduceIdenticalPredictions
- CategoricalNaiveBayesTests.Builder_AccuracyShouldBeatChance
- OneVsRestClassifierTests.Builder_AccuracyShouldBeatChance
All 4 pass locally after this fix.
Unblocks the host_crash jobs on PR #1154 triage:
- ModelFamily - Classification
- ModelFamily - Clustering/GP
- ModelFamily - Regression
- ModelFamily - TimeSeries/Activation/Loss
- Unit - 04 Feature/Fit/Fitness/Genetics
- AiDotNet.Serving.Tests
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
0 commit comments