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
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 ===========
Add comment
All about bugs
View bugs we have successfully reproduced, and vote for the bugs you want to see fixed most urgently.
Latest issues
- Crash on ShaderLab::ShaderState::ApplyShaderState when entering Play Mode and calling ShaderWarmup.WarmupShaderFromCollection with a shader that has dynamic_branch
- Crash on operator delete[] when a serializable structure in the System namespace is serialized by a MonoBehaviour
- [macOS] forward and backward mouse buttons are recognized as middle mouse button
- NavMeshModifier.OnEnable/OnDisable gets progressively slower when called repeatedly
- "System.Net.CookieContainer" throws an "ArgumentException" error when using a non-UTF-8 machine locale and hostname
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.