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

HTML ParserDelegator has race condition in class init

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: P3 P3
    • 1.4.0
    • 1.2.2
    • client-libs
    • beta
    • generic
    • generic



      Name: krT82822 Date: 03/07/2000


      (please see Comments section)

      java version "1.2.2"
      Classic VM (build JDK-1.2.2-W, native threads, symcjit)

      This is a logic bug. I can reproduce a failure reliably within a fairly large
      program, but have not been able to come up with a small program that does it,
      sorry. But this is an obvious logic error, so you'll be able to see it just by
      looking at the source code, like I did.

        The "dtd" static member of the class ParserDelegator (from package
      javax.swing.text.html.parser) is assigned in a non-thread-safe way, during this
      class's constructor. The logic error is: what happens when two threads both
      create ParserDelegators nearly simultaneously? The answer, as far as I have
      been able to tell from my situation, is that sometimes a parser is given a
      not-yet-initialized DTD object to work with. At least: this is clearly possible
      from reading the code, and it is consistent with the behavior I am seeing, which
      is that a parser is making otherwise inexplicable mistakes in its parsing.

        The simplest way for you to rewrite this code is to initialize the "dtd" field
      in a static initializer. Let the JVM take care of guaranteeing a single
      initialization of each class.
      (Review ID: 100666)
      ======================================================================

            svioletsunw Scott Violet (Inactive)
            kryansunw Kevin Ryan (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: