[10] RFR for JDK-8170299: Debugger does not stop inside the low memory notifications code

Shafi Ahmad shafi.s.ahmad at oracle.com
Mon Sep 4 10:11:00 UTC 2017


Hi,

 

Please review the fix for 'JDK-8170299: Debugger does not stop inside the low memory notifications code' to jdk10.

 

With the current implementation 'debugger does not stop inside the low memory *notifications* code' 

This is expected as the notification code is getting executed with the service thread, which is a hidden thread.

 

jdk10-dev-new$ jdb -Xmx32m MemoryWarningSystem

Initializing jdb ...

> stop at MemoryWarningSystem$1:25

Deferring breakpoint MemoryWarningSystem$1:25.

It will be set after the class is loaded.

> run

run MemoryWarningSystem

Set uncaught java.lang.Throwable

Set deferred uncaught java.lang.Throwable

> 

. . .

> quit

 

Breakpoint not hit.

 

With the attached webrev, jdb stop  at breakpoint inside notification code.

 

jdk10-dev-new$ jdb -Xmx64m MemoryWarningSystem

Initializing jdb ...

> stop at MemoryWarningSystem$1:25

Deferring breakpoint MemoryWarningSystem$1:25.

It will be set after the class is loaded.

> run

run MemoryWarningSystem

Set uncaught java.lang.Throwable

Set deferred uncaught java.lang.Throwable

> 

VM Started: Set deferred breakpoint MemoryWarningSystem$1:25

 

Breakpoint hit: "thread=Thread-0", MemoryWarningSystem$1.memoryUsageLow(), line=25 bci=0

25            System.out.println("Memory usage low!!!");

 

Thread-0[1] step

> Memory usage low!!!

 

Step completed: "thread=Thread-0", MemoryWarningSystem$1.memoryUsageLow(), line=26 bci=8

26            double percentageUsed = ((double) usedMemory) / maxMemory;

 

Thread-0[1] where

  [1] MemoryWarningSystem$1.memoryUsageLow (MemoryWarningSystem.java:26)

  [2] MemoryWarningSystem$2.handleNotification (MemoryWarningSystem.java:48)

  [3] javax.management.NotificationBroadcasterSupport.handleNotification (NotificationBroadcasterSupport.java:284)

  [4] javax.management.NotificationBroadcasterSupport$SendNotifJob.run (NotificationBroadcasterSupport.java:361)

  [5] java.lang.Thread.run (Thread.java:844)

Thread-0[1] step

> 

Step completed: "thread=Thread-0", MemoryWarningSystem$1.memoryUsageLow(), line=27 bci=15

27            System.out.println("percentageUsed = " + percentageUsed);

 

Thread-0[1] list

23        mws.addListener(new MemoryWarningSystem.Listener() {

24          public void memoryUsageLow(long usedMemory, long maxMemory) {

25            System.out.println("Memory usage low!!!");

26            double percentageUsed = ((double) usedMemory) / maxMemory;

27 =>         System.out.println("percentageUsed = " + percentageUsed);

28            MemoryWarningSystem.setPercentageUsageThreshold(0.8);

29          }

30        });

31    

32        Collection<Double> numbers = new LinkedList<Double>();

Thread-0[1]

 

In the change, the class 'MemoryImpl' is derived from class 'NotificationBroadcasterSupport' instead of class 'NotificationEmitterSupport' 

NotificationBroadcastSupport takes an Executor, MemoryImpl constructor  call super() with an executor,  a visible thread.

 

The method hasListeners() is referenced  inside MemoryImpl.java and defined in  NotificationEmitterSupport.

This method is not present in  NotificationBroadcasterSupport so I added it to NotificationBroadcasterSupport.

 

Jdk10 bug: https://bugs.openjdk.java.net/browse/JDK-8170299

Webrev link: http://cr.openjdk.java.net/~shshahma/8170299/webrev.01/

 

Testing: jprt -testset core, vm tonga tests nsk.jvmti.testlist, nsk.jdi.testlist, nsk.jdwp.testlist and jtreg tests ./jdk/test/com/sun/jdi/

 

Please let me know if I missed to test some more test suit[s].

 

Thanks to Mandy and Poonam for helping me in fixing this. 

 

Regards,

Shafi
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.openjdk.java.net/pipermail/serviceability-dev/attachments/20170904/8ca0639e/attachment.html>


More information about the serviceability-dev mailing list