RE: 回复: 回复: JDK-8257039: Memory allocated by GenericTaskQueue::_array_allocator may be double freed(Internet mail)

Hohensee, Paul hohensee at amazon.com
Wed Apr 28 14:27:37 UTC 2021


Issue tagged on your behalf.

Paul

-----Original Message-----
From: "wattsun(孙宇)" <wattsun at tencent.com>
Date: Tuesday, April 27, 2021 at 6:49 PM
To: "Hohensee, Paul" <hohensee at amazon.com>, "jdk8u-dev at openjdk.java.net" <jdk8u-dev at openjdk.java.net>
Subject: 回复: 回复: JDK-8257039: Memory allocated by GenericTaskQueue::_array_allocator may be double freed(Internet mail)

Hi,Paul
    Yes, I need a sponsor, Thank you very much.

Yours
watt

-----邮件原件-----
发件人: Hohensee, Paul <hohensee at amazon.com>
发送时间: 2021年4月28日 1:08
收件人: wattsun(孙宇) <wattsun at tencent.com>; jdk8u-dev at openjdk.java.net
主题: Re: 回复: JDK-8257039: Memory allocated by GenericTaskQueue::_array_allocator may be double freed(Internet mail)

Do you need a sponsor?

-----Original Message-----
From: jdk8u-dev <jdk8u-dev-retn at openjdk.java.net> on behalf of "Hohensee, Paul" <hohensee at amazon.com>
Date: Thursday, April 15, 2021 at 12:06 PM
To: "wattsun(孙宇)" <wattsun at tencent.com>, "jdk8u-dev at openjdk.java.net" <jdk8u-dev at openjdk.java.net>
Subject: RE: 回复: JDK-8257039: Memory allocated by GenericTaskQueue::_array_allocator may be double freed(Internet mail)

Lgtm.

-----Original Message-----
From: "wattsun(孙宇)" <wattsun at tencent.com>
Date: Thursday, April 15, 2021 at 5:37 AM
To: "Hohensee, Paul" <hohensee at amazon.com>, "jdk8u-dev at openjdk.java.net" <jdk8u-dev at openjdk.java.net>
Subject: 回复: JDK-8257039: Memory allocated by GenericTaskQueue::_array_allocator may be double freed(Internet mail)

Thanks for your reply, Paul.
make sense, both methods can eliminate the risk of double-free , and free the memory in ~ArrayAllocator is more reasonable. Update the patch:

diff -r 91b61f678a19 src/share/vm/utilities/taskqueue.hpp
--- a/src/share/vm/utilities/taskqueue.hpp      Sat Mar 27 19:01:26 2021 +0000
+++ b/src/share/vm/utilities/taskqueue.hpp      Thu Apr 15 20:32:02 2021 +0800
@@ -430,9 +430,7 @@
 }

 template<class E, MEMFLAGS F, unsigned int N> -GenericTaskQueue<E, F, N>::~GenericTaskQueue() {
-  FREE_C_HEAP_ARRAY(E, _elems, F);
-}
+GenericTaskQueue<E, F, N>::~GenericTaskQueue() {}

 // OverflowTaskQueue is a TaskQueue that also includes an overflow stack for  // elements that do not fit in the TaskQueue.


Thanks
wattsun


-----邮件原件-----
发件人: Hohensee, Paul <hohensee at amazon.com>
发送时间: 2021年4月15日 5:16
收件人: wattsun(孙宇) <wattsun at tencent.com>; jdk8u-dev at openjdk.java.net
主题: RE: JDK-8257039: Memory allocated by GenericTaskQueue::_array_allocator may be double freed(Internet mail)

If I read this correctly, you're disabling ArrayAllocator::free() to accommodate ~GenericTaskQueue, which latter explicitly frees the queue element array. This seems backwards to me because ~GenericTaskQueue currently reachs into the implementation of ArrayAllocator, violating encapsulation. Your original patch, which eliminated the explicit free in ~GenericTaskQueue, removed that reaching and left it up to ~ArrayAllocator to handle it, which is what I'd prefer.

Thanks,
Paul

-----Original Message-----
From: jdk8u-dev <jdk8u-dev-retn at openjdk.java.net> on behalf of "wattsun(孙宇)" <wattsun at tencent.com>
Date: Wednesday, December 23, 2020 at 2:06 AM
To: "jdk8u-dev at openjdk.java.net" <jdk8u-dev at openjdk.java.net>
Subject: JDK-8257039: Memory allocated by GenericTaskQueue::_array_allocator may be double freed

Dear All,

     may I hava this small bug fix to review?

     Bug: https://bugs.openjdk.java.net/browse/JDK-8257039





the diff:



diff -r 83661fdee9f0 src/share/vm/utilities/taskqueue.hpp

--- a/src/share/vm/utilities/taskqueue.hpp      Wed Nov 18 06:55:35 2020 +0000

+++ b/src/share/vm/utilities/taskqueue.hpp      Wed Nov 25 18:10:28 2020 +0800

@@ -314,7 +314,7 @@

 };



 template<class E, MEMFLAGS F, unsigned int N>

-GenericTaskQueue<E, F, N>::GenericTaskQueue() {

+GenericTaskQueue<E, F, N>::GenericTaskQueue() : _array_allocator(false)
+{

   assert(sizeof(Age) == sizeof(size_t), "Depends on this.");

 }





Thanks!

watt







More information about the jdk8u-dev mailing list