Search Issue Tracker

Won't Fix

Votes

0

Found in

2018.3.0b12

2019.1.0a1

2019.1.9f1

2019.2.0a1

2019.3.0a1

Issue ID

1173543

Regression

No

Unity Editor crashes when copy byte array from NativeArray

Mono

-

Steps to reproduce:
1. Download attached project
2. Open "Test" scene
3. Enter play mode
4. Open Profilier

Actual results: Editor crashes

Reproduced with: 2019.3.0a11, 2019.2.1f1, 2019.1.14f1, 2018.4.5f1

Note:
- If Editor doesn't crash reimport scripts and reenter play mode.
- Older Unity version throw compiler errors

========== OUTPUTTING STACK TRACE ==================

0x0000000142B549C7 (Unity) memcpy
0x000000014184C21C (Unity) UnsafeUtility_CUSTOM_MemCpy
0x0000000043289320 (Mono JIT Code) (wrapper managed-to-native) Unity.Collections.LowLevel.Unsafe.UnsafeUtility:MemCpy (void*,void*,long)
0x0000000043288B3B (Mono JIT Code) [C:\buildslave\unity\build\Runtime\Export\NativeArray\NativeArray.cs:436] Unity.Collections.NativeArray`1<byte>:Copy (Unity.Collections.NativeArray`1<byte>,int,byte[],int,int)
0x000000004328A203 (Mono JIT Code) [C:\buildslave\unity\build\Runtime\Export\NativeArray\NativeArray.cs:324] Unity.Collections.NativeArray`1<byte>:Copy (Unity.Collections.NativeArray`1<byte>,byte[])
0x0000000043289E93 (Mono JIT Code) [C:\buildslave\unity\build\Runtime\Export\NativeArray\NativeArray.cs:183] Unity.Collections.NativeArray`1<byte>:CopyTo (byte[])
<...>
========== END OF STACKTRACE ===========

  1. Resolution Note:

    NativeArray returned by GetData cannot be hold and must be used directly at the frame the function is called. It is using temporary memory that is cleared at next frame. A guard is supposed to throw in editor instead of crashing though (checks are removed in player). I'll check that but it wont fix the issue as this is due to a misuse of the feature.

    Note that in 2019.3 there's a new option to provide a NativeArray directly to the readback request that will allo to do what is needed here. It is then the user's responsability to manage the NativeArray life time.

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.