From owner-freebsd-java@freebsd.org Thu Apr 13 10:28:34 2017 Return-Path: Delivered-To: freebsd-java@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 7D099D3C2C2 for ; Thu, 13 Apr 2017 10:28:34 +0000 (UTC) (envelope-from redraiment@gmail.com) Received: from mail-lf0-x244.google.com (mail-lf0-x244.google.com [IPv6:2a00:1450:4010:c07::244]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client CN "smtp.gmail.com", Issuer "Google Internet Authority G2" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id E64C7B5F; Thu, 13 Apr 2017 10:28:33 +0000 (UTC) (envelope-from redraiment@gmail.com) Received: by mail-lf0-x244.google.com with SMTP id i3so6268445lfh.2; Thu, 13 Apr 2017 03:28:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:in-reply-to:references:mime-version:date:message-id:subject:to :cc; bh=PHrkRNnpfifxtvMeRa39RL07mvtiYvAaYCAdC7gMYTg=; b=jfcM1EtToLB5lIsTWaJYZl996zqXp6tOmiRi4RJDSpLuHDZeYCirB2mP7JzbIu+snV uanQXwXqohNrL7+vqVTJ7tBWqXKsromqUFSqKODL2gMQBW6RtgTtme644Ox4snKXCH7b YZBdujGWbyoRBf8Vk7paKsDM4GlnbvgrMNyi+BqJ5aD9iXc8QY0C6ILV8T9L+ubV4c2I aDWQZdahkIK7FH+BuPI1NZcZwCfb0mcG+h6oNdxg/aAWjEDr9yfTxUn84myN9fSI8fy7 ulmgCiyqMLHDwxZ5FJ8IS3XR9JoJlgebQKcBH585cAul/bpB6uoKt67GN/thuRqrTkbX VUJg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:in-reply-to:references:mime-version:date :message-id:subject:to:cc; bh=PHrkRNnpfifxtvMeRa39RL07mvtiYvAaYCAdC7gMYTg=; b=pTrbmSYdiKHK0UgbVFC7TaZUfUjJcuMnXUSdafNJm7EAjWR3a/ssdxX2JEgeEq+FC1 Avp+Wl3LL4nkAousPNmVl+1/s0jJjcrH+by6HI+hho61kyZUb/C92OZWG1Qyws+tsalz u4GR399LOOOKecwWxD3YjrEiSD/AnEbrUWgZgwf8D/FjKDHcJU0Iz3AUiRDnASVwd566 8BemUgEnMtK43hRGzUy4t63I4wMsqbGAIBS6yoqESHcHD7jygRGFUWxA+F1HJxU0m3Jf k8q6oCgp+s0Qe720ePXxPB2MvDjXzfmqaX8hb10hNDhJMxBrZwT29IzGNb1BYc/9J2q3 tPxA== X-Gm-Message-State: AN3rC/5Si0ZMLAX5aBnGqbQ0UM10R38IIhLINmYFzOdaZJ9Z3AIkqMKE QvMcAKI1Ki/hJENkk3+beapP7JAYtQ== X-Received: by 10.46.71.206 with SMTP id u197mr711049lja.104.1492079310527; Thu, 13 Apr 2017 03:28:30 -0700 (PDT) Received: from 1058052472880 named unknown by gmailapi.google.com with HTTPREST; Thu, 13 Apr 2017 06:28:29 -0400 From: =?UTF-8?B?5byg5rO96bmP?= In-Reply-To: <2349193f-568b-37f1-dcc5-7e0002046325@FreeBSD.org> References: <20170408070340.GD1788@kib.kiev.ua> <2349193f-568b-37f1-dcc5-7e0002046325@FreeBSD.org> X-Mailer: Airmail (420) MIME-Version: 1.0 Date: Thu, 13 Apr 2017 06:28:29 -0400 Message-ID: Subject: Re: OpenJDK8 Thread.sleep will deadlock while turn down system date time. To: Jung-uk Kim , Eric van Gyzen , Daniel Eischen Cc: Konstantin Belousov , freebsd-java@freebsd.org Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable X-Content-Filtered-By: Mailman/MimeDel 2.1.23 X-BeenThere: freebsd-java@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Porting Java to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 13 Apr 2017 10:28:34 -0000 I apply the patch and reinstall from ports, it works well for me now. Thanks Kim! thanks everyone! =E5=8F=91=E4=BB=B6=E4=BA=BA: Jung-uk Kim =E5=9B=9E=E5=A4=8D: Jung-uk Kim =E6=97=A5=E6=9C=9F: 2017=E5=B9=B44=E6=9C=8813=E6=97=A5 at =E4=B8=8A=E5=8D= =881:17:41 =E8=87=B3: Daniel Eischen , Er= ic van Gyzen =E6=8A=84=E9=80=81: redraiment@gmail.com , Konstantin Belousov , freebsd-java@freebsd.org =E4=B8=BB=E9=A2=98: Re: OpenJDK8 Thread.sleep will deadlock while turn dow= n 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=3D6900441 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