Date: Thu, 13 Apr 2017 06:28:29 -0400 From: =?UTF-8?B?5byg5rO96bmP?= <redraiment@gmail.com> To: Jung-uk Kim <jkim@freebsd.org>, Eric van Gyzen <eric@vangyzen.net>, Daniel Eischen <deischen@freebsd.org> Cc: Konstantin Belousov <kostikbel@gmail.com>, freebsd-java@freebsd.org Subject: Re: OpenJDK8 Thread.sleep will deadlock while turn down system date time. Message-ID: <CAPRzLQSGBLzBqR1nWEt9DZ_eQUbcXQ%2BASyFmoWdZgEHXRPUk6Q@mail.gmail.com> In-Reply-To: <2349193f-568b-37f1-dcc5-7e0002046325@FreeBSD.org> References: <CAPRzLQSOfySJWqN8CoLNchRs_JgHkeQz57ZNB9E__Meip3zmOQ@mail.gmail.com> <20170408070340.GD1788@kib.kiev.ua> <a48038a5-3f12-f7ef-9e94-6c33b4672c02@vangyzen.net> <Pine.GSO.4.64.1704111923550.21979@sea.ntplx.net> <2349193f-568b-37f1-dcc5-7e0002046325@FreeBSD.org>
next in thread | previous in thread | raw e-mail | index | archive | help
I apply the patch and reinstall from ports, it works well for me now. Thanks Kim! thanks everyone! 发件人: Jung-uk Kim <jkim@freebsd.org> <jkim@freebsd.org> 回复: Jung-uk Kim <jkim@freebsd.org> <jkim@freebsd.org> 日期: 2017年4月13日 at 上午1:17:41 至: Daniel Eischen <deischen@freebsd.org> <deischen@freebsd.org>, Eric van Gyzen <eric@vangyzen.net> <eric@vangyzen.net> 抄送: redraiment@gmail.com <redraiment@gmail.com> <redraiment@gmail.com>, Konstantin Belousov <kostikbel@gmail.com> <kostikbel@gmail.com>, freebsd-java@freebsd.org <freebsd-java@freebsd.org> <freebsd-java@freebsd.org> 主题: Re: OpenJDK8 Thread.sleep will deadlock while turn down system date time. On 04/11/2017 19:55, Daniel Eischen wrote: > On Tue, 11 Apr 2017, Eric van Gyzen wrote: > >> On 4/8/17 2:03 AM, Konstantin Belousov wrote: > [ ... ] >>> >>> If JVM sets timeouts using absolute times than it might be fixed in >>> latest >>> HEAD and stable/11. >> >> The JVM uses pthread_cond_timedwait() to implement Thread.sleep(), so >> it always uses absolute times. Furthermore, it uses the default >> clock, CLOCK_REALTIME. My recent change (r315280) does not fix this >> behavior; in fact, I believe it will make the problem worse, since >> moving the clock forward will wake the thread prematurely. >> >> I think the JVM should be fixed to use CLOCK_MONOTONIC. Would someone >> like to do the research to determine the correct behavior of >> Thread.sleep()? Specifically, should the duration of the sleep be >> affected by adjustments to the real-time clock? I expect that it >> should /not/ be affected, especially since the API takes a >> relative/interval time. Ideally, we would find the answer in the >> formal language specification; failing that, I would be satisfied with >> empirical data from testing on Windows, Linux, MacOS, and Solaris. >> I'll be happy to write a patch once we know what it should do. >> >> Please keep me CC'd, since I'm not on freebsd-java@. (Thanks for the >> CC, Kostik.) > > It seems CLOCK_REALTIME behavior has bugged Linux in the past, too. I > think using CLOCK_MONOTONIC, perhaps via pthread_condattr_setclock() in > our JVM, would be the better approach. http://bugs.java.com/view_bug.do?bug_id=6900441 http://hg.openjdk.java.net/jdk8u/jdk8u/hotspot/rev/2e6938dd68f2 Basically, it was fixed in Linux source but it wasn't merged to ours somehow. Please try the attached patch. > You'd probably also want to check that whatever java.util.concurrent > relies on, if different, also behaves similarly (monotonically). Runtime behaviour depends on HotSpot implementation. Jung-uk Kim
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?CAPRzLQSGBLzBqR1nWEt9DZ_eQUbcXQ%2BASyFmoWdZgEHXRPUk6Q>
