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

Debug Agent might miss some loaded classes during startup

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Unresolved
    • Icon: P5 P5
    • tbd
    • 19
    • core-svc

      At startup the Debug Agent calls JVMTI GetLoadedClasses() to get all the currently loaded classes. It then calls SetTag on each class so when the class is unload it will get an ObjectFree event. After processing the classes returned by GetLoadedClasses(), it sets up a JVMTI ClassPrepare event callback so it can also call SetTag on any additional classes that are loaded. The problem is there might be some classes loaded between the GetLoadedClasses() call and the setting up of the ClassPrepare event callback. The debug agent will never tag these classes, so it will never be notified when they are unloaded. The end result in a missed CLASS_UNLOAD event for the debugger.

      In order to fix this issue, the debug agent has to reverse the order and setup the ClassPrepare event callback before calling GetLoadedClasses(). GetLoadedClasses() is called as part of classTrack_initialize(), which is called from the initialize() function in debugInit.c. The ClassPrepare event callback is setup in eventHandler_initialize(), which is also called from initialize(), just a little bit after classTrack_initialize(). I don't think there would be any issue with moving the classTrack_initialize() to be just after eventHandler_initialize(), but will have to try it and see.

      Note there have been no reported test failures do to this bug. It is just something I observed while looking into another issue.

            Unassigned Unassigned
            cjplummer Chris Plummer
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated: