Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Pinned object overflow exception?

Tags:

java

exception

Getting below error in logs though. I do not see any visible impact of it on my application like on UI or performance. Using weblogic Jrockit JVM.

Caused by: java.lang.InternalError: pinned object overflow!
    at java.util.zip.Inflater.inflateBytes(Inflater.java:381) ~[na:1.6.0_31]
    at java.util.zip.Inflater.inflate(Inflater.java:231) ~[na:1.6.0_31]
    at java.util.zip.InflaterInputStream.read(InflaterInputStream.java:135) ~[na:1.6.0_31]
    at java.io.FilterInputStream.read(FilterInputStream.java:116) ~[na:1.6.0_31]
    at sun.nio.cs.StreamDecoder.readBytes(StreamDecoder.java:264) ~[na:1.6.0_31]

On net, I do not find anything specific to pinned object overflow exception. To me this does not look like programming issue but issue related to weblogic or jrockit?

Any pointers how can I get rid of this?

like image 571
emilly Avatar asked Apr 30 '16 09:04

emilly


People also ask

What is a pinned object?

Many wish to access the memory location if they have unmanaged code that references to a C# object they've built. Now they can accomplish this with confidence if they pin the object. But what exactly is pinning an object? In simple words, a pinned object is nothing but an object that has a specific memory location.

Can you catch a StackOverflowException?

NET Framework 2.0, you can't catch a StackOverflowException object with a try / catch block, and the corresponding process is terminated by default. Consequently, you should write your code to detect and prevent a stack overflow.

What causes stack overflow c#?

What causes stack overflow? One of the most common causes of a stack overflow is the recursive function, a type of function that repeatedly calls itself in an attempt to carry out specific logic. Each time the function calls itself, it uses up more of the stack memory.

What is stack overflow error c#?

A StackOverflowException is thrown when the execution stack overflows because it contains too many nested method calls. For example, suppose you have an app as follows: C# Copy. using System; namespace temp { class Program { static void Main(string[] args) { Main(args); // Oops, this recursion won't stop. } } }


1 Answers

Pinning Object?:

Let first understand Pinning Object.Basically,Pinning is where we temporarily tag an object on the heap so that the garbage collector will not try to move the object until we remove the tag. Normally, an object might be moved from one address to another if it is being promoted (i.e. being moved from young space to old space) or as part of compaction (defragmentation). But if an object is pinned, the GC will not try to move it until it is unpinned.

So why would we want to pin an object?.

Pinning is important for simply a performance optimization. Pinning a buffer (a byte array) during an I/O operation allows us to hand it's address directly to the operating system. Because the buffer is pinned, we do not need to worry that the garbage collector will try to move it to a different address before the I/O operation finishes.

If we were not able to pin the buffer, we would need to allocate additional native (off-heap) memory to pass to the OS's native I/O call and also copy data between the on-heap and off-heap buffers.

So by pinning the buffer to a constant address on the heap, we avoid both having to do an otherwise redundant native memory allocation and a copy.

When pinned object overflow might happen?

This scenery might happen during JNI call or bad exception handling in I/O calls.To find out the real fact, we have to analyze thread dump to find out how many threads are blocked ie. stucked.

Troubleshooting:

So what should you do when you have a thread that appears stuck in a call to readBytesPinned or writeBytesPinned? That depends entirely on where the application is trying to read data from or write data to.

Lets look at a real-world example of a thread stuck doing a blocking read:

   "ExecuteThread: '2' for queue: 'weblogic.kernel.Default'" id=20 idx=0x2e tid=16946 prio=5 alive, in native, daemon
        at jrockit/net/SocketNativeIO.readBytesPinned(I[BIII)I(Native Method)
        at jrockit/net/SocketNativeIO.socketRead(Ljava/io/FileDescriptor;[BIII)I(Unknown Source)[inlined]
        at java/net/SocketInputStream.socketRead0(Ljava/io/FileDescriptor;[BIII)I(Unknown Source)[inlined]
        at java/net/SocketInputStream.read([BII)I(SocketInputStream.java:113)[optimized]
        at oracle/net/ns/Packet.receive()V(Unknown Source)[inlined]
        at oracle/net/ns/DataPacket.receive()V(Unknown Source)[optimized]
        at oracle/net/ns/NetInputStream.getNextPacket()V(Unknown Source)[optimized]
        at oracle/net/ns/NetInputStream.read([BII)I(Unknown Source)[inlined]
        at oracle/net/ns/NetInputStream.read([B)I(Unknown Source)[inlined]
        at oracle/net/ns/NetInputStream.read()I(Unknown Source)[optimized]
        at oracle/jdbc/driver/T4CMAREngine.unmarshalUB1()S(T4CMAREngine.java:1099)[optimized]
<rest of stack omited> 

In the above case, you can tell from the stack trace that the JDBC (database) driver is doing a blocking read from a network socket. So the typical next step would be to see if there is a reason why the expected data may have been delayed (or even never arrive at all). For example, the database server we are talking to could be hung, there could be a network issue that is delaying (or even dropping) the database’s response, or there could be some sort of protocol mismatch where both parties believe it is the other side’s turn to talk. Analyzing log files on both sides may provide clues as to what happened. If the issue is reproducible, collecting a network trace and analyzing it with a tool like WireShark may also prove useful.

Solutions:

Afer finding the proper reason, you could write proper exception handling and of course close the FileInputStream when we are finished with it to avoid the unwanted overflow.

References:thread_stuck_at_readbytespinned_writebytespinned

like image 124
CrawlingKid Avatar answered Sep 28 '22 12:09

CrawlingKid