Crash on closing XmppConnection

Hi,

I consistently get a JVM crash due to an ‘access violation’ in ntdll.dll when closing an XmppConnection (crash dump below) and can’t track down the source of the problem.

It seems to be timing and/or threading related - e.g. adding System.out.println() statements in PacketReader.shutdown and PacketWriter.shutdown() can sometimes (but not reliably) prevent the crash.

So far the only reliable workaround I’ve found is to comment out the writer.close() section in PacketWriter.shutdown() as follows:

// Close the stream.

try

{ writer.write("</stream:stream>");

writer.flush();

}

catch (Exception e)

{ // Do nothing

}

finally

{ // NOTE: COMMENTED OUT TO AVOID CRASH IN NTDLL ON Windows 2000. TS

// (writer is closed in XmppConnection.disconnect() anyway)

// try {

// writer.close();

// }

// catch (Exception e) {

// // Do nothing

// }

}

I’d like to find a better fix though so if anybody has any better ideas or more information …

regards

Tony Seebregts

Java crash dump:

  1. An unexpected error has been detected by Java Runtime Environment:

  1. EXCEPTION_ACCESS_VIOLATION (0xc0000005) at pc=0x77f8f281, pid=812, tid=516

  1. Java VM: Java HotSpot™ Client VM (1.6.0_01-b06 mixed mode, sharing)

  2. Problematic frame:

  3. C http://ntdll.dll+0xf281

  1. If you would like to submit a bug report, please visit:

  2. http://java.sun.com/webapps/bugreport/crash.jsp


T H R E A D -


Current thread (0x02e00800): JavaThread “Smack Packet Reader” daemon

siginfo: ExceptionCode=0xc0000005, writing address 0x00000010

Registers:

EAX=0x00000000, EBX=0x00000000, ECX=0x03a562fc, EDX=0x00002320

ESP=0x03c5ecc8, EBP=0x03c5ed28, ESI=0x03a562ec, EDI=0x00000000

EIP=0x77f8f281, EFLAGS=0x00010246

Top of Stack: (sp=0x03c5ecc8)

0x03c5ecc8: 03a33b58 00000000 00000000 74fd160d

0x03c5ecd8: 00002324 000023c8 00000000 00000001

0x03c5ece8: 03c5edd8 03c5ede4 00000001 03c5ed88

0x03c5ecf8: 20b01a6a 0009cbe8 00002324 03c5edcc

0x03c5ed08: 03c5edc0 00000001 00000000 00000020

0x03c5ed18: 00000000 00000010 00000000 00000000

0x03c5ed28: 03c5edc0 77f87f26 03a56200 20b0453e

0x03c5ed38: 03a562ec 03c5edd8 00000000 03c5edc0

Instructions: (pc=0x77f8f281)

0x77f8f271: 39 5e 10 89 45 fc 75 06 56 e8 1f fe ff ff 8b 06

0x77f8f281: ff 40 10 ff 75 fc 8b 06 ff 40 14 53 ff 76 10 e8

Stack: [0x03c10000,0x03c60000), sp=0x03c5ecc8, free space=315k

Native frames: (J=compiled Java code, j=interpreted, Vv=VM code, C=native code)

C http://ntdll.dll+0xf281

C http://ntdll.dll+0x7f26

Java frames: (J=compiled Java code, j=interpreted, Vv=VM code)

j java.net.SocketInputStream.socketRead0(Ljava/io/FileDescriptor;[BIII)I+0

j java.net.SocketInputStream.read([BII)I+84

j sun.nio.cs.StreamDecoder.readBytes()I+135

j sun.nio.cs.StreamDecoder.implRead([CII)I+112

j sun.nio.cs.StreamDecoder.read([CII)I+180

j java.io.InputStreamReader.read([CII)I+7

j java.io.BufferedReader.fill()V+145

j java.io.BufferedReader.read1([CII)I+47

j java.io.BufferedReader.read([CII)I+61

j org.xmlpull.mxp1.MXParser.fillBuf()V+323

J org.xmlpull.mxp1.MXParser.more()C

J org.xmlpull.mxp1.MXParser.nextImpl()I

j org.xmlpull.mxp1.MXParser.next()I+6

j org.jivesoftware.smack.PacketReader.parsePackets()V+602

j org.jivesoftware.smack.PacketReader.access$0(Lorg/jivesoftware/smack/PacketRead er;)V+1

j org.jivesoftware.smack.PacketReader$1.run()V+4

v ~StubRoutines::call_stub


P R O C E S S -


Java Threads: ( => current thread )

0x00776800 JavaThread “DestroyJavaVM”

0x02a38c00 JavaThread “Log Event Dispatcher” daemon

0x029db000 JavaThread “Thread-6” daemon

=>0x02e00800 JavaThread “Smack Packet Reader” daemon

0x02ab6400 JavaThread “Thread-2” daemon

0x0301f400 JavaThread “Timer-0” daemon

0x02ed1c00 JavaThread “Start Level Event Dispatcher” daemon

0x02f31800 JavaThread “OSGi Console”

0x02f1e400 JavaThread “Framework Event Dispatcher” daemon

0x029ed400 JavaThread “Low Memory Detector” daemon

0x029e8400 JavaThread “CompilerThread0” daemon

0x029e7400 JavaThread “Attach Listener” daemon

0x029e6400 JavaThread “Signal Dispatcher” daemon

0x029e1c00 JavaThread “Finalizer” daemon

0x029dd800 JavaThread “Reference Handler” daemon

Wow, that’s a weird one! You could try using another Java release. I’m guessing this is a Java bug on Windows 2000, though. I don’t think there is anything wrong with our logic.

Regards,

Matt

Mmmm … also starting to suspect its a Windows 2000 specific Java bug (it happens with both Java 5 and Java 6) - closing a writer just shouldn’t affect a reader in a different thread.

Will keep gnawing away at it - starting with trying it out on an XP box.

regards

Tony