JDK-6619873 : JVM crashes while playing a midi file
  • Type: Bug
  • Component: client-libs
  • Sub-Component: javax.sound
  • Affected Version: 6u2
  • Priority: P4
  • Status: Closed
  • Resolution: Won't Fix
  • OS: windows_xp
  • CPU: other
  • Submitted: 2007-10-22
  • Updated: 2011-01-19
  • Resolved: 2009-01-21
Related Reports
Relates :  
Description
OPERATING SYSTEM(S):
Windows XP Professional SP2

FULL JDK VERSION(S):
java version "1.6.0_02"
Java(TM) SE Runtime Environment (build 1.6.0_02-b06)
Java HotSpot(TM) Client VM (build 1.6.0_02-b06, mixed mode)

DESCRIPTION:

The sample program is a stress test that tries to open multiple midi devices invoking multiple threads.

Expected Result:
The program should run smoothly producing no dumps.

Observed Result:
Program behaviour is inconsistent. JVM crashes occur.


STEPS TO REPRODUCE

1. Install SUN JDK 1.6.0_02-b06
2. Change the location of the midi file in the sample program to your
   own midi file location.
3. Compile the program with the above mentioned build.
4. Now run the program.


TESTCASE:

import java.io.IOException;
import java.net.MalformedURLException;
import java.net.URL;
import javax.sound.midi.InvalidMidiDataException;
import javax.sound.midi.MidiSystem;
import javax.sound.midi.MidiUnavailableException;
import javax.sound.midi.Sequence;
import javax.sound.midi.Sequencer;


class sample extends Thread {
	
	public void run() {
	
	   	double dur,cur_dur;
        Sequence seq = null;
        try {
			seq = MidiSystem.getSequence(new URL("file:///C:/WINDOWS/Media/town.mid"));
		} catch (MalformedURLException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (InvalidMidiDataException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (Exception e)
		{
		  System.out.println("Inside catch!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!1");
		  e.printStackTrace();
		}
		
        Sequencer seqcer;
		try {
			seqcer = MidiSystem.getSequencer();
			seqcer.open();
			  seqcer.setSequence(seq);
		        dur = 1;
		        cur_dur =0; 
		        seqcer.start();
		        do
				{
				   dur=seqcer.getMicrosecondLength();
		           cur_dur=seqcer.getMicrosecondPosition();
		       	}while(dur!=cur_dur);
		       	
			System.out.println(Thread.currentThread().getName()+"finished");
		   seqcer.close();
		   System.out.println("Executed close of"
		   +  Thread.currentThread().getName() );
		} catch (MidiUnavailableException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (InvalidMidiDataException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		catch (Exception e)
		{
		  System.out.println("Inside catch!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!1");
		  e.printStackTrace();
		}
    		
    }
   
	public static void main(String[] args) throws Exception
	{
		// Create and start the thread
		Thread thread1 = new sample();
		Thread thread2 = new sample();
		Thread thread3 = new sample();
		Thread thread4 = new sample();
		Thread thread5 = new sample();
		Thread thread6 = new sample();
		Thread thread7 = new sample();
		Thread thread8 = new sample();
		Thread thread9 = new sample();
		Thread thread10 = new sample();
		Thread thread11 = new sample();
		Thread thread12 = new sample();
		Thread thread13 = new sample();
		Thread thread14 = new sample();
		Thread thread15 = new sample();
		Thread thread16 = new sample();
		Thread thread17 = new sample();
		Thread thread18 = new sample();
		Thread thread19 = new sample();
		Thread thread20 = new sample();
		Thread thread21 = new sample();
		Thread thread22 = new sample();
		Thread thread23 = new sample();
		Thread thread24 = new sample();
		Thread thread25 = new sample();
		Thread thread26 = new sample();
		Thread thread27 = new sample();
		Thread thread28 = new sample();
		Thread thread29 = new sample();
		Thread thread30 = new sample();
		Thread thread31 = new sample();
		Thread thread32 = new sample();
		
		thread1.start();
		
		thread2.start();
		thread3.start();
		thread4.start();
		thread5.start();
		thread6.start();
		thread7.start();
		thread8.start();
		thread9.start();
		thread10.start();
		thread11.start();
		thread12.start();
		thread13.start();
		thread14.start();
		thread15.start();
		thread16.start();
		thread17.start();
		thread18.start();
		thread19.start();
		thread20.start();
		thread21.start();
		thread22.start();
		thread23.start();
		thread24.start();
		thread25.start();
		thread26.start();
		thread27.start();
		thread28.start();
		thread29.start();
		thread30.start();
		thread31.start();
		thread32.start();
	}

}



SAMPLE HS_ERR OUTPUT:

#
# An unexpected error has been detected by Java Runtime Environment:
#
#  EXCEPTION_ACCESS_VIOLATION (0xc0000005) at pc=0x7c911e58, pid=7460, tid=7712
#
# Java VM: Java HotSpot(TM) Client VM (1.6.0_02-b06 mixed mode)
# Problematic frame:
# C  [ntdll.dll+0x11e58]
#
# If you would like to submit a bug report, please visit:
#   http://java.sun.com/webapps/bugreport/crash.jsp
#

---------------  T H R E A D  ---------------

Current thread (0x0afaa400):  JavaThread "Thread-31" [_thread_in_native, id=7712]

siginfo: ExceptionCode=0xc0000005, reading address 0x00000000

Registers:
EAX=0x0d31a008, EBX=0x000a0000, ECX=0x00000000, EDX=0x00000000
ESP=0x0b9af4f8, EBP=0x0b9af504, ESI=0x0d31a000, EDI=0x0d31d000
EIP=0x7c911e58, EFLAGS=0x00010246

Top of Stack: (sp=0x0b9af4f8)
0x0b9af4f8:   000a0000 00000001 000a0006 0b9af53c
0x0b9af508:   7c918251 00000000 0d31d000 0b9af530
0x0b9af518:   00000000 00000101 00000000 000a0000
0x0b9af528:   0b9af506 ffffffff 00000200 0cc40000
0x0b9af538:   7c910738 0b9af76c 7c911c76 050a0000
0x0b9af548:   00000808 00000000 0c52c0f0 7c80ff19
0x0b9af558:   000a0000 001208f0 0b9af550 7c90ee18
0x0b9af568:   0b9af794 7c90ee18 000a01a0 ffffffff 

Instructions: (pc=0x7c911e58)
0x7c911e48:   85 97 7a 03 00 8b 4e 0c 8d 46 08 8b 10 89 4d 08
0x7c911e58:   8b 09 3b 4a 04 89 55 0c 0f 85 9d 00 00 00 3b c8 


Stack: [0x0b960000,0x0b9b0000),  sp=0x0b9af4f8,  free space=317k
Native frames: (J=compiled Java code, j=interpreted, Vv=VM code, C=native code)
C  [ntdll.dll+0x11e58]
C  [ntdll.dll+0x18251]
C  [ntdll.dll+0x11c76]
C  [kernel32.dll+0xfe6f]
C  [wdmaud.drv+0x2c4b]
C  [wdmaud.drv+0x2729]
C  [WINMM.dll+0x18d0c]
C  [midimap.dll+0x1fa7]
C  [midimap.dll+0x29f3]
C  [WINMM.dll+0x18d0c]
C  [jsound.dll+0x18535]
j  com.sun.media.sound.MidiOutDevice.nOpen(I)J+0
j  com.sun.media.sound.MidiOutDevice.implOpen()V+14
j  com.sun.media.sound.AbstractMidiDevice.doOpen()V+12
j  com.sun.media.sound.AbstractMidiDevice.openInternal(Ljava/lang/Object;)V+34
j  com.sun.media.sound.AbstractMidiDevice.getReceiverReferenceCounting()Ljavax/sound/midi/Receiver;+14
j  javax.sound.midi.MidiSystem.getReceiver()Ljavax/sound/midi/Receiver;+18
j  javax.sound.midi.MidiSystem.getSequencer(Z)Ljavax/sound/midi/Sequencer;+145
j  javax.sound.midi.MidiSystem.getSequencer()Ljavax/sound/midi/Sequencer;+1
j  sample.run()V+47
v  ~StubRoutines::call_stub

Java frames: (J=compiled Java code, j=interpreted, Vv=VM code)
j  com.sun.media.sound.MidiOutDevice.nOpen(I)J+0
j  com.sun.media.sound.MidiOutDevice.implOpen()V+14
j  com.sun.media.sound.AbstractMidiDevice.doOpen()V+12
j  com.sun.media.sound.AbstractMidiDevice.openInternal(Ljava/lang/Object;)V+34
j  com.sun.media.sound.AbstractMidiDevice.getReceiverReferenceCounting()Ljavax/sound/midi/Receiver;+14
j  javax.sound.midi.MidiSystem.getReceiver()Ljavax/sound/midi/Receiver;+18
j  javax.sound.midi.MidiSystem.getSequencer(Z)Ljavax/sound/midi/Sequencer;+145
j  javax.sound.midi.MidiSystem.getSequencer()Ljavax/sound/midi/Sequencer;+1
j  sample.run()V+47
v  ~StubRoutines::call_stub

---------------  P R O C E S S  ---------------

Java Threads: ( => current thread )
  0x0afc3800 JavaThread "Headspace mixer frame proc thread" daemon [_thread_in_native, id=7764]
  0x0afbd400 JavaThread "Java Sound Event Dispatcher" daemon [_thread_blocked, id=7748]
  0x0afbc800 JavaThread "Java Sound Event Dispatcher" daemon [_thread_blocked, id=7744]
  0x00296800 JavaThread "DestroyJavaVM" [_thread_blocked, id=7536]
=>0x0afaa400 JavaThread "Thread-31" [_thread_in_native, id=7712]
  0x0afa9400 JavaThread "Thread-30" [_thread_in_native, id=7708]
  0x0afa8400 JavaThread "Thread-29" [_thread_in_native, id=7704]
  0x0afa7400 JavaThread "Thread-28" [_thread_in_native, id=7696]
  0x0afa6400 JavaThread "Thread-27" [_thread_in_native, id=7692]
  0x0afa5400 JavaThread "Thread-26" [_thread_in_native, id=7688]
  0x0afa4400 JavaThread "Thread-25" [_thread_in_native, id=7684]
  0x0afa3400 JavaThread "Thread-24" [_thread_in_native, id=7680]
  0x0afa2400 JavaThread "Thread-23" [_thread_in_native, id=7676]
  0x0afa1400 JavaThread "Thread-22" [_thread_in_native, id=7672]
  0x0af9f400 JavaThread "Thread-21" [_thread_in_native, id=7668]
  0x0af9e400 JavaThread "Thread-20" [_thread_in_native, id=7664]
  0x0af9d400 JavaThread "Thread-19" [_thread_in_native, id=3592]
  0x0af9c400 JavaThread "Thread-18" [_thread_in_native, id=7660]
  0x0af9b400 JavaThread "Thread-17" [_thread_in_native, id=7656]
  0x0af99800 JavaThread "Thread-16" [_thread_in_native, id=7652]
  0x0af98800 JavaThread "Thread-15" [_thread_in_native, id=7648]
  0x0af97800 JavaThread "Thread-14" [_thread_in_native, id=7644]
  0x0af96800 JavaThread "Thread-13" [_thread_in_native, id=7640]
  0x0af95800 JavaThread "Thread-12" [_thread_in_native, id=7636]
  0x0af94800 JavaThread "Thread-11" [_thread_in_native, id=7632]
  0x0af93800 JavaThread "Thread-10" [_thread_in_native, id=7628]
  0x0af92800 JavaThread "Thread-9" [_thread_in_native, id=7624]
  0x0af91800 JavaThread "Thread-8" [_thread_in_native, id=7620]
  0x0af90800 JavaThread "Thread-7" [_thread_in_native, id=7616]
  0x0ab2f800 JavaThread "Thread-6" [_thread_in_native, id=7608]
  0x0ab2e800 JavaThread "Thread-5" [_thread_in_native, id=7604]
  0x0ab2d800 JavaThread "Thread-4" [_thread_in_native, id=7600]
  0x0ab2c800 JavaThread "Thread-3" [_thread_in_native, id=7596]
  0x0ab2bc00 JavaThread "Thread-2" [_thread_in_native, id=7592]
  0x0aadb800 JavaThread "Thread-1" [_thread_in_native, id=7588]
  0x0aadb000 JavaThread "Thread-0" [_thread_in_native, id=7584]
  0x0aabd400 JavaThread "Low Memory Detector" daemon [_thread_blocked, id=7572]
  0x0aab8800 JavaThread "CompilerThread0" daemon [_thread_blocked, id=7568]
  0x0aab7400 JavaThread "Attach Listener" daemon [_thread_blocked, id=5244]
  0x0aab6400 JavaThread "Signal Dispatcher" daemon [_thread_blocked, id=7560]
  0x0aaa7000 JavaThread "Finalizer" daemon [_thread_blocked, id=7556]
  0x0aaa2c00 JavaThread "Reference Handler" daemon [_thread_blocked, id=7552]

Other Threads:
  0x0aa9fc00 VMThread [id=7548]
  0x0aad7c00 WatcherThread [id=7580]

VM state:not at safepoint (normal execution)

VM Mutex/Monitor currently owned by a thread: None

Heap
 def new generation   total 2816K, used 1783K [0x02990000, 0x02c90000, 0x02e70000)
  eden space 2560K,  69% used [0x02990000, 0x02b4de00, 0x02c10000)
  from space 256K,   0% used [0x02c10000, 0x02c10000, 0x02c50000)
  to   space 256K,   0% used [0x02c50000, 0x02c50000, 0x02c90000)
 tenured generation   total 34992K, used 20993K [0x02e70000, 0x0509c000, 0x06990000)
   the space 34992K,  59% used [0x02e70000, 0x042f0570, 0x042f0600, 0x0509c000)
 compacting perm gen  total 12288K, used 2195K [0x06990000, 0x07590000, 0x0a990000)
   the space 12288K,  17% used [0x06990000, 0x06bb4f10, 0x06bb5000, 0x07590000)
No shared spaces configured.

Dynamic libraries:
0x00400000 - 0x00423000 	H:\sandbox\sun_jdk6_02\bin\java.exe
0x7c900000 - 0x7c9b0000 	C:\WINDOWS\system32\ntdll.dll
0x7c800000 - 0x7c8f5000 	C:\WINDOWS\system32\kernel32.dll
0x77dd0000 - 0x77e6b000 	C:\WINDOWS\system32\ADVAPI32.dll
0x77e70000 - 0x77f01000 	C:\WINDOWS\system32\RPCRT4.dll
0x7c340000 - 0x7c396000 	H:\sandbox\sun_jdk6_02\jre\bin\msvcr71.dll
0x6d870000 - 0x6dab9000 	H:\sandbox\sun_jdk6_02\jre\bin\client\jvm.dll
0x7e410000 - 0x7e4a0000 	C:\WINDOWS\system32\USER32.dll
0x77f10000 - 0x77f57000 	C:\WINDOWS\system32\GDI32.dll
0x76b40000 - 0x76b6d000 	C:\WINDOWS\system32\WINMM.dll
0x76390000 - 0x763ad000 	C:\WINDOWS\system32\IMM32.DLL
0x629c0000 - 0x629c9000 	C:\WINDOWS\system32\LPK.DLL
0x74d90000 - 0x74dfb000 	C:\WINDOWS\system32\USP10.dll
0x77c10000 - 0x77c68000 	C:\WINDOWS\system32\msvcrt.dll
0x6d3c0000 - 0x6d3c8000 	H:\sandbox\sun_jdk6_02\jre\bin\hpi.dll
0x76bf0000 - 0x76bfb000 	C:\WINDOWS\system32\PSAPI.DLL
0x6d820000 - 0x6d82c000 	H:\sandbox\sun_jdk6_02\jre\bin\verify.dll
0x6d460000 - 0x6d47f000 	H:\sandbox\sun_jdk6_02\jre\bin\java.dll
0x6d860000 - 0x6d86f000 	H:\sandbox\sun_jdk6_02\jre\bin\zip.dll
0x6d5d0000 - 0x6d5f4000 	H:\sandbox\sun_jdk6_02\jre\bin\jsound.dll
0x6d600000 - 0x6d608000 	H:\sandbox\sun_jdk6_02\jre\bin\jsoundds.dll
0x73f10000 - 0x73f6c000 	C:\WINDOWS\system32\DSOUND.dll
0x774e0000 - 0x7761d000 	C:\WINDOWS\system32\ole32.dll
0x77c00000 - 0x77c08000 	C:\WINDOWS\system32\VERSION.dll
0x76c30000 - 0x76c5e000 	C:\WINDOWS\system32\WINTRUST.dll
0x77a80000 - 0x77b14000 	C:\WINDOWS\system32\CRYPT32.dll
0x77b20000 - 0x77b32000 	C:\WINDOWS\system32\MSASN1.dll
0x76c90000 - 0x76cb8000 	C:\WINDOWS\system32\IMAGEHLP.dll
0x72d20000 - 0x72d29000 	C:\WINDOWS\system32\wdmaud.drv
0x72d10000 - 0x72d18000 	C:\WINDOWS\system32\msacm32.drv
0x77be0000 - 0x77bf5000 	C:\WINDOWS\system32\MSACM32.dll
0x77bd0000 - 0x77bd7000 	C:\WINDOWS\system32\midimap.dll

VM Arguments:
java_command: sample
Launcher Type: SUN_STANDARD

Environment Variables:

[error occurred during error reporting, step 220, id 0xc0000005]



---------------  S Y S T E M  ---------------

OS: Windows XP Build 2600 Service Pack 2

CPU:total 1 (1 cores per cpu, 1 threads per core) family 15 model 2 stepping 9, cmov, cx8, fxsr, mmx, sse, sse2

Memory: 4k page, physical 2095088k(1250032k free), swap 2714960k(1597316k free)

vm_info: Java HotSpot(TM) Client VM (1.6.0_02-b06) for windows-x86, built on Jul 12 2007 01:16:14 by "java_re" with unknown MS VC++:1310

Comments
EVALUATION The issue has gone with new Synthesizer. Closing the CR.
21-01-2009

EVALUATION The synthesizer implementation will be replaced soon (with open-source implementation) so the CR will be closed.
07-02-2008

EVALUATION The bug is in Synthesizer implementation (MixerSynth). It supports only 16 instances simultaneously, but does not report when the limit reached. see src/closed/share/native/com/sun/media/sound/engine/GenSong.c, line 493 (GM_StartLiveSong function) If it is not able to find free slot (songSlot == -1) it should report error (TOO_MANY_SONGS_PLAYING ?)
07-02-2008