Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix crash when logging out during 2FA email verification #26834

Merged
merged 1 commit into from
Jan 31, 2024

Conversation

bdach
Copy link
Collaborator

@bdach bdach commented Jan 30, 2024

Closes #26824.

Can be reproduced via something like

diff --git a/osu.Game/Online/API/OAuth.cs b/osu.Game/Online/API/OAuth.cs index 485274f349..e6e93ab4c7 100644
--- a/osu.Game/Online/API/OAuth.cs
+++ b/osu.Game/Online/API/OAuth.cs
@@ -151,6 +151,11 @@ internal string RequestAccessToken()
         {
             if (!ensureAccessToken()) return null;

+            for (int i = 0; i < 10000; ++i)
+            {
+                _ = Token.Value.AccessToken;
+            }
+
             return Token.Value.AccessToken;
         }

The cause is SecondFactorAuthForm calling Logout(), which calls OAuth.Clear(), while the APIAccess connect loop is checking if authentication.HasValidAccessToken is true, which happens to internally check Token.Value.AccessToken, which the clearing of tokens can brutally interrupt.

Closes ppy#26824... I think?

Can be reproduced via something like

diff --git a/osu.Game/Online/API/OAuth.cs b/osu.Game/Online/API/OAuth.cs
index 485274f349..e6e93ab4c7 100644
--- a/osu.Game/Online/API/OAuth.cs
+++ b/osu.Game/Online/API/OAuth.cs
@@ -151,6 +151,11 @@ internal string RequestAccessToken()
         {
             if (!ensureAccessToken()) return null;

+            for (int i = 0; i < 10000; ++i)
+            {
+                _ = Token.Value.AccessToken;
+            }
+
             return Token.Value.AccessToken;
         }

The cause is `SecondFactorAuthForm` calling `Logout()`, which calls
`OAuth.Clear()`, _while_ the `APIAccess` connect loop is checking if
`authentication.HasValidAccessToken` is true, which happens to
internally check `Token.Value.AccessToken`, which the clearing of
tokens can brutally interrupt.
@Walavouchey
Copy link
Member

tested this branch (3 times) and the issue seems to be fixed

you said on discord that this apparently crashes randomly but for me it was every time (5 times on the release + a couple when testing locally before the release)

@bdach bdach added the next release Pull requests which are almost there. We'll aim to get them in the next release, but no guarantees! label Jan 31, 2024
@peppy peppy merged commit edab056 into ppy:master Jan 31, 2024
15 of 17 checks passed
@bdach bdach deleted the 2fa-cancel-crash branch January 31, 2024 09:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
next release Pull requests which are almost there. We'll aim to get them in the next release, but no guarantees! size/S type:online type:reliability
Projects
Development

Successfully merging this pull request may close these issues.

Crash when cancelling 2FA email verification
3 participants