Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-4681384

SourceDataLine.write() causes Unexpected Signal 11 in native code outside the VM

    Details

    • Subcomponent:
    • Resolved In Build:
      1.4.2
    • CPU:
      generic
    • OS:
      generic

      Backports

        Description

        {
                    out.println("\n==> test PASSED!");
                }
                return testResult;
            }
            
        } // end of test class
        -------------------------------------------------------------------------
         
        ======================================================================

        Name: abR10010 Date: 05/10/2002


        ###@###.### Date: 05/10/2002

        There is extra info for this bugreport:

        If the following strings in the test.java above:

                        int bufferSizeToWrite = testedSourceLine.available()
                            + (frameSize * framesNumberToExceed);

        are changed to the string:

                        int bufferSizeToWrite = testedSourceLine.available();

        and the following strings:

                        out.println("> wait for 10 seconds after write() method call!");
                        Object objForWait = new Object();
                        synchronized(objForWait) {
                            try {
                                objForWait.wait(10000);
                            }
                            catch (Throwable thrown) {
                            }
                        }

        are added after the write() method call before the string:

                        testedSourceLine.close();

        we have the same Unexpected Signal 11 running this updated test.

        So I think the reason of this failure is not the try to write more data
        than can currently be written.

        It seems that the exception happens when the mixer is processing the written to
        the source line bytes and it is not revealed without some delay (e.g. for 10 seconds)
        as the JVM exits before the exception.


        ======================================================================

        Name: ipR10067 Date: 08/15/2002



        The attached test.java also failed under Windows XP with similar log
        (The result is the same for JDK1.4.0-b92, 1.4.1-rc-b18 and 1.4.2-beta-b01):

        ==> Test for SourceDataLine.write() method:

        >>> Number of mixers installed on the system = 3

        >>> installedMixer[0] = com.sun.media.sound.HeadspaceMixer@76c74b

        >> Number of SourceLineInfo supported by installedMixer = 2

        > testSourceLineInfo[0] = interface SourceDataLine supporting 8 audio formats
        > testedSourceLine = com.sun.media.sound.MixerSourceLine@f436f5

        > open tested SourceLine:
        > OK - line is opened

        > check SourceDataLine.write() to write more data than can currently be written:
        > testedSourceLine.available() = 4
        > frame size = 4
        > number of bytes to write = 12

        An unexpected exception has been detected in native code outside the VM.
        Unexpected Signal : EXCEPTION_ACCESS_VIOLATION occurred at PC=0x6D2B16E0
        Function=[Unknown.]
        Library=H:\ld25\java\dest\jdk1.4.0\win\jre\bin\jsound.dll

        NOTE: We are unable to locate the function name symbol for the error
              just occurred. Please refer to release documentation for possible
              reason and solutions.


        Current Java thread:
        at com.sun.media.sound.MixerThread.runNative(Native Method)
        at com.sun.media.sound.MixerThread.run(MixerThread.java:314)

        Dynamic libraries:
        0x00400000 - 0x00406000 h:\ld25\java\dest\jdk1.4.0\win\bin\java.exe
        0x77F50000 - 0x77FF9000 F:\WINDOWS\System32\ntdll.dll
        0x77E60000 - 0x77F45000 F:\WINDOWS\system32\kernel32.dll
        0x77DD0000 - 0x77E5B000 F:\WINDOWS\system32\ADVAPI32.dll
        0x77CC0000 - 0x77D35000 F:\WINDOWS\system32\RPCRT4.dll
        0x77C10000 - 0x77C63000 F:\WINDOWS\system32\MSVCRT.dll
        0x6D330000 - 0x6D442000 h:\ld25\java\dest\jdk1.4.0\win\jre\bin\client\jvm.dll
        0x77D40000 - 0x77DCD000 F:\WINDOWS\system32\USER32.dll
        0x77C70000 - 0x77CB0000 F:\WINDOWS\system32\GDI32.dll
        0x76B40000 - 0x76B6C000 F:\WINDOWS\System32\WINMM.dll
        0x6D1D0000 - 0x6D1D7000 h:\ld25\java\dest\jdk1.4.0\win\jre\bin\hpi.dll
        0x6D300000 - 0x6D30D000 h:\ld25\java\dest\jdk1.4.0\win\jre\bin\verify.dll
        0x6D210000 - 0x6D228000 h:\ld25\java\dest\jdk1.4.0\win\jre\bin\java.dll
        0x6D320000 - 0x6D32D000 h:\ld25\java\dest\jdk1.4.0\win\jre\bin\zip.dll
        0x6D2A0000 - 0x6D2C1000 H:\ld25\java\dest\jdk1.4.0\win\jre\bin\jsound.dll
        0x72D20000 - 0x72D29000 F:\WINDOWS\System32\wdmaud.drv
        0x72D10000 - 0x72D18000 F:\WINDOWS\System32\msacm32.drv
        0x77BE0000 - 0x77BF4000 F:\WINDOWS\System32\MSACM32.dll
        0x77BD0000 - 0x77BD7000 F:\WINDOWS\System32\midimap.dll
        0x76C90000 - 0x76CB2000 F:\WINDOWS\system32\imagehlp.dll
        0x6D510000 - 0x6D58C000 F:\WINDOWS\system32\DBGHELP.dll
        0x77C00000 - 0x77C07000 F:\WINDOWS\system32\VERSION.dll
        0x76BF0000 - 0x76BFB000 F:\WINDOWS\System32\PSAPI.DLL

        Local Time = Fri Aug 16 11:41:06 2002
        Elapsed Time = 4
        #
        # The exception above was detected in native code outside the VM
        #
        # Java VM: Java HotSpot(TM) Client VM (1.4.0-b92 mixed mode)
        #
        # An error report file has been saved as hs_err_pid2016.log.
        # Please refer to the file for further information.
        #


        ======================================================================


        Name: abR10010 Date: 05/07/2002



        The test (see below) shows that the SourceDataLine.write(byte[] b, int off, int len)
        method of the javax.sound.sampled.SourceDataLine interface causes an unexpected exception
        (Unexpected Signal 11) in native code outside the VM if it is called to write more data
        than can currently be written.

        Such behavior is shown for the one source data line of the one of installed on the system
        mixers when test runs with JDK 1.4.1-beta-b10.

        Please take into account this failure depends on the number of bytes to write.

        The argument of the test is the number of frames defining the number of bytes to exceed
        the currently available to write without blocking number of bytes.

        The default value of this argument is int 2.

        Please, see test log for default value of argument:

        % java -version
        java version "1.4.1-beta"
        Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.1-beta-b10)
        Java HotSpot(TM) Client VM (build 1.4.1-beta-b10, mixed mode)

        % java test

        ==> Test for SourceDataLine.write() method:

        >>> Number of mixers installed on the system = 3

        >>> installedMixer[0] = com.sun.media.sound.HeadspaceMixer@fd13b5

        >> Number of SourceLineInfo supported by installedMixer = 2

        > testSourceLineInfo[0] = interface SourceDataLine supporting 8 audio formats
        > testedSourceLine = com.sun.media.sound.MixerSourceLine@133796

        > open tested SourceLine:
        > OK - line is opened

        > check SourceDataLine.write() to write more data than can currently be written:
        > testedSourceLine.available() = 4
        > frame size = 4
        > number of bytes to write = 12

        An unexpected exception has been detected in native code outside the VM.
        Unexpected Signal : 11 occurred at PC=0xFDFD752C
        Function=SR_resample32_add+0x1E4
        Library=/export/ld55/java/dest/jdk1.4.1-b10/solaris-sparc/jre/lib/sparc/libjsound.so

        Current Java thread:
        at com.sun.media.sound.MixerThread.runNative(Native Method)
        at com.sun.media.sound.MixerThread.run(MixerThread.java:314)

        Dynamic libraries:
        0x10000 /export/ld25/java/dest/jdk1.4.1/solaris-sparc/bin/java
        0xff350000 /usr/lib/libthread.so.1
        0xff390000 /usr/lib/libdl.so.1
        0xff200000 /usr/lib/libc.so.1
        0xff330000 /usr/platform/SUNW,Ultra-1/lib/libc_psr.so.1
        0xfe000000 /export/ld55/java/dest/jdk1.4.1-b10/solaris-sparc/jre/lib/sparc/client/libjvm.so
        0xff2d0000 /usr/lib/libCrun.so.1
        0xff1d0000 /usr/lib/libsocket.so.1
        0xff100000 /usr/lib/libnsl.so.1
        0xff0d0000 /usr/lib/libm.so.1
        0xff300000 /usr/lib/libw.so.1
        0xff0b0000 /usr/lib/libmp.so.2
        0xff070000
        /export/ld55/java/dest/jdk1.4.1-b10/solaris-sparc/jre/lib/sparc/native_threads/libhpi.so
        0xff030000 /export/ld55/java/dest/jdk1.4.1-b10/solaris-sparc/jre/lib/sparc/libverify.so
        0xfe7c0000 /export/ld55/java/dest/jdk1.4.1-b10/solaris-sparc/jre/lib/sparc/libjava.so
        0xfe7a0000 /export/ld55/java/dest/jdk1.4.1-b10/solaris-sparc/jre/lib/sparc/libzip.so
        0xfe4e0000 /usr/lib/locale/ru_RU.KOI8-R/ru_RU.KOI8-R.so.2
        0xfdfa0000 /export/ld55/java/dest/jdk1.4.1-b10/solaris-sparc/jre/lib/sparc/libjsound.so

        Local Time = Wed May 8 10:30:11 2002
        Elapsed Time = 11
        #
        # The exception above was detected in native code outside the VM
        #
        # Java VM: Java HotSpot(TM) Client VM (1.4.1-beta-b10 mixed mode)
        #
        # An error report file has been saved as hs_err_pid2583.log.
        # Please refer to the file for further information.
        #
        Abort
         

        Please, see test log for int 1 value of argument:

        % java test 1

        ==> Test for SourceDataLine.write() method:

        >>> Number of mixers installed on the system = 3

        >>> installedMixer[0] = com.sun.media.sound.HeadspaceMixer@fd13b5

        >> Number of SourceLineInfo supported by installedMixer = 2

        > testSourceLineInfo[0] = interface SourceDataLine supporting 8 audio formats
        > testedSourceLine = com.sun.media.sound.MixerSourceLine@133796

        > open tested SourceLine:
        > OK - line is opened

        > check SourceDataLine.write() to write more data than can currently be written:
        > testedSourceLine.available() = 4
        > frame size = 4
        > number of bytes to write = 8
        > OK - number of written bytes = 8

        > testSourceLineInfo[1] = interface Clip supporting 8 audio formats, and buffers of 0 to 4194304 bytes
        > testedSourceLine = com.sun.media.sound.MixerClip@1fdc96c
        > testSourceLine is not SourceDataLine

        >>> installedMixer[1] = com.sun.media.sound.SimpleInputDevice@b2fd8f

        >> Number of SourceLineInfo supported by installedMixer = 0

        >>> installedMixer[2] = com.sun.media.sound.SimpleOutputDevice@124bbbf

        >> Number of SourceLineInfo supported by installedMixer = 1

        > testSourceLineInfo[0] = interface SourceDataLine supporting 24 audio formats
        > testedSourceLine = com.sun.media.sound.SimpleOutputDevice$OutputDeviceDataLine@1e0bc08

        > open tested SourceLine:
        > Line is not available due to security restrictions:
        java.lang.SecurityException: Permission to read data from the output device not granted.
        at
        com.sun.media.sound.SimpleOutputDevice$OutputDeviceDataLine.implOpen(SimpleOutputDevice.java:486)
        at com.sun.media.sound.AbstractDataLine.open(AbstractDataLine.java:85)
        at com.sun.media.sound.AbstractDataLine.open(AbstractDataLine.java:113)
        at test.run(test.java:133)
        at test.main(test.java:13)

        ==> test PASSED!


         
        The test source:
        ------------------------------- test.java --------------------------------
        // File: %Z%%M% %I% %E%
        // Copyright %G% Sun Microsystems, Inc. All Rights Reserved

        import javax.sound.sampled.*;

        public class test {

            static final int STATUS_PASSED = 0;
            static final int STATUS_FAILED = 2;
            static final int STATUS_TEMP = 95;
            
            public static void main(String argv[]) {
                int testExitStatus = run(argv, System.out) + STATUS_TEMP;
                System.exit(testExitStatus);
            }

            public static int run(String argv[], java.io.PrintStream out) {
                int testResult = STATUS_PASSED;
            
                int framesNumberToExceed = 2;
                if ( argv.length > 0 ) {
                    try {
                        framesNumberToExceed = Integer.parseInt(argv[0]);
                    }
                    catch (NumberFormatException e) {
                    }
                }

                out.println
                    ("\n==> Test for SourceDataLine.write() method:");

                Mixer.Info[] installedMixersInfo = AudioSystem.getMixerInfo();
                
                if ( installedMixersInfo == null ) {
                    out.println("## AudioSystem.getMixerInfo() returned unexpected result:");
                    out.println("# expected: an array of Mixer.Info objects (may be array of length 0);");
                    out.println("# produced: null;");
                    return STATUS_FAILED;
                }

                if ( installedMixersInfo.length == 0 ) {
                    // there are no mixers installed on the system -
                    // so this testcase can not be tested
                    out.println("\n>>> There are no mixers installed on the system!");
                    return STATUS_PASSED;
                }

                out.println("\n>>> Number of mixers installed on the system = "
                    + installedMixersInfo.length);
                Mixer installedMixer = null;
                for (int i=0; i < installedMixersInfo.length; i++) {
                    try {
                        installedMixer = AudioSystem.getMixer(installedMixersInfo[i]);
                    } catch (SecurityException securityException) {
                        // installed Mixer is unavailable because of security restrictions
                        out.println("\n>>> installedMixer[" + i
                            + "] is unavailable because of security restrictions");
                        continue;
                    } catch (Throwable thrown) {
                        out.println("\n## installedMixer[" + i + "] is unavailable because of");
                        out.println("# AudioSystem.getMixer() threw unexpected exception:");
                        thrown.printStackTrace(out);
                        testResult = STATUS_FAILED;
                        continue;
                    }

                    out.println("\n>>> installedMixer["+i+"] = " + installedMixer);
                    try {
                        installedMixer.open();
                    } catch (LineUnavailableException lineUnavailableException) {
                        // installedMixer is not available due to resource restrictions
                        out.println(">> installedMixer[" + i
                            + "] is not opened because of resource restrictions");
                        continue;
                    } catch (SecurityException securityException) {
                        // installedMixer is not available due to security restrictions
                        out.println(">> installedMixer[" + i
                            + "] is not opened because of security restrictions");
                        continue;
                    } catch (Throwable thrown) {
                        out.println("## installedMixer.open() throws unexpected exception:");
                        thrown.printStackTrace(out);
                        testResult = STATUS_FAILED;
                        continue;
                    }
                    Line.Info supportedSourceLineInfo[] = null;
                    try {
                        supportedSourceLineInfo = installedMixer.getSourceLineInfo();
                    } catch (Throwable thrown) {
                        out.println("## installedMixer.getSourceLineInfo() throws "
                            + "unexpected exception:");
                        thrown.printStackTrace(out);
                        testResult = STATUS_FAILED;
                        installedMixer.close();
                        continue;
                    }
                    if ( supportedSourceLineInfo == null ) {
                        out.println("## installedMixer.getSourceLineInfo() returned null array");
                        out.println("# Mixer = " + installedMixer);
                        testResult = STATUS_FAILED;
                        installedMixer.close();
                        continue;
                    }
                    out.println("\n>> Number of SourceLineInfo supported by installedMixer = "
                        + supportedSourceLineInfo.length);

                    for (int j=0; j < supportedSourceLineInfo.length; j++) {
                        Line.Info testSourceLineInfo = supportedSourceLineInfo[j];
                        
                        out.println("\n> testSourceLineInfo["+j+"] = " + testSourceLineInfo);
                        Line testSourceLine = null;
                        try {
                            testSourceLine = installedMixer.getLine(testSourceLineInfo);
                        } catch (LineUnavailableException lineUnavailableException) {
                            // line is not available due to resource restrictions
                            out.println("> Line for this SourceLine Info is not available "
                                + "due to resource restrictions");
                            continue;
                        } catch (SecurityException securityException) {
                            // line is not available due to security restrictions
                            out.println("> Line for this SourceLine Info is not available "
                                + "due to security restrictions");
                            continue;
                        } catch (Throwable thrown) {
                            out.println("## installedMixer.getLine(testSourceLineInfo) throws "
                                + "unexpected Exception:");
                            thrown.printStackTrace(out);
                            testResult = STATUS_FAILED;
                            continue;
                        }

                        out.println("> testedSourceLine = " + testSourceLine);
                        if ( ! (testSourceLine instanceof SourceDataLine) ) {
                            out.println("> testSourceLine is not SourceDataLine");
                            continue;
                        }

                        SourceDataLine testedSourceLine = (SourceDataLine)testSourceLine;
                        AudioFormat lineAudioFormat = testedSourceLine.getFormat();

                        out.println("\n> open tested SourceLine:");
                        try {
                            testedSourceLine.open(lineAudioFormat);
                            out.println("> OK - line is opened");
                        } catch (LineUnavailableException lineUnavailableException) {
                            out.println("> Line is not available due to resource restrictions:");
                            lineUnavailableException.printStackTrace(out);
                            continue;
                        } catch (SecurityException securityException) {
                            out.println("> Line is not available due to security restrictions:");
                            securityException.printStackTrace(out);
                            continue;
                        } catch (Throwable thrown) {
                            out.println("## SourceDataLine.open(AudioFormat format) failed:");
                            out.println("# Unexpected Exception is thrown");
                            out.println("# Mixer = " + installedMixer);
                            out.println("# SourceDataLine = " + testedSourceLine);
                            thrown.printStackTrace(out);
                            testResult = STATUS_FAILED;
                            continue;
                        }
                        
                        testedSourceLine.start();

                        int frameSize = 1;
                        if ( lineAudioFormat.getFrameSize() != AudioSystem.NOT_SPECIFIED ) {
                            frameSize = lineAudioFormat.getFrameSize();
                        } else {
                            if ( lineAudioFormat.getSampleSizeInBits() != AudioSystem.NOT_SPECIFIED ) {
                                frameSize = lineAudioFormat.getSampleSizeInBits()/8;
                                if ( lineAudioFormat.getSampleSizeInBits()%8 != 0 ) {
                                    frameSize++;
                                }
                            }
                        }
                        int bufferSizeToWrite = testedSourceLine.available()
                            + (frameSize * framesNumberToExceed);
                        byte[] dataToWrite = new byte[bufferSizeToWrite];
                        for (int k=0; k < bufferSizeToWrite; k++) {
                            dataToWrite[k] = (byte)1;
                        }
                        int offsetToWrite = 0;

                        out.println("\n> check SourceDataLine.write() to write more data "
                            + "than can currently be written:");

                        out.println("> testedSourceLine.available() = " + testedSourceLine.available());
                        out.println("> frame size = " + frameSize);
                        out.println("> number of bytes to write = " + bufferSizeToWrite);
                        int writtenBytes = -1;
                        try {
                            writtenBytes =
                                testedSourceLine.write(dataToWrite, offsetToWrite, bufferSizeToWrite);
                            out.println("> OK - number of written bytes = " + writtenBytes);
                        } catch (Throwable thrown) {
                            out.println("## SourceDataLine.write(byte[] b, int off, int len) failed:");
                            out.println("# Unexpected Exception is thrown");
                            thrown.printStackTrace(out);
                            testResult = STATUS_FAILED;
                        }

                        testedSourceLine.close();

                    } // for (int j=0; j < supportedSourceLineInfo.length; j++)
                    installedMixer.close();

                } // for (int i=0; i < installedMixersInfo.length; i++)

                if ( testResult == STATUS_FAILED ) {
                    out.println("\n==> test FAILED!");
                } else

          Attachments

            Issue Links

              Activity

                People

                • Assignee:
                  fbomerssunw Florian Bomers (Inactive)
                  Reporter:
                  bondsunw Bond Bond (Inactive)
                • Votes:
                  0 Vote for this issue
                  Watchers:
                  0 Start watching this issue

                  Dates

                  • Created:
                    Updated:
                    Resolved:
                    Imported:
                    Indexed: