Bug 59547 - Premature collection possible in bindings in MetalPerformanceShaders
Summary: Premature collection possible in bindings in MetalPerformanceShaders
Status: CONFIRMED
Alias: None
Product: iOS
Classification: Xamarin
Component: Xamarin.iOS.dll (show other bugs)
Version: master
Hardware: PC Mac OS
: --- major
Target Milestone: 15.6
Assignee: Bugzilla
URL:
Depends on:
Blocks:
 
Reported: 2017-09-18 07:55 UTC by Rolf Bjarne Kvinge [MSFT]
Modified: 2017-09-18 07:57 UTC (History)
1 user (show)

See Also:
Tags:
Is this bug a regression?: ---
Last known good build:


Attachments

Description Rolf Bjarne Kvinge [MSFT] 2017-09-18 07:55:04 UTC
See: https://github.com/xamarin/xamarin-macios/blob/1690ccbc991ab59835f76a15ef510cd182259915/src/MetalPerformanceShaders/MPSKernel.cs#L23-L43

The following code is unsafe, because the GC is free to move the 'values' array once we're out of the fixed statement:

    fixed (nfloat *ptr = values)
        return (IntPtr) ptr;

this means that the calling function now has pointer to memory that the GC can move at any time.
Comment 1 Rolf Bjarne Kvinge [MSFT] 2017-09-18 07:57:18 UTC
Raising priority and targeting the next release (15.6), since this will cause random crashes (or other random behavior) when it occurs, and it will be very tricky to track down.

Note You need to log in before you can comment on or make changes to this bug.