I am using Declares against a compiled version of PCRE, and so far, so good. Mostly. I can compile and use a pattern to get back matches, and if I change the lib path, it stops working, so I know I’m using the dylib I compiled.
The issue comes when I try to release the compiled pattern (stored as a Ptr).
if RePtr <> nil then
declare sub pcre_free lib kPCRELib ( re as ptr )
pcre_free( RePtr )
RePtr = nil
end if
The .h file and example code says this should work, but I get a hard crash.
From the .h file:
PCRE_EXP_DECL void pcre_free(void *);
And the example C code calls it that way too. What could be wrong?
My partial crash report:
Process: RegExPro Harness.debug [68960]
Path: /Users/USER/Documents/*/RegExPro Harness.debug.app/Contents/MacOS/RegExPro Harness.debug
Identifier: com.mactechnologies.regexproharness
Version: ??? (1.0.0.0.0)
Code Type: X86-64 (Native)
Parent Process: ??? [1]
Responsible: RegExPro Harness.debug [68960]
User ID: 501
Date/Time: 2021-02-10 09:47:15.402 -0500
OS Version: Mac OS X 10.15.7 (19H512)
Report Version: 12
Bridge OS Version: 5.2 (18P4346)
Anonymous UUID: 78D4241F-9681-C8FA-5BF5-2D68192D214A
Sleep/Wake UUID: 774A546C-DBB8-4CE3-8E6B-88652AA0A339
Time Awake Since Boot: 320000 seconds
Time Since Wake: 590 seconds
System Integrity Protection: enabled
Crashed Thread: 0 Dispatch queue: com.apple.main-thread
Exception Type: EXC_BAD_ACCESS (SIGBUS)
Exception Codes: KERN_PROTECTION_FAILURE at 0x000000010dec70d8
Exception Note: EXC_CORPSE_NOTIFY
Termination Signal: Bus error: 10
Termination Reason: Namespace SIGNAL, Code 0xa
Terminating Process: exc handler [68960]
VM Regions Near 0x10dec70d8:
__DATA_CONST 000000010dec3000-000000010dec7000 [ 16K] r--/rwx SM=COW /Users/USER/Documents/*/RegExPro Harness.debug.app/Contents/Frameworks/pcre_libs/libpcre.1.dylib
--> __DATA 000000010dec7000-000000010decb000 [ 16K] rw-/rwx SM=COW /Users/USER/Documents/*/RegExPro Harness.debug.app/Contents/Frameworks/pcre_libs/libpcre.1.dylib
__LINKEDIT 000000010decb000-000000010ded2000 [ 28K] r--/rwx SM=COW /Users/USER/Documents/*/RegExPro Harness.debug.app/Contents/Frameworks/pcre_libs/libpcre.1.dylib
Thread 0 Crashed:: Dispatch queue: com.apple.main-thread
0 ??? 0x000000010dec70d8 pcre_free + 0
1 RegExPro Harness.debug 0x0000000106f16892 RegExPro_MTC.Destructor%%o<RegExPro_MTC> + 114 (/RegExPro_MTC:167)
2 XojoFramework 0x0000000107376d9b RuntimeUnlockObject + 135
3 RegExPro Harness.debug 0x0000000106fc5394 RegExProTests.SearchTest%%o<RegExProTests> + 2804 (/RegExProTests:21)
4 RegExPro Harness.debug 0x0000000106ec388c Introspection.Invoke%% + 60
5 RegExPro Harness.debug 0x0000000106db9817 Xojo.Introspection.MethodInfo.Invoke%x%o<Xojo.Introspection.MethodInfo>o<Object>A1x + 951
6 RegExPro Harness.debug 0x0000000106db93a3 Xojo.Introspection.MethodInfo.Invoke%%o<Xojo.Introspection.MethodInfo>o<Object>A1x + 115
7 RegExPro Harness.debug 0x0000000106d9f74a Introspection.MethodInfo.Invoke%%o<Introspection.MethodInfo>o<Object>A1v + 1002
8 RegExPro Harness.debug 0x0000000106f275ca TestGroup.RunTestsTimer_Action%%o<TestGroup>o<Timer> + 9066 (/TestGroup:329)
9 XojoFramework 0x000000010737c48e 0x107105000 + 2585742
10 com.apple.CoreFoundation 0x00007fff2dd4a7f9 __CFRUNLOOP_IS_CALLING_OUT_TO_A_TIMER_CALLBACK_FUNCTION__ + 20
11 com.apple.CoreFoundation 0x00007fff2dd4a35f __CFRunLoopDoTimer + 859
12 com.apple.CoreFoundation 0x00007fff2dd49e47 __CFRunLoopDoTimers + 322
13 com.apple.CoreFoundation 0x00007fff2dd2ebea __CFRunLoopRun + 1871
14 com.apple.CoreFoundation 0x00007fff2dd2de3e CFRunLoopRunSpecific + 462
15 com.apple.HIToolbox 0x00007fff2c95aabd RunCurrentEventLoopInMode + 292
16 com.apple.HIToolbox 0x00007fff2c95a6f4 ReceiveNextEventCommon + 359
17 com.apple.HIToolbox 0x00007fff2c95a579 _BlockUntilNextEventMatchingListInModeWithFilter + 64
18 com.apple.AppKit 0x00007fff2afa0039 _DPSNextEvent + 883
19 com.apple.AppKit 0x00007fff2af9e880 -[NSApplication(NSEvent) _nextEventMatchingEventMask:untilDate:inMode:dequeue:] + 1352
20 XojoFramework 0x00000001071f1b34 0x107105000 + 969524
21 XojoFramework 0x00000001071f1b78 0x107105000 + 969592
22 RegExPro Harness.debug 0x0000000106e3ab15 Application._CallFunctionWithExceptionHandling%%o<Application>p + 181
23 XojoFramework 0x00000001073749ec CallFunctionWithExceptionHandling(void (*)()) + 254
24 XojoFramework 0x00000001071f1ae1 0x107105000 + 969441
25 com.apple.AppKit 0x00007fff2af9058e -[NSApplication run] + 658
26 XojoFramework 0x0000000107373336 RuntimeRun + 41
27 RegExPro Harness.debug 0x0000000106eba5e3 REALbasic._RuntimeRun + 19
28 RegExPro Harness.debug 0x0000000106fc609e _Main + 846 (/#main:98)
29 RegExPro Harness.debug 0x0000000106fc54f3 main + 19
30 libdyld.dylib 0x00007fff67dcfcc9 start + 1