Possible hang in LexActivator when calling SetLicenseCallback from within the callback routine?

Hi Cryptlex,

I’ve received an error report from a Mac customer that he got a hang, and he sent us a call stack dump. It seems to indicate that me calling SetLicenseCallback with a nullptr, right from within the actual callback routine, might cause a deadlock of sorts in LexActivator? Hopefully you guys find the below useful.

The details:

  • This is a plugin running under a host application.
  • There could be other plugins of mine loaded at this time (before this one, or still busy, or coming after), all doing the same LexActivator setup stuff. But only one of them calls SetLicenseCallback; that one is most probably the 1st to load while no others are even loaded yet.
  • The error occurred on both MacOS 10.15.7 and 11.0 (which run resulted in the call stack dump below I do not know).
  • I used LexActivator 3.14.0 and it got statically linked.
  • I do a SetLicenseCallback as the last step in initializing LexActivator.
  • In the callback routine I just raise an event that the callback has happened, and I do a SetLicenseCallback again but with nullptr to not get called again (I only want the event to fire once).
  • LexActivator seems to be deadlocked due to that last call…
  • This seems to be the first time this issue appears, though I don’t know how many users have experienced it but didn’t bother to write in of course.
  • For now I’ve probably ‘fixed’ it in my code by just not (re)setting the license callback function anymore, and just having a static bool keeping track on whether the event must still be raised.

A call stack dump with some more details, in which my function C_Cryptlex::LicenseCallback called LexActivator’s SetLicenseCallback with nullptr as the argument:

thread_start  (in libsystem_pthread.dylib) 15  [0x7fff6cbdcb8b]
_pthread_start  (in libsystem_pthread.dylib) 148  [0x7fff6cbe1109]
ThreadTimerCallback(void*)  (in My-Application) 524  [0x1e2a6a501]
LexThread::InvokeCallback(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, long)  (in My-Application) 86  [0x1e2a6a268]
C_Cryptlex::LicenseCallback(unsigned int)  (in My-Application) 140  [0x1e28c0050]
SetLicenseCallback  (in My-Application) 178  [0x1e2a7ba0d]
_pthread_mutex_firstfit_lock_slow  (in libsystem_pthread.dylib) 222  [0x7fff6cbdc937]
_pthread_mutex_firstfit_lock_wait  (in libsystem_pthread.dylib) 83  [0x7fff6cbde917]
__psynch_mutexwait  (in libsystem_kernel.dylib) 10  [0x7fff6cb20062]

Hi Carl,

Thanks for reporting. We will look into this.