Search Issue Tracker

Fixed

Fixed in 1.15.1

Votes

0

Found in [Package]

1.14.1

Issue ID

ISXB-1637

Regression

Yes

Crash on memcpy when calling Press() in an InputTestFixture

Package: Input System

-

How to reproduce:
1. Open the attached “CrashRepro_IN-106698“ project
2. Open the “Assets/InitTestScene.unity“ Scene
3. Enter Play Mode

Reproducible with: 1.11.2 (2022.3.49f1), 1.14.0 (6000.0.55f1), 1.14.1 (6000.0.55f1, 6000.2.0f1, 6000.3.0a4)
Not reproducible with: 1.11.0 (2022.3.49f1)

Reproducible on: macOS 15.5 Sequoia (Intel), Windows 11 (by user)
Not reproducible on: No other environment tested

First few lines of the stack trace:
0x00007FFAA3EEDD24 (Unity) memcpy
0x00007FFAA05C07F5 (Unity) UnsafeUtility_CUSTOM_MemCpy
0x00000181ACE5F566 (Mono JIT Code) (wrapper managed-to-native) Unity.Collections.LowLevel.Unsafe.UnsafeUtility:MemCpy (void,void,long)
0x00000182BFD5B77B (Mono JIT Code) [.\Library\PackageCache\com.unity.inputsystem@7fe8299111a7\InputSystem\Events\DeltaStateEvent.cs:99] UnityEngine.InputSystem.LowLevel.DeltaStateEvent:From (UnityEngine.InputSystem.InputControl,UnityEngine.InputSystem.LowLevel.InputEventPtr&,Unity.Collections.Allocator)

  1. Resolution Note (fix version 1.15.1):

    In the reported reproduction project [OneTimeSetUp]and [OneTimeTearDown]is used to setup and remove devices. InputTestFixture do not support this and is instead tightly coupled to [SetUp]and [TearDown]hooks of NUnit. The only change needed to the repro project to avoid a crash like this is to replace [OneTimeSetUp]with [SetUp]and [OneTimeTearDown]with [TearDown]. The reason behind this is that InputTestFixture will push a test state as part of Setup() and pop that state as part of TearDown(). This means that only code in-between SetUp and TearDown will be operating on the test instance of the system. If a device is created before SetUp, like in the provided project, it will no longer be a valid instance after SetUp has executed and may contain unsafe pointers into memory that is not valid until the current test ends. Hope this helps.

    In addition to the above we have as part of investigating this ticket improved the documentation of InputTestFixture and added checks that throws exceptions if used in an unsupported way to provide better guidance when using it outside what it may support. If desirable to keep devices between multiple tests it is instead recommended to create a custom test fixture for that purpose if the features supported by InputTestFixture are considered insufficient.

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.