Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice
  3. Join us on November 16th, 2023, between 1 pm and 9 pm CET for Ask the Experts Online on Discord and on Unity Discussions.
    Dismiss Notice

Interlocked methods crashing with IL2CPP

Discussion in 'iOS and tvOS' started by Asse1, Aug 14, 2015.

  1. Asse1

    Asse1

    Joined:
    Jan 9, 2013
    Posts:
    89
    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:
    Code (CSharp):
    1. // we get some bottleneck, start next worker
    2. var runningCounter = Interlocked.Read(ref this.runningCounter);
    or
    Code (CSharp):
    1. Interlocked.Increment(ref this.runningCounter);
    And here's the compiled CPP code:
    Code (CSharp):
    1. // System.Int64 System.Threading.Interlocked::Increment(System.Int64&)
    2. extern "C" int64_t Interlocked_Increment_m18231 (Object_t * __this /* static, unused */, int64_t* ___location, const MethodInfo* method)
    3. {
    4.     using namespace il2cpp::icalls;
    5.     typedef int64_t (*Interlocked_Increment_m18231_ftn) (int64_t*);
    6.     return  ((Interlocked_Increment_m18231_ftn)mscorlib::System::Threading::Interlocked::Increment64) (___location);
    7. }
    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.
     
  2. tmsduman

    tmsduman

    Joined:
    Oct 10, 2014
    Posts:
    4
    I have the same error, did you find a solution meanwhile?
     
  3. JoshPeterson

    JoshPeterson

    Unity Technologies

    Joined:
    Jul 21, 2014
    Posts:
    6,775
    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.
     
  4. jctz

    jctz

    Joined:
    Aug 14, 2013
    Posts:
    47
    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.
     
  5. JoshPeterson

    JoshPeterson

    Unity Technologies

    Joined:
    Jul 21, 2014
    Posts:
    6,775
    @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.
     
  6. jctz

    jctz

    Joined:
    Aug 14, 2013
    Posts:
    47
    Thanks Josh, looking forward to it.