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

Concurrency bug in com.sun.media.sound.UlawCodec with tempBuffer

XMLWordPrintable

    • b34
    • x86
    • linux

      FULL PRODUCT VERSION :
      java version "1.5.0_01"
      Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_01-b08)
      Java HotSpot(TM) Server VM (build 1.5.0_01-b08, mixed mode)

      ADDITIONAL OS VERSION INFORMATION :
      Found on SLES 9, kernel 2.6.5-7.139-smp but not OS specific

      EXTRA RELEVANT SYSTEM CONFIGURATION :
      Dual CPU w/ hyperthreading for 4 hardware threads

      A DESCRIPTION OF THE PROBLEM :
      The class com.sun.media.sound.UlawCodec provides conversion between PCM and ULAW audio formats. When a conversion stream is requested it returns a new instance of an inner class (UlawCodecStream). This class references the member tempBuffer in UlawCodec. Only one instance of UlawCodec is loaded per JVM but many conversion streams can be created (via multiple calls to javax.sound.sampled.AudioSystem.getAudioInputStream(AudioFormat, AudioInputStream)). The access to tempBuffer is not protected by any synchronization mechanism. This leads to audio data swapping between multiple streams that are undergoing conversion at the same time. There is really no reason for tempBuffer to reside in UlawCodec. It is very small and should be a member of UlawCodecStream. Moving it there would remove the need for any synchronization.

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      Using SMP hardware start many threads (20+) that read from a PCM wav file, convert to ULAW, and write the results out to a new wav file. Some of the resulting output files will have corrupted sound. With this many threads the problem is always reproducible in a short period of time.

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      There should be no audio corruption in the output files.
      ACTUAL -
      Some output files are corrupt.

      REPRODUCIBILITY :
      This bug can be reproduced always.

      CUSTOMER SUBMITTED WORKAROUND :
      Streams must be converted serially, not in parallel.
      ###@###.### 2005-04-19 16:42:45 GMT

            bino Bino George
            gmanwanisunw Girish Manwani (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: