osu/osu.Game/Beatmaps
Dean Herbert 8a0b975d71 Fix deadlock scenario when calculating fallback difficulty
The previous code would run a calcaulation for the beatmap's own ruleset
if the current one failed. While this does make sense, with the current
way we use this component (and the implementation flow) it is quite unsafe.

The to the call on `.Result` in the `catch` block, this would 100%
deadlock due to the thread concurrency of the `ThreadedTaskScheduler`
being 1. Even if the nested run could be run inline (it should be), the
task scheduler won't even get to the point of checking whether this is
feasible due to it being saturated by the already running task.

I'm not sure if we still need this fallback lookup logic. After removing
it, it's feasible that 0 stars will be returned during the scenario that
previously caused a deadlock, but I don't necessarily think this is
incorrect. There may be another reason for this needing to exist which
I'm not aware of (diffcalc?) but if that's the case we may want to move
the try-catch handling to the point of usage.

To reproduce the deadlock scenario with 100% success (the repro
instructions in the linked issue aren't that simple and require some
patience and good timing), the main portion of the lookup can be changed
to randomly trigger a nested lookup:

```
if (RNG.NextSingle() > 0.5f)
    return GetAsync(new
DifficultyCacheLookup(key.Beatmap, key.Beatmap.Ruleset,
key.OrderedMods)).Result;
else
    return new StarDifficulty(attributes);
```

After switching beatmap once or twice, pausing debug and viewing the
state of threads should show exactly what is going on.
2021-01-14 18:25:34 +09:00
..
ControlPoints Fix incorrectly copy pasted xmldoc 2021-01-07 19:06:10 +09:00
Drawables Rename BeatmapDifficultyManager to BeatmapDifficultyCache 2020-11-06 13:14:29 +09:00
Formats Fix BPM multiplier not working in all cases 2021-01-12 17:50:22 +09:00
Legacy
Timing Remove culling notice from HasEffect 2020-10-12 15:28:16 +09:00
Beatmap.cs Move ControlPointInfo copying to base Beatmap.Clone method (and remove setter) 2021-01-07 23:52:04 +09:00
BeatmapConverter.cs Rework to support obsoletion 2020-09-17 21:37:32 +09:00
BeatmapDifficulty.cs
BeatmapDifficultyCache.cs Fix deadlock scenario when calculating fallback difficulty 2021-01-14 18:25:34 +09:00
BeatmapInfo.cs Rename BeatmapDifficultyManager to BeatmapDifficultyCache 2020-11-06 13:14:29 +09:00
BeatmapManager_BeatmapOnlineLookupQueue.cs Add a simple cache-busting query string to online.db retrieval 2020-12-11 17:56:02 +09:00
BeatmapManager_WorkingBeatmap.cs Enforce non-null for BeatmapManager WorkingBeatmap resources 2020-12-22 12:06:10 +09:00
BeatmapManager.cs Add nullability to BeatmapManager's GameHost reference 2020-12-22 12:03:25 +09:00
BeatmapMetadata.cs Update class exclusion for dynamic compilation 2020-09-04 20:41:08 +09:00
BeatmapMetrics.cs
BeatmapOnlineInfo.cs
BeatmapProcessor.cs Force first hitobject to be a NewCombo in BeatmapProcessor preprocessing step 2020-10-06 22:10:13 +09:00
BeatmapSetFileInfo.cs
BeatmapSetInfo.cs Update EndsWith usages 2020-10-16 12:58:34 +09:00
BeatmapSetMetrics.cs
BeatmapSetOnlineInfo.cs
BeatmapSetOnlineStatus.cs
BeatmapStatistic.cs Strongly type and expose default beatmap information icon implementations for other rulesets 2020-09-04 15:01:32 +09:00
BeatmapStatisticIcon.cs Strongly type and expose default beatmap information icon implementations for other rulesets 2020-09-04 15:01:32 +09:00
BeatmapStore.cs
DifficultyRating.cs
DifficultyRecommender.cs Refactor recommendation iteration code to read better 2020-12-22 14:57:32 +09:00
DummyWorkingBeatmap.cs Add default token 2020-09-17 18:37:48 +09:00
IBeatmap.cs Move ControlPointInfo copying to base Beatmap.Clone method (and remove setter) 2021-01-07 23:52:04 +09:00
IBeatmapConverter.cs Add default token 2020-09-17 18:37:48 +09:00
IBeatmapProcessor.cs
IBeatmapResourceProvider.cs Expose resources to skin via interface (and share common pieces with beatmap) 2020-12-21 15:18:52 +09:00
IWorkingBeatmap.cs Revert "Add marker interface for beatmap skins" 2020-08-31 18:29:46 +02:00
StarDifficulty.cs Move StarDifficulty to own file 2020-11-06 13:51:25 +09:00
WorkingBeatmap.cs Move ControlPointInfo copying to base Beatmap.Clone method (and remove setter) 2021-01-07 23:52:04 +09:00