Crash when calling a Dylib

I am hoping that someone can give me an insight into a crash that I am getting in my software.

I have an imported dylib and my declaration is as follows:

Soft Declare Sub CallDLL Lib libDLL (par As CString) CallDLL(p)
I can execute this function about 2-3 times before the program crashes. An extract of the crash report is:

Crashed Thread:        0  Dispatch queue:

Exception Type:        EXC_CRASH (SIGABRT)
Exception Codes:       0x0000000000000000, 0x0000000000000000
Exception Note:        EXC_CORPSE_NOTIFY

Termination Reason:    Namespace OBJC, Code 0x1

Thread 0 Crashed:: Dispatch queue:
0   libsystem_kernel.dylib        	0x00007fffcf6d40aa __abort_with_payload + 10
1   libsystem_kernel.dylib        	0x00007fffcf6d0326 abort_with_payload_wrapper_internal + 90
2   libsystem_kernel.dylib        	0x00007fffcf6d02cc abort_with_reason + 22
3   libobjc.A.dylib               	0x00007fffcecc6e1b _objc_fatalv(unsigned long long, unsigned long long, char const*, __va_list_tag*) + 102
4   libobjc.A.dylib               	0x00007fffcecc6cc6 _objc_fatal(char const*, ...) + 146
5   libobjc.A.dylib               	0x00007fffcecd1e78 (anonymous namespace)::AutoreleasePoolPage::busted(bool) + 144
6   libobjc.A.dylib               	0x00007fffcecba078 (anonymous namespace)::AutoreleasePoolPage::pop(void*) + 80
7      	0x00007fffb9994b86 _CFAutoreleasePoolPop + 22
8          	0x00007fffbb404e90 -[NSAutoreleasePool release] + 146
9   CLNT001.dylib                 	0x0000000107fc7ecd 0x107fbf000 + 36557
10  CLNT001.dylib                 	0x0000000107fc9309 0x107fbf000 + 41737
11  CLNT001.dylib                 	0x0000000107fc956e 0x107fbf000 + 42350
12  CLNT001.dylib                 	0x0000000107fc377d 0x107fbf000 + 18301

Has anybody any idea of what I am doing wrong?


It happens when the NSAutoreleasePool is emptied. Which means that you probably have objects in it that have already been released, and when the pool attempts to release them again later on, the objects do not exist any more, hence the crash.

You’ll have to figure out where you over-release an NSObject.


Thank you for the insight. I had worked out that it was something to do with memory allocation but nowhere in my program do I allocate or deallocate any memory. The crash happens here:

Soft Declare Sub CallDLL Lib libDLL (par As CString) CallDLL(p) <--- HERE
It does not happen the first or second time. It is on the third or fourth time the routine is called.

Do you think there is an error somewhere within the Xojo frameworks after the soft declare?


I am no clearvoiant :slight_smile:
And it is far more likely a mistake on your part than on Xojo’s here.

You won’t be at next week’s conference in Munich, by any chance?

Or contact me privately if you like me to have a look at your code.