1
0
mirror of https://github.com/ppy/osu.git synced 2024-09-22 04:07:25 +08:00
osu-lazer/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 Add legacy flag value for mirror mod 2020-08-29 11:45:59 +02:00
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 Sadly, xmldoc doesn't support tuple elements. 2019-11-17 21:01:56 +08:00
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 Move metrics to beatmap set 2019-06-13 16:52:49 +09:00
BeatmapOnlineInfo.cs Move Length out of OnlineInfo 2019-07-07 20:25:36 +03:00
BeatmapProcessor.cs Force first hitobject to be a NewCombo in BeatmapProcessor preprocessing step 2020-10-06 22:10:13 +09:00
BeatmapSetFileInfo.cs Update licence header (and remove year) 2019-01-24 17:43:03 +09:00
BeatmapSetInfo.cs Update EndsWith usages 2020-10-16 12:58:34 +09:00
BeatmapSetMetrics.cs Move metrics to beatmap set 2019-06-13 16:52:49 +09:00
BeatmapSetOnlineInfo.cs Remove usings 2019-08-29 12:49:44 +03:00
BeatmapSetOnlineStatus.cs Update licence header (and remove year) 2019-01-24 17:43:03 +09:00
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 Reduce database includes where possible 2020-04-28 21:43:35 +09:00
DifficultyRating.cs Replace DifficultyColouredContainer with a more scalable solution 2019-08-17 15:16:24 +09:00
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 Add IBeatmap<T> interface for typed hitobject retrieval 2019-08-28 20:19:22 +09:00
IBeatmapConverter.cs Add default token 2020-09-17 18:37:48 +09:00
IBeatmapProcessor.cs Update licence header (and remove year) 2019-01-24 17:43:03 +09:00
IBeatmapResourceProvider.cs Expose resources to skin via interface (and share common pieces with beatmap) 2020-12-21 15:18:52 +09:00
IWorkingBeatmap.cs Centralise and clarify LoadTrack documentation 2020-08-22 19:42:34 +09:00
StarDifficulty.cs Move StarDifficulty to own file 2020-11-06 13:51:25 +09:00
WorkingBeatmap.cs Make beatmap conversion support cancellation tokens 2020-09-17 17:40:05 +09:00