delphizmq
delphizmq copied to clipboard
zmq assertion failure with TZMQPoller.Poll
I receive the following error message when attempting to use TZMQPoller.Poll with the 64-bit ZeroMQ library (3.2.4, in this case):
"Assertion failed: Invalid argument (......\src\zmq.cpp:868)"
The following is an example free pascal program that generates the error (using 64-bit FPC):
program TestZmqPoll;
{$mode objfpc}{$H+}
uses
Classes,
zmqapi;
var
context: TZMQContext;
socket: TZMQSocket;
poller: TZMQPoller;
begin
context := TZMQContext.create;
socket := context.Socket(stSub);
socket.bind('tcp://*:50000');
socket.Subscribe('');
poller := TZMQPoller.Create(True, context);
poller.Register(socket, [pePollIn]);
while True do begin
poller.poll(500);
end;
end.
The assertion failure does not occur when using 32-bit FPC and libzmq.
I've never tried to make it work with a 64bit ZeroMQ lib, :(
I stumbled in a similar issue. Here are some notes.
On a windows 10, 64 bits machine.
First I have built 32 and 64 versions of libzmq.dll (3.2.5) with vs2015. Pool works great with Lazarus 32 bits (1.6.2, fpc 3.0.0) and libzmq.dll 32 bits. However, it failed with Lazarus 64 bits and libzmq.dll 64 bits (TZMQPoller.poll
returning result = -1
). I had to change the following lines to make lazarus happy:
zmqapi.pas
procedure TZMQSocket.RegisterMonitor( proc: TZMQMonitorProc; events: TZMQMonitorEvents = cZMQMonitorEventsAll );
var
PISocket : ^integer;
{$ifdef UNIX}
tid: QWord;
{$else}
{$ifdef WIN32}
tid: LongWord;
{$endif}
{$ifdef WIN64}
tid: QWord;
{$endif}
{$endif}
begin
On a Linux Bunsen Labs-Hydrogen (Debian 8), 64 bits machine.
Everything works great with Lazarus 1.6.0 64 bits. Lazarus 32 was not tested. Lazarus 1.6.2 will be tested.
Any pull requests are welcome, it's a great news that you could make it work on 64bit.
@bvarga , I did nothing, really! ZMQPool still does not work on Win64 (even though it gets compiled with the corresponding "*.dll"). And on Linux 64, Lazarus 64 bits and compiling the 3.2.5 version from source it always worked without any changes. I am not sure why :roll_eyes: :dizzy:
Ps.: Lazarus 1.6.2 64 bits works great as well.