Interlocked methods crashing with IL2CPP

Hey,

I currently work on getting our project ready for IL2CPP. So far everything compiles but during runtime all calls of static Interlocked methods crash.

Here are some C# examples:

// we get some bottleneck, start next worker
var runningCounter = Interlocked.Read(ref this.runningCounter);

or

Interlocked.Increment(ref this.runningCounter);

And here’s the compiled CPP code:

// System.Int64 System.Threading.Interlocked::Increment(System.Int64&)
extern "C" int64_t Interlocked_Increment_m18231 (Object_t * __this /* static, unused */, int64_t* ___location, const MethodInfo* method)
{
    using namespace il2cpp::icalls;
    typedef int64_t (*Interlocked_Increment_m18231_ftn) (int64_t*);
    return  ((Interlocked_Increment_m18231_ftn)mscorlib::System::Threading::Interlocked::Increment64) (___location);
}

And here’s the crash error I get:

Any hints on this one? It’s totally strange and as I said, every Interlocked call crashes.

I have the same error, did you find a solution meanwhile?

Does this occur on a 32-bit device (e.g. an iPhone 5c)? We’ve just merged a fix internally for a bug which looks like this and occurs only on 32-bit devices.

This has been happening for me too, and it in fact only happens on 32-bit CPUs. May I ask what release you expect this bug to be fixed in? We’re running 5.1.2p3.

@jctz

The fix is in the 5.13p2 patch release in the 5.1 series, so you’ll need to upgrade at least to that version when it is out (should be any day now). It is also in 4.6.8p1 on the 4.6 series.

Thanks Josh, looking forward to it.