Search Issue Tracker

Won't Fix

Votes

0

Found in

2020.3.48f1

2021.3.25f1

2022.2.16f1

2023.1.0b16

2023.2.0a13

2023.3.0a3

6000.0.0b11

Issue ID

UUM-35574

Regression

No

Crash on AddComponentUnchecked when running tests and DestroyImmediate() is used

--

-

Reproduction steps:
1. Open the attached project “CrashRepro“
2. Open the Test Runner window
3. Click on the “Run All” button

Expected result: Tests run
Actual result: Editor crashes

Reproducible with: 2020.3.48f1, 2021.3.25f1, 2022.2.16f1, 2023.1.0b16, 2023.2.0a13

Reproducible on: Windows 10

First few lines of the stack trace:

{noformat}0x00007ff6da603c8f (Unity) AddComponentUnchecked
0x00007ff6da6036f7 (Unity) AddComponent
0x00007ff6da89fdf6 (Unity) MonoAddComponentWithType
0x00007ff6d9adf1f7 (Unity) GameObject_CUSTOM_Internal_AddComponentWithType
0x00000248ffa420cc (Mono JIT Code) (wrapper managed-to-native) UnityEngine.GameObject:Internal_AddComponentWithType (UnityEngine.GameObject,System.Type){noformat}

  1. Resolution Note:

    Issue is related to the incorrect usage of Singletons in the user's project. To ensure the objects in your code have a proper lifecycle, make sure you:
    1. Use Destroy() instead of DestroyImmediate() in the runtime.
    2. Do a cleanup after your tests finish executing.

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.