I am working on a Fortran application that uses PLPlot to graph data on MacOS. If I run the application from the terminal, everything works fine. But when I create a MacOS bundle, the application crashes every time during the first call to plbox with a null pointer error (see crash log below).
After some debugging, it seemslike the issue is that the call to register the cairo context is failing:
call pl_cmd(PLESC_DEVINIT, cairo_context).
If I remove this line from the application, it fails the same way whether I run it in terminal or as a MacOS bundle.
As I understand the documentation, I need to make this call to get the "extcairo" driver to work, but I cannot find a way around this issue if I want to distribute an application as a MacOS bundle that uses PLPlot. Any suggestions to deal with this would be appreciated.
Crash Log
Process: ZOA [9389]
Path: /Users/USER/Library/Mobile Documents/com~apple~CloudDocs/*/ZOA
Identifier: ZOA
Version: ???
Code Type: ARM-64 (Native)
Parent Process: zsh [611]
Responsible: Terminal [510]
User ID: 502
Date/Time: 2022-12-07 15:59:40.5134 -0800
OS Version: macOS 12.5.1 (21G83)
Report Version: 12
Anonymous UUID: 64AC6177-EDD0-B543-05D4-32CEDE8BFCA6
Sleep/Wake UUID: 34BCD013-C8A1-4B12-A855-FBE312FF5D5E
Time Awake Since Boot: 1000000 seconds
Time Since Wake: 1157 seconds
System Integrity Protection: enabled
Crashed Thread: 0 Dispatch queue: com.apple.main-thread
Exception Type: EXC_BAD_ACCESS (SIGSEGV)
Exception Codes: KERN_INVALID_ADDRESS at 0x0000000000000004
Exception Codes: 0x0000000000000001, 0x0000000000000004
Exception Note: EXC_CORPSE_NOTIFY
VM Region Info: 0x4 is not in any region. Bytes before following region: 105553518919676
REGION TYPE START - END [ VSIZE] PRT/MAX SHRMOD REGION DETAIL
UNUSED SPACE AT START
--->
MALLOC_NANO (reserved) 600018000000-600020000000 [128.0M] rw-/rwx SM=NUL ...(unallocated)
Thread 0 Crashed:: Dispatch queue: com.apple.main-thread
0 libcairo.2.dylib 0x10eaed3d0 cairo_set_source_rgba + 12
1 cairo.so 0x11565f468 set_current_context + 104
2 cairo.so 0x11565f468 set_current_context + 104
3 cairo.so 0x11565f348 plD_line_cairo + 52
4 libplplot.17.0.0.dylib 0x10ee0ae00 grline + 108
5 libplplot.17.0.0.dylib 0x10ee0ad88 plP_line + 316
6 libplplot.17.0.0.dylib 0x10ee2487c genlin + 72
7 libplplot.17.0.0.dylib 0x10ee240ec plP_pllclp + 1084
8 libplplot.17.0.0.dylib 0x10ee23b9c pllclp + 88
9 libplplot.17.0.0.dylib 0x10ee23144 plP_draphy + 108
10 libplplot.17.0.0.dylib 0x10edfe028 c_plaxes + 2940
11 libplplot.17.0.0.dylib 0x10edfd4a0 c_plbox + 72
12 libplplotfortran.0.2.0.dylib 0x10ed86174 __plplot_double_MOD_plbox_impl + 372
13 ZOA 0x104b53ca0 __handlers_MOD_plot1 + 1888 (zzhandlers.f90:558)
Line that triggered the crash:
call plbox('bclnst', 0.0_plflt, 0, 'bnstv', 0.0_plflt, 0)
Thanks!