Search Issue Tracker

By Design

Votes

0

Found in

2019.1

2019.3.9f1

2019.4

2020.1

2020.2

Issue ID

1253593

Regression

Yes

Crash on GC_malloc_kind_global when entering Play Mode and using pointers in script

Mono

-

How to reproduce:
1. Open attached project "Case_1253593_pointers.rar"
2. Enter Play Mode

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

Reproducible with - 2019.1.0f1, 2019.1.14f1, 2019.4.2f1, 2020.1.0b14, 2020.2.0a16
Not reproducible with - 2017.4.40f1, 2018.4.23f1, 2019.1.0b10

Notes:
Does not crash 100% of the times

  1. Response avatar

    Resolution Note:

    The issue here is that pointers to array elements are stored and accessed outside of a `fixed` block. The memory may be moved or collected. In this case, the fix is to allocate a pinned GC handle to keep the array alive and fixed. Something like this

    System.Runtime.InteropServices.GCHandle.Alloc(c, System.Runtime.InteropServices.GCHandleType.Pinned);

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.