jeromq icon indicating copy to clipboard operation
jeromq copied to clipboard

periodic index-out-of-bounds error

Open stealthrabbi opened this issue 2 years ago • 10 comments

Using v0.5.2

My program is able to run days sending binary pictures, but will occasionally encounter an IndexOutOfBoundsException. I am not sure if it's an apparent issue with the data being sent to the zmq client, or something with a connection. The issue is not easily repeatable.

Also, are there release notes for different versions? I see there's now a 0.5.3, but I can't tell what's been added to it.

Exception in thread "My Thread" Exception in thread "My Thread" java.lang.IndexOutOfBoundsException: Index 1 out of bounds for length 1
        at java.base/jdk.internal.util.Preconditions.outOfBounds(Unknown Source)
        at java.base/jdk.internal.util.Preconditions.outOfBoundsCheckIndex(Unknown Source)
        at java.base/jdk.internal.util.Preconditions.checkIndex(Unknown Source)
        at java.base/java.util.Objects.checkIndex(Unknown Source)
        at java.base/java.util.ArrayList.get(Unknown Source)
        at zmq.socket.pubsub.Dist.distribute(Dist.java:162)
        at zmq.socket.pubsub.Dist.sendToMatching(Dist.java:138)
        at zmq.socket.pubsub.XPub.xsend(XPub.java:253)
        at zmq.SocketBase.send(SocketBase.java:718)
        at org.zeromq.ZMQ$Socket.send(ZMQ.java:3205)
        at org.zeromq.ZFrame.send(ZFrame.java:136)
        at org.zeromq.ZFrame.sendAndKeep(ZFrame.java:151)
        at org.zeromq.ZMsg.send(ZMsg.java:187)
        at org.zeromq.ZMsg.send(ZMsg.java:159)
        at org.zeromq.proto.ZPicture.sendBinaryPicture(ZPicture.java:168)
        at org.zeromq.ZMQ$Socket.sendBinaryPicture(ZMQ.java:3342)
		<<my code>>

stealthrabbi avatar Jan 11 '23 12:01 stealthrabbi

@stealthrabbi Can you verify if this is still an issue with v0.5.3?

trevorbernard avatar Jan 11 '23 13:01 trevorbernard

@trevorbernard I will try. The issue is that the exception sometimes takes many days to surface -- it's hard to pin down. Do you happen to have a list of things changed in 0.5.2 -> 0.5.3

stealthrabbi avatar Jan 11 '23 13:01 stealthrabbi

https://github.com/zeromq/jeromq/blob/master/CHANGELOG.md

trevorbernard avatar Jan 11 '23 13:01 trevorbernard

No the issue still exists in 0.5.3. Took about 24 hours to recreate. In my program, I've added an exception handler for this case, but I see now that the exception continues forever. I am guessing I need to create a new zmq socket. I also don't know if I can reuse the ZContext I created when my program starts, or if a new ZContext is needed.

stealthrabbi avatar Jan 12 '23 12:01 stealthrabbi

Just to be sure, the XPub socket is not shared between threads ?

fbacchella avatar Jan 28 '23 09:01 fbacchella

Can you try with this branch: https://github.com/fbacchella/jeromq/tree/issue938 ?

fbacchella avatar Jan 28 '23 19:01 fbacchella

I am still seeing this issue with version 0.5.4.

elihusmails avatar Nov 16 '23 14:11 elihusmails

This branch was not merged as nobody provided any feebdback.

fbacchella avatar Nov 16 '23 15:11 fbacchella

I added the changes to the Dist.java in my local 0.5.4 environment and recompiled/installed the change. While I'm not getting the stack trace, it appears that my app is silently failing now. I'm going to dig into this more.

elihusmails avatar Nov 16 '23 16:11 elihusmails

I'm also experiencing this issue and for me it seems fairly easily reproduceable:

at java.base/jdk.internal.util.Preconditions.outOfBoundsCheckIndex(Preconditions.java:70) at java.base/jdk.internal.util.Preconditions.checkIndex(Preconditions.java:266) at java.base/java.util.Objects.checkIndex(Objects.java:361) at java.base/java.util.ArrayList.get(ArrayList.java:427) at zmq.socket.pubsub.Dist.distribute(Dist.java:161) at zmq.socket.pubsub.Dist.sendToMatching(Dist.java:137) at zmq.socket.pubsub.XPub.xsend(XPub.java:253) at zmq.SocketBase.send(SocketBase.java:829) at zmq.SocketBase.send(SocketBase.java:792) at org.zeromq.ZMQ$Socket.send(ZMQ.java:3445)

In my setup, a Java application creates a zeromq socket of tpye SocketType.PUB and connects to a XPUB/XPUB router. The connection is setup in the constructor of a class, and the oob exception is triggered periodically (but i can see it happening at least once a day in my current setup).

tommy2d avatar Apr 24 '24 08:04 tommy2d