raise alarm on deadlock

This commit is contained in:
Richard Frith-Macdonald 2022-06-17 11:32:27 +01:00
parent 0194f1d5bf
commit 6bc408e35a
2 changed files with 34 additions and 0 deletions

View file

@ -1,3 +1,9 @@
2022-06-17 Richard Frith-Macdonald <rfm@gnu.org>
* EcProcess.m: Intercept lock error handling and, in the case of a
deadlock, raise an alarm before calling the normal handler to log
and stop the thread.
2022-06-07 Richard Frith-Macdonald <rfm@gnu.org>
* GNUMakefile: Fix to supply local flags to build libraries

View file

@ -81,6 +81,29 @@
NSString * const EcDidQuitNotification = @"EcDidQuitNotification";
NSString * const EcWillQuitNotification = @"EcWillQuitNotification";
static NSLock_error_handler *original_NSLock_error_handler = NULL;
static void
EcLock_error_handler(id obj, SEL _cmd, BOOL stop, NSString *msg)
{
if (stop && EcProc)
{
EcAlarm *a;
a = [EcAlarm alarmForManagedObject: nil
at: nil
withEventType: EcAlarmEventTypeProcessingError
probableCause: EcAlarmSoftwareProgramError
specificProblem: @"thread deadlock"
perceivedSeverity: EcAlarmSeverityCritical
proposedRepairAction:
_(@"Generate/save a core dump and then restart the process.")
additionalText: [obj description]];
[EcProc alarm: a];
}
(original_NSLock_error_handler)(obj, _cmd, stop, msg);
}
#ifndef __MINGW__
static int reservedPipe[2] = { 0, 0 };
static NSInteger descriptorsMaximum = 0;
@ -3175,6 +3198,11 @@ NSLog(@"Ignored attempt to set timer interval to %g ... using 10.0", interval);
+ (void) initialize
{
if (NULL == original_NSLock_error_handler)
{
original_NSLock_error_handler = _NSLock_error_handler;
_NSLock_error_handler = EcLock_error_handler;
}
if (nil == ecLock)
{
#if GS_USE_GNUTLS