Search Issue Tracker

Duplicate

Votes

0

Found in

2019.3.0a3

2019.3.0b10

2020.1.0a1

Issue ID

1197417

Regression

Yes

Editor crash on AssetDatabase.CreateAsset() called from Editor.OnDisable

Asset - Database

-

How to reproduce:
1. Open user attached project "New Unity Project.zip"
2. Open scene "TestScene"
3. Select "GameObject" in the Hierarchy
4. Click empty space in Hierarchy Window to unselect "GameObject"

Expected result: Editor does not crash
Actual result: Editor crashes

Reproducible with - 2019.3.0a3, 2019.3.0b10, 2020.1.0a11
Not reproducible with - 2017.4.30f1, 2018.4.5f1, 2019.2.0b10, 2019.3.0a2

  1. Resolution Note:

    The callstack looks like this:

    ActiveEditorTracker::ForceReloadInspector
    SceneTracker::ForceReloadInspector
    RefreshInternalV2
    StopAssetImportingV2
    CreateSerializedAssetV2
    AssetDatabase::CreateSerializedAsset
    AssetDatabaseBindings::CreateAsset
    AssetDatabase_CUSTOM_CreateAsset
    (wrapper managed-to-native) UnityEditor.AssetDatabase:CreateAsset (UnityEngine.Object,string)
    [D:\MiFBox\Unity\New Unity Project\Assets\TestScript.cs:17] TestScript/TestScriptEditor:OnDisable ()
    (wrapper runtime-invoke) object:runtime_invoke_void__this__ (object,intptr,intptr,intptr)
    [c:\build\output\unity-technologies\mono\mono\mini\mini-runtime.c:2809] mono_jit_runtime_invoke
    [c:\build\output\unity-technologies\mono\mono\metadata\object.c:2921] do_runtime_invoke
    [c:\build\output\unity-technologies\mono\mono\metadata\object.c:2968] mono_runtime_invoke
    scripting_method_invoke
    ScriptingInvocation::Invoke
    ScriptingInvocation::InvokeChecked
    SerializableManagedRef::CallMethod
    MonoBehaviour::WillDestroyComponent
    DestroyObjectHighLevel_Internal
    DestroyObjectHighLevel
    ActiveEditorTracker::Element::~Element
    std::vector<ActiveEditorTracker::Element,std::allocator<ActiveEditorTracker::Element> >::clear
    ActiveEditorTracker::Rebuild
    ActiveEditorTracker::DidFlushDirty
    SceneTracker::FlushDirty
    Application::TickTimer
    MainMessageLoop
    WinMain
    Which essentially says that the object which is being destroyed is being accessed later on.

    Users should not call CreateAsset from calls which are destroying objects. We will enforce this rule in 2020.1, but for right now this is not something that they should be doing.

Add comment

Log in to post comment

All about bugs

View bugs we have successfully reproduced, and vote for the bugs you want to see fixed most urgently.