[SNMP4J] SNMP Buffer OverFlow Exception

Frank Fock fock at agentpp.com
Wed May 1 00:25:55 CEST 2013


Hello Akshay,

I think the root cause is the buffer overflow exception.
First, you should fix that issue.

Possible causes are:
1. The PDU or any contained VariableBinding is modified by another
thread (for example the PDU sender) after calling asynchronous
Snmp.send*.
2. A variable binding is being sent, that is not supported by the
protocol version (as you send a scoped pdu, I think this cases is not
matching your case).

Then you can optimize the threading behavior by reducing the
bootle neck in Snmp.NotificationDispatcher.processPdu by
replacing it with:

     public void processPdu(CommandResponderEvent event) {
       CommandResponder listener;
       synchronized (this) {
         listener = notificationTransports.get(event.getTransportMapping());
       }
       if ((event.getPDU() != null) &&
           (event.getPDU().getType() == PDU.INFORM)) {
         // try to send INFORM response
         try {
           sendInformResponse(event);
         }
         catch (MessageException mex) {
           if (logger.isWarnEnabled()) {
             logger.warn("Failed to send response on INFORM PDU event (" +
                         event + "): " + mex.getMessage());
           }
         }
       }
       if (listener != null) {
         listener.processPdu(event);
       }
     }

Best regards,
Frank

Am 30.04.2013 17:35, schrieb Ballarpure, Akshay (NSN - IN/Hyderabad):
> Hello Frank,
> I am also facing below error in our application with SNMP4J stack (version is 1.11.1)
>
> INFO   | jvm 2    | 2013/04/29 13:36:54 | Exception in thread "Timer-7" java.nio.BufferOverflowException
> INFO   | jvm 2    | 2013/04/29 13:36:54 |       at java.nio.Buffer.nextPutIndex(Unknown Source)
> INFO   | jvm 2    | 2013/04/29 13:36:54 |       at java.nio.HeapByteBuffer.put(Unknown Source)
> INFO   | jvm 2    | 2013/04/29 13:36:54 |       at org.snmp4j.asn1.BEROutputStream.write(BEROutputStream.java:64)
> INFO   | jvm 2    | 2013/04/29 13:36:54 |       at org.snmp4j.asn1.BER.encodeHeader(BER.java:119)
> INFO   | jvm 2    | 2013/04/29 13:36:54 |       at org.snmp4j.smi.VariableBinding.encodeBER(VariableBinding.java:178)
> INFO   | jvm 2    | 2013/04/29 13:36:54 |       at org.snmp4j.PDU.encodeBER(PDU.java:528)
> INFO   | jvm 2    | 2013/04/29 13:36:54 |       at org.snmp4j.ScopedPDU.encodeBER(ScopedPDU.java:123)
> INFO   | jvm 2    | 2013/04/29 13:36:54 |       at org.snmp4j.mp.MPv3.prepareOutgoingMessage(MPv3.java:722)
> INFO   | jvm 2    | 2013/04/29 13:36:54 |       at org.snmp4j.MessageDispatcherImpl.sendPdu(MessageDispatcherImpl.java:444)
> INFO   | jvm 2    | 2013/04/29 13:36:54 |       at org.snmp4j.util.MultiThreadedMessageDispatcher.sendPdu(MultiThreadedMessageDispatcher.java:146)
> INFO   | jvm 2    | 2013/04/29 13:36:54 |       at org.snmp4j.Snmp.sendMessage(Snmp.java:1067)
> INFO   | jvm 2    | 2013/04/29 13:36:54 |       at org.snmp4j.Snmp$PendingRequest.run(Snmp.java:1610)
> INFO   | jvm 2    | 2013/04/29 13:36:54 |       at java.util.TimerThread.mainLoop(Unknown Source)
> INFO   | jvm 2    | 2013/04/29 13:36:54 |       at java.util.TimerThread.run(Unknown Source)
>
> I took a thread dump and observed that all the dispatcher pool threads are in blocked state and hence SNMP4J stack is unable to process informs. So could you please let us know if it is known issue in SNMP4J stack version 1.11.1 ?
>
> Thread dump from our apps
> -------------------------------------------
>
> "DispatcherPool.6" prio=3 tid=0x00a78c00 nid=0xe8 waiting for monitor entry [0x27e0f000]
> java.lang.Thread.State: BLOCKED (on object monitor)
> at org.snmp4j.Snmp$NotificationDispatcher.processPdu(Snmp.java:1825)
> - waiting to lock <0x44c7c3d8> (a org.snmp4j.Snmp$NotificationDispatcher)
> at org.snmp4j.Snmp.fireProcessPdu(Snmp.java:1430)
> at org.snmp4j.Snmp.processPdu(Snmp.java:1288)
> at org.snmp4j.MessageDispatcherImpl.fireProcessPdu(MessageDispatcherImpl.java:616)
> at org.snmp4j.MessageDispatcherImpl.dispatchMessage(MessageDispatcherImpl.java:287)
> at org.snmp4j.MessageDispatcherImpl.processMessage(MessageDispatcherImpl.java:347)
> at org.snmp4j.util.MultiThreadedMessageDispatcher$MessageTask.run(MultiThreadedMessageDispatcher.java:209)
> at org.snmp4j.util.ThreadPool$TaskManager.run(ThreadPool.java:239)      - locked <
> 0x44cb3710> (a org.snmp4j.util.ThreadPool$TaskManager)
>
>
>
> --
> With Thanks & Regards,
> Akshay Ballarpure
> AOffice:  +91-40-4472-4112
>
> -----Original Message-----
> From: snmp4j-bounces at agentpp.org [mailto:snmp4j-bounces at agentpp.org] On Behalf Of ext Frank Fock
> Sent: Saturday, November 19, 2011 2:20 AM
> To: snmp4j at agentpp.org
> Subject: Re: [SNMP4J] SNMP Buffer OverFlow Exception
>
> Hi Vinod,
>
> You do not have to change anything on OS level.
> With SNMP you cannot send packets that exceed 64K.
> But I do not think that this is the problem here.
> I guess that you modify the PDU contents while it
> is being encoded. Have you checked that already?
>
> Best regards,
> Frank
>
>
> Am 18.11.2011 05:53, schrieb vinod:
>> Hi,
>>
>> I am facing the Buffer OverFlow Exception when trying to do send a snmp
>> packet. The Stack Trace is given below.
>>
>> java.nio.BufferOverflowException
>>           at java.nio.Buffer.nextPutIndex(Buffer.java:513)
>>           at java.nio.HeapByteBuffer.put(HeapByteBuffer.java:163)
>>           at org.snmp4j.asn1.BEROutputStream.write(BEROutputStream.java:64)
>>           at org.snmp4j.asn1.BER.encodeHeader(BER.java:119)
>>           at org.snmp4j.smi.Null.encodeBER(Null.java:99)
>>           at
>> org.snmp4j.smi.VariableBinding.encodeBER(VariableBinding.java:181)
>>           at org.snmp4j.PDU.encodeBER(PDU.java:528)
>>           at org.snmp4j.mp.MPv1.prepareOutgoingMessage(MPv1.java:132)
>>           at
>> org.snmp4j.MessageDispatcherImpl.sendPdu(MessageDispatcherImpl.java:444)
>>
>> I had increased all the memory limits in linux and still facing this
>> problem very often. Kindly guide me in solving the problem.
>>
>> Thanks,
>> Vinod Kumar Boppanna
>>
>> _______________________________________________
>> SNMP4J mailing list
>> SNMP4J at agentpp.org
>> http://lists.agentpp.org/mailman/listinfo/snmp4j

-- 
---
AGENT++
Maximilian-Kolbe-Str. 10
73257 Koengen, Germany
https://agentpp.com
Phone: +49 7024 8688230
Fax:   +49 7024 8688231




More information about the SNMP4J mailing list