Intermittent AUHostingServiceXPC_arrow crash on lock in JUCE Timer thread on macOS13

We’ve been getting reports of random crashes on ARM macOS13 (sometimes after hours of inactivity, which is very annoying to debug of course!). This seems to be a crash on the JUCE Timer thread when taking a lock via pthread_mutex_lock(). See the JSON crash fragment below.

This seems to be similar to this one:
https://discussions.apple.com/thread/254536452?answerId=258479254022#258479254022

…which is not what what the post says about NI plugins but the JUCE Timer thread in a “bettermaker” plugin. There appear to be two JUCE Timer threads in that one FWIW.

Anyone got any ideas or seing similar?

Our crash fragment:

{
  "triggered" : true,
  "id" : 22680,
  "name" : "JUCE Timer",
  "threadState" : {
    "x" : [
      {
        "value" : 0
      },
      {
        "value" : 4588586352
      },
      {
        "value" : 257
      },
      {
        "value" : 74995457
      },
      {
        "value" : 322101931431974660
      },
      {
        "value" : 74995457
      },
      {
        "value" : 0
      },
      {
        "value" : 299998875
      },
      {
        "value" : 11124867072
      },
      {
        "value" : 4254010488855810
      },
      {
        "value" : 4254010488855808
      },
      {
        "value" : 4254010488855810
      },
      {
        "value" : 4254010488855810
      },
      {
        "value" : 4254010488855808
      },
      {
        "value" : 256
      },
      {
        "value" : 0
      },
      {
        "value" : 6820226380,
        "symbolLocation" : 0,
        "symbol" : "pthread_mutex_lock"
      },
      {
        "value" : 8430363264
      },
      {
        "value" : 0
      },
      {
        "value" : 0
      },
      {
        "value" : 4588586352
      },
      {
        "value" : 11051760528
      },
      {
        "value" : 11124928256
      },
      {
        "value" : 16115560
      },
      {
        "value" : 16115560
      },
      {
        "value" : 1
      },
      {
        "value" : 11124924416
      },
      {
        "value" : 4294967295
      },
      {
        "value" : 100
      }
    ],
    "flavor" : "ARM_THREAD_STATE64",
    "lr" : {
      "value" : 9946622000622467000
    },
    "cpsr" : {
      "value" : 1610616832
    },
    "fp" : {
      "value" : 11439566512
    },
    "sp" : {
      "value" : 11439566512
    },
    "esr" : {
      "value" : 2449473542,
      "description" : "(Data Abort) byte read Translation fault"
    },
    "pc" : {
      "value" : 6820226392,
      "matchesCrashFrame" : 1
    },
    "far" : {
      "value" : 0
    }
  },
  "frames" : [
    {
      "imageOffset" : 5464,
      "symbol" : "pthread_mutex_lock",
      "symbolLocation" : 12,
      "imageIndex" : 19
    },
    {
      "imageOffset" : 10369040,
      "imageIndex" : 3
    },
    {
      "imageOffset" : 10721176,
      "imageIndex" : 3
    },
    {
      "imageOffset" : 10726144,
      "imageIndex" : 3
    },
    {
      "imageOffset" : 10199160,
      "imageIndex" : 3
    },
    {
      "imageOffset" : 10374332,
      "imageIndex" : 3
    },
    {
      "imageOffset" : 28584,
      "symbol" : "_pthread_start",
      "symbolLocation" : 148,
      "imageIndex" : 19
    },
    {
      "imageOffset" : 7584,
      "symbol" : "thread_start",
      "symbolLocation" : 8,
      "imageIndex" : 19
    }
  ]
}

What is the Juce version used in your plugin?

Indeed these are coming from JUCE 6 builds…

This still happens with JUCE 7 AFAIK

Dealing with the same problem… Anyone find a solution?

@martinrobinson-2 @Skyleryoung are you using the latest version of JUCE? code in this area has changed as recently as August this year.

Ideally if you can run up a version attached to a debugger or at least get a fully symbolicated crash report? I realise this isn’t easy when you might have to wait hours and attaching to AUHostingServiceXPC_arrow is difficult at the best of times. However if you look at the timer in questions and how it’s being used maybe you can try to do something that might push it harder to potentially make the issue more likely?

Is it possible stopTimer hasn’t been called in the case of a timer that has been started and is now being destroyed? pthread_mutex_lock is used by CriticalSection, there’s one in the timer class but as it’s a bad access I assume it’s trying to access the lock (passed as a argument to the function) while it’s also being deleted from another thread? The most obvious cause would be that a timer object is being destroyed while it’s still running. I’ve seen this happen when a timer is used as a one-shot as it’s expected the event will definitely fire, but then if the plugin is really just being left running I’m not sure why this would happen because I assume nothing is being destroyed!? I know FinalCut in some cases spawns and destroys instances for generating waveforms, I wonder if there is ever a case like this in Logic?

On most recent version of JUCE 6. Made a bunch of changes to multiple parts of the plugin and have not had the crash occur since. But it was only happening after leaving computer inactive overnight. Will report back if happens again. Thank you!

1 Like