Reproduction steps:
1. Open the attacher “UndoCrash“ project
2. Open the “Assets/Scene/SampleScene.unity“ scene
3. In the Hierarchy window, select “Crash” GameObject
4. In the Inspector window, under the “Crash Behaviour” script component, set the “Gobj” field to None
5. In the Scene Tools window, select “CT”
6. Click CTRL+Z or Edit > Undo
Expected result: The “Gobj” field is reset to its previous value
Actual result: Unity Editor crashes
Reproducible with: 2021.3.30f1, 2023.1.0a1, 2023.1.12f1
Not reproducible with: 2022.1.0a1, 2022.3.9f1, 2023.2.0a1, 2023.2.0b8, 2023.3.0a4
Reproducible on: Ubuntu 23.04
Not reproducible on: Windows 10 Pro 22H2
First lines of the stack trace:
#2 0x0055e9cf1458e0 in ContainerWindow::ToggleMaximize()
#3 0x0055e9cf13ad45 in GUIView::UpdateBackingScaleFactor()
#4 0x0055e9cf13aa6c in GUIView::UpdateScreenManager()
#5 0x0055e9cea9822d in ExecuteCommandOnAllWindows(core::basic_string<char, core::StringStorageDefault<char> > const&)
#6 0x0055e9cefe92e1 in UndoManager::SyncAfterUndo()
Note: On Windows, this bug leads to an error log in the Unity Editor console (the “GameObject” part is not consistent, as it shows random class type names, for example, ShaderNameRegistry):
PPtr cast failed when dereferencing! Casting from GameObject to MonoBehaviour!
UnityEngine.GUIUtility:ProcessEvent (int,intptr,bool&)