Handle manager thread safe?

The plugin API marks EX_HANDLE_MANAGER as thread safe, but my plugin is crashing when I use that in a preemptive process to get a handle size. Any experience with this?

Code :
Crashed Thread: 16 P_1 (id = -3)

Exception Type: EXC_BAD_ACCESS (SIGSEGV)
Exception Codes: KERN_INVALID_ADDRESS at 0x0000000003010000
Exception Note: EXC_CORPSE_NOTIFY

Termination Signal: Segmentation fault: 11
Termination Reason: Namespace SIGNAL, Code 0xb
Terminating Process: exc handler [0]

Thread 16 Crashed:: P_1 (id = -3)
0 com.apple.CoreServices.CarbonCore 0x00007fff3308539d CSMemGetHandleSize + 35
1 com.apple.CoreServices.CarbonCore 0x00007fff33085362 GetHandleSize + 23
2 com.4d.4d 0x000000010b8d178f ext_HandleManager(parm*) + 164
3 com.4d.4d 0x000000010b788b46 entreeexterneex + 318
4 ??? 0x0000004000050712 0 + 274878236434

What 4D Version exactly? Which build number?

According to the docs, only PA_NewHandle and PA_DisposeHandle are thread-safe.

Build 17.229909 (17.0 HF4)

Ah, I see now in EntryPoints.h that EX_HANDLE_MANAGER (-434) has several entries and only the ones you mention have true for thread safe. Too bad.

So I guess it is impossible to pass a blob parameter in a preemptive thread? I don’t see how to copy the data without knowing the size.

: John DESOI

So I guess it is impossible to pass a blob parameter in a preemptive
thread? I don’t see how to copy the data without knowing the size.

Sure, you have to use PA_GetBlobParameter.

Sorry for the newbie questions - not much of a C programmer, I’m using this plugin as bridge to work in Lisp. Anything I’m using in the plugin API has to be translated to the Lisp foreign function interface.

PA_GetBlobParameter appears to require a byte array pre-allocated to the correct size of the blob. Reading through the API source indicates that you can call ToUserData with a null pointer to have it return the size of the blob and then call it again once you know the size with the pre-allocated buffer.

This seems to be working for me and returning the correct data. But I’m bothered that both calls to EX_CONVERT_STRING return error -1. Maybe that makes sense for the first one with the null pointer to get the size, but I expected a zero error on the second call. Am I doing something wrong?