Re: RFR: 8260366: ExtendedSocketOptions can deadlock in some circumstances [v5]

2021-02-26 Thread Jaikiran Pai
On Wed, 24 Feb 2021 15:41:53 GMT, Daniel Fuchs wrote: >> Jaikiran Pai has updated the pull request incrementally with one additional >> commit since the last revision: >> >> Reduce the scope of the synchronized block in getInstance() and enhance >> the testcase to be more robust in catching

Re: RFR: 8260366: ExtendedSocketOptions can deadlock in some circumstances [v5]

2021-02-24 Thread Daniel Fuchs
On Fri, 19 Feb 2021 04:29:55 GMT, Jaikiran Pai wrote: >> Can I please get a review for this change which proposes to fix the issue >> reported in https://bugs.openjdk.java.net/browse/JDK-8260366? >> >> The issue relates to the concurrent classloading of >> `sun.net.ext.ExtendedSocketOptions` a

Re: RFR: 8260366: ExtendedSocketOptions can deadlock in some circumstances [v4]

2021-02-24 Thread Jaikiran Pai
On Fri, 19 Feb 2021 05:15:24 GMT, Vyom Mani Tewari wrote: >> After thinking a bit more about this issue and the patch I had proposed, I >> realized what I did wrong in this patch. The `synchronized` block in the >> `sun.net.ext.ExtendedSocketOptions#getInstance()` was scoped one statement >>

Re: RFR: 8260366: ExtendedSocketOptions can deadlock in some circumstances [v4]

2021-02-18 Thread Vyom Mani Tewari
On Fri, 19 Feb 2021 04:26:26 GMT, Jaikiran Pai wrote: > After thinking a bit more about this issue and the patch I had proposed, I > realized what I did wrong in this patch. The `synchronized` block in the > `sun.net.ext.ExtendedSocketOptions#getInstance()` was scoped one statement > too many.

Re: RFR: 8260366: ExtendedSocketOptions can deadlock in some circumstances [v4]

2021-02-18 Thread Jaikiran Pai
On Thu, 18 Feb 2021 13:06:44 GMT, Jaikiran Pai wrote: >> Changes requested by dfuchs (Reviewer). > > I'm closing this for now, for the reason stated here > https://github.com/openjdk/jdk/pull/2601#discussion_r578400669. After thinking a bit more about this issue and the patch I had proposed, I

Re: RFR: 8260366: ExtendedSocketOptions can deadlock in some circumstances [v5]

2021-02-18 Thread Jaikiran Pai
> Can I please get a review for this change which proposes to fix the issue > reported in https://bugs.openjdk.java.net/browse/JDK-8260366? > > The issue relates to the concurrent classloading of > `sun.net.ext.ExtendedSocketOptions` and `jdk.net.ExtendedSocketOptions` > leading to a deadlock.

Re: RFR: 8260366: ExtendedSocketOptions can deadlock in some circumstances [v4]

2021-02-18 Thread Daniel Fuchs
On Thu, 18 Feb 2021 13:31:07 GMT, Jaikiran Pai wrote: >> Hi Jaikiran, >> >> I tested with my suggested change and i did not see any deadlock at my local >> Linux environment. I just ran test in loop and it worked as expected. >> >> Thanks, >> Vyom > > Hello Vyom, > > The trick is to change t

Re: RFR: 8260366: ExtendedSocketOptions can deadlock in some circumstances [v4]

2021-02-18 Thread Jaikiran Pai
On Thu, 18 Feb 2021 13:23:37 GMT, Vyom Mani Tewari wrote: >> Hello Daniel, I had thought about it in my previous commit. But this won't >> work, since in the normal case where the `ClassNotFoundException` doesn't >> get thrown, the `instance` is actually set in the `register` method which >>

Re: RFR: 8260366: ExtendedSocketOptions can deadlock in some circumstances [v4]

2021-02-18 Thread Vyom Mani Tewari
On Thu, 18 Feb 2021 13:05:48 GMT, Jaikiran Pai wrote: >> src/java.base/share/classes/sun/net/ext/ExtendedSocketOptions.java line 189: >> >>> 187: } >>> 188: } >>> 189: return instance; >> >> I'd suggest changing these two lines as well: >> >> // the

Re: RFR: 8260366: ExtendedSocketOptions can deadlock in some circumstances [v4]

2021-02-18 Thread Jaikiran Pai
On Thu, 18 Feb 2021 10:54:36 GMT, Daniel Fuchs wrote: >> Jaikiran Pai has updated the pull request incrementally with one additional >> commit since the last revision: >> >> reduce volatile reads > > Changes requested by dfuchs (Reviewer). I'm closing this for now, for the reason stated here

Re: RFR: 8260366: ExtendedSocketOptions can deadlock in some circumstances [v4]

2021-02-18 Thread Daniel Fuchs
On Thu, 18 Feb 2021 10:44:03 GMT, Jaikiran Pai wrote: >> Can I please get a review for this change which proposes to fix the issue >> reported in https://bugs.openjdk.java.net/browse/JDK-8260366? >> >> The issue relates to the concurrent classloading of >> `sun.net.ext.ExtendedSocketOptions` a

Re: RFR: 8260366: ExtendedSocketOptions can deadlock in some circumstances [v2]

2021-02-18 Thread Jaikiran Pai
On Thu, 18 Feb 2021 09:57:19 GMT, Jaikiran Pai wrote: >> Let me be more clear: I think that it's enough to have only 2 `volatile` >> field reads _in worst case_. We can use local variable to avoid more than >> needed reads. >> Current code can perform read 4 times _in worst case_: twice outside

Re: RFR: 8260366: ExtendedSocketOptions can deadlock in some circumstances [v4]

2021-02-18 Thread Jaikiran Pai
> Can I please get a review for this change which proposes to fix the issue > reported in https://bugs.openjdk.java.net/browse/JDK-8260366? > > The issue relates to the concurrent classloading of > `sun.net.ext.ExtendedSocketOptions` and `jdk.net.ExtendedSocketOptions` > leading to a deadlock.

Re: RFR: 8260366: ExtendedSocketOptions can deadlock in some circumstances [v2]

2021-02-18 Thread Jaikiran Pai
On Thu, 18 Feb 2021 07:59:45 GMT, Andrey Turbanov wrote: >> Hello @turbanoff, the double read is necessary to correctly avoid any race >> conditions and is a typical strategy used in cases like these. I am not >> aware of any other alternate more performant strategy, for code like this. > > Le

Re: RFR: 8260366: ExtendedSocketOptions can deadlock in some circumstances [v3]

2021-02-18 Thread Vyom Mani Tewari
On Thu, 18 Feb 2021 05:01:41 GMT, Jaikiran Pai wrote: >>> > Changes looks OK to me, any specific reason for removing "final" >>> > specifier from "getInstance" & "register" methods ?. >>> >>> Hello Vyom, thank you for the review. Since those two methods are `static`, >>> the `final` was redund

Re: RFR: 8260366: ExtendedSocketOptions can deadlock in some circumstances [v2]

2021-02-18 Thread Andrey Turbanov
On Thu, 18 Feb 2021 07:35:51 GMT, Jaikiran Pai wrote: >> Yes. Once here and once inside `synchronized` block. >> Reading `volatile` fields cost _something_ on some architectures, so I think >> we could optimize it a bit. > > Hello @turbanoff, the double read is necessary to correctly avoid any r

Re: RFR: 8260366: ExtendedSocketOptions can deadlock in some circumstances [v2]

2021-02-17 Thread Jaikiran Pai
On Thu, 18 Feb 2021 07:03:07 GMT, Andrey Turbanov wrote: >> Hello @turbanoff, do you mean why read it twice - once here and once inside >> the `synchronized` block? > > Yes. Once here and once inside `synchronized` block. > Reading `volatile` fields cost _something_ on some architectures, so I

Re: RFR: 8260366: ExtendedSocketOptions can deadlock in some circumstances [v2]

2021-02-17 Thread Andrey Turbanov
On Thu, 18 Feb 2021 01:08:30 GMT, Jaikiran Pai wrote: >> src/java.base/share/classes/sun/net/ext/ExtendedSocketOptions.java line 171: >> >>> 169: >>> 170: public static ExtendedSocketOptions getInstance() { >>> 171: if (instance != null) { >> >> May be it's worth to avoid reading `

Re: RFR: 8260366: ExtendedSocketOptions can deadlock in some circumstances [v3]

2021-02-17 Thread Jaikiran Pai
On Thu, 18 Feb 2021 04:31:56 GMT, Vyom Mani Tewari wrote: > What about improving the test little bit, your test wants to load both > classes at the same time. Please have a look on modified test. Hello Vyom, I think that's a good suggestion to use a latch for deciding when to trigger the clas

Re: RFR: 8260366: ExtendedSocketOptions can deadlock in some circumstances [v3]

2021-02-17 Thread Jaikiran Pai
> Can I please get a review for this change which proposes to fix the issue > reported in https://bugs.openjdk.java.net/browse/JDK-8260366? > > The issue relates to the concurrent classloading of > `sun.net.ext.ExtendedSocketOptions` and `jdk.net.ExtendedSocketOptions` > leading to a deadlock.

Re: RFR: 8260366: ExtendedSocketOptions can deadlock in some circumstances [v2]

2021-02-17 Thread Vyom Mani Tewari
On Thu, 18 Feb 2021 01:06:50 GMT, Jaikiran Pai wrote: > > Changes looks OK to me, any specific reason for removing "final" specifier > > from "getInstance" & "register" methods ?. > > Hello Vyom, thank you for the review. Since those two methods are `static`, > the `final` was redundant on the

Re: RFR: 8260366: ExtendedSocketOptions can deadlock in some circumstances [v2]

2021-02-17 Thread Jaikiran Pai
On Wed, 17 Feb 2021 20:01:17 GMT, Andrey Turbanov wrote: >> Jaikiran Pai has updated the pull request incrementally with three >> additional commits since the last revision: >> >> - Incorporate the review suggestion to run the test multiple times to >> improve the chances of reproducing any

Re: RFR: 8260366: ExtendedSocketOptions can deadlock in some circumstances [v2]

2021-02-17 Thread Jaikiran Pai
On Wed, 17 Feb 2021 16:47:51 GMT, Vyom Mani Tewari wrote: > Changes looks OK to me, any specific reason for removing "final" specifier > from "getInstance" & "register" methods ?. Hello Vyom, thank you for the review. Since those two methods are `static`, the `final` was redundant on them and

Re: RFR: 8260366: ExtendedSocketOptions can deadlock in some circumstances [v2]

2021-02-17 Thread Andrey Turbanov
On Wed, 17 Feb 2021 13:42:57 GMT, Jaikiran Pai wrote: >> Can I please get a review for this change which proposes to fix the issue >> reported in https://bugs.openjdk.java.net/browse/JDK-8260366? >> >> The issue relates to the concurrent classloading of >> `sun.net.ext.ExtendedSocketOptions` a

Re: RFR: 8260366: ExtendedSocketOptions can deadlock in some circumstances [v2]

2021-02-17 Thread Vyom Mani Tewari
On Wed, 17 Feb 2021 13:36:18 GMT, Jaikiran Pai wrote: >> Hi Jaikiran, >> >> Thanks for taking a go at this one. >> >> At a glance - the proposed fix seems reasonable to me. It would be good to >> have another pair of eyes (and analysis) on this though. Some issues with >> the test. > > Hello

Re: RFR: 8260366: ExtendedSocketOptions can deadlock in some circumstances [v2]

2021-02-17 Thread Jaikiran Pai
> Can I please get a review for this change which proposes to fix the issue > reported in https://bugs.openjdk.java.net/browse/JDK-8260366? > > The issue relates to the concurrent classloading of > `sun.net.ext.ExtendedSocketOptions` and `jdk.net.ExtendedSocketOptions` > leading to a deadlock.

Re: RFR: 8260366: ExtendedSocketOptions can deadlock in some circumstances [v2]

2021-02-17 Thread Jaikiran Pai
On Wed, 17 Feb 2021 13:37:19 GMT, Jaikiran Pai wrote: >> Since the test should be fast, I'd also advise to stick several identical >> @run lines (maybe e.g. 5 of them) to increase the probability of the >> deadlock to happen... > >> Since the test should be fast, I'd also advise to stick severa

Re: RFR: 8260366: ExtendedSocketOptions can deadlock in some circumstances [v2]

2021-02-17 Thread Jaikiran Pai
On Wed, 17 Feb 2021 13:11:23 GMT, Daniel Fuchs wrote: >> Jaikiran Pai has updated the pull request incrementally with three >> additional commits since the last revision: >> >> - Incorporate the review suggestion to run the test multiple times to >> improve the chances of reproducing any pote

Re: RFR: 8260366: ExtendedSocketOptions can deadlock in some circumstances [v2]

2021-02-17 Thread Jaikiran Pai
On Wed, 17 Feb 2021 13:09:27 GMT, Daniel Fuchs wrote: > Since the test should be fast, I'd also advise to stick several identical > @run lines (maybe e.g. 5 of them) to increase the probability of the deadlock > to happen... Done. The PR has been updated to run this test multiple times now. -

Re: RFR: 8260366: ExtendedSocketOptions can deadlock in some circumstances

2021-02-17 Thread Daniel Fuchs
On Wed, 17 Feb 2021 13:05:03 GMT, Daniel Fuchs wrote: >> Can I please get a review for this change which proposes to fix the issue >> reported in https://bugs.openjdk.java.net/browse/JDK-8260366? >> >> The issue relates to the concurrent classloading of >> `sun.net.ext.ExtendedSocketOptions` a

Re: RFR: 8260366: ExtendedSocketOptions can deadlock in some circumstances

2021-02-17 Thread Daniel Fuchs
On Wed, 17 Feb 2021 07:20:27 GMT, Jaikiran Pai wrote: > Can I please get a review for this change which proposes to fix the issue > reported in https://bugs.openjdk.java.net/browse/JDK-8260366? > > The issue relates to the concurrent classloading of > `sun.net.ext.ExtendedSocketOptions` and `j

RFR: 8260366: ExtendedSocketOptions can deadlock in some circumstances

2021-02-16 Thread Jaikiran Pai
Can I please get a review for this change which proposes to fix the issue reported in https://bugs.openjdk.java.net/browse/JDK-8260366? The issue relates to the concurrent classloading of `sun.net.ext.ExtendedSocketOptions` and `jdk.net.ExtendedSocketOptions` leading to a deadlock. This is beca