I’m trying to write an ABL binding for the ØMQ C library, but am crashing the Procedure Editor for my zmq_init function binding. I wrote a binding for zmq_version without issue, so I assume it’s not a .dll file problem. Anyway, the C function prototype looks like this:
void *zmq_init (int io_threads);
The ABL code I’ve written is as follows:
PROCEDURE zmq_init EXTERNAL "libzmq.dll" CDECL:
DEFINE INPUT PARAMETER num_threads AS LONG.
DEFINE RETURN PARAMETER context_ptr AS MEMPTR.
END PROCEDURE.
DEF VAR mContext AS MEMPTR NO-UNDO.
RUN zmq_init(INPUT 0, OUTPUT mContext).
This particular function initializes a “0mq context” (potential problem: it’s a thread pool) and returns a pointer to it. Could the error be related to OpenEdge’s non-threaded nature, even though I’m calling an external library and requesting 0 threads be allocated in the pool?
Running the code in Procedure Editor makes it crash with a Windows “Progress Client has stopped working” error with Exception code: C0000005 ACCESS_VIOLATION (full stack trace here, although I don’t always get a stack trace with info in it).
I’ve never done Windows C programming, but it looks like what I’d call a Segmentation Fault if I were on Unix using gcc (accessing protected memory). Speaking of which, I’d in fact rather run this code on a Unix machine but apparently Progress only provides evaluation developer OE environments for Windows :(.
I’ve disabled DEP without success. Is ABL trying to dereference the pointer when it returns from the library or something? Surely there has to be a way to handle signatures with a return value of void* that get malloc’ed in the library call.
I’ve paged through OpenEdge Development: Programming Interfaces, Tom Bascom’s UNIX Shared Libraries PowerPoint, and some other PowerPoint called OpenEdge in an LDAP World that has some code samples but don’t see anything obvious that I’m missing.
I’m on OpenEdge 10.2B, Windows 7 64-bit, however using the 32-bit version of OpenEdge as that’s my only option for evaluation software. Anyone got a license I could borrow for compiling/running this code on CentOS? 🙂
I ran into the same problem several times (Progress Client has stopped working) while i was working on some c# methods (called via clr bridge) in which I used threads.
Hiding the threads from progress by using some c# library classes(AsyncOperation,AsyncCallback) solved the problem, but most attempts caused the progress runtime to stop.
Related to .net the progress help states “You cannot use System.Threading.Thread, or any derived class — ABL is single-threaded.”
I know that calling c# methods via clr bridge is completely different from invoking c libraries but maybe our problems are caused by the single threaded nature of OpenEdge.