The crash is when FLTK function create_aux_bitmap calls macOS function CGBitmapContextGetWidth.
Here is that FLTK function:
- (void)create_aux_bitmap:(CGContextRef)gc retina:(BOOL)r {
if (!gc || fl_mac_os_version >= 101600) {
// bitmap context-related functions (e.g., CGBitmapContextGetBytesPerRow) can't be used here with macOS 11.0 "Big Sur"
static CGColorSpaceRef cspace = CGColorSpaceCreateDeviceRGB();
int W = [self frame].size.width, H = [self frame].size.height;
if (r) { W *= 2; H *= 2; }
aux_bitmap = CGBitmapContextCreate(NULL, W, H, 8, 0, cspace, kCGImageAlphaPremultipliedFirst|kCGBitmapByteOrder32Host);
} else {
aux_bitmap = CGBitmapContextCreate(NULL, CGBitmapContextGetWidth(gc), CGBitmapContextGetHeight(gc),
CGBitmapContextGetBitsPerComponent(gc), CGBitmapContextGetBytesPerRow(gc),
CGBitmapContextGetColorSpace(gc), CGBitmapContextGetBitmapInfo(gc));
}
if (r) CGContextScaleCTM(aux_bitmap, 2, 2);
}
When running macOS 11 or above, the first part of the if MUST be chosen, which avoids
a call to CGBitmapContextGetWidth() that faults with these macOS versions.
Thus, either you run an older version of FLTK (Sorry, I insist because this has happened
so many times with systems containing various FLTK source trees), or global variable fl_mac_os_version is not properly initialized.
Its value should be 1015xx on macOS 10.15, or 101600 or 11xxyy on macOS 11.
Please, have its value printed out before your program creates its first FLTK window.
It's enough to declare it with :
extern int fl_mac_os_version;
fl_mac_os_version is assigned either as a static initializer, or when FLTK opens the display.
But if that's not enough in your special setting that mixes FLTK and non-FLTK windows,
you can force its initialization calling FLTK's public function fl_open_display() early in your program.
This requires :
#include <FL/platform.H>
Let me know, please, if it's getting better with that cure.