From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 128346 invoked by alias); 1 Dec 2018 08:57:21 -0000 Mailing-List: contact cygwin-help@cygwin.com; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: cygwin-owner@cygwin.com Mail-Followup-To: cygwin@cygwin.com Received: (qmail 128328 invoked by uid 89); 1 Dec 2018 08:57:19 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-2.6 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_LOW,SPF_PASS autolearn=ham version=3.3.2 spammy=claim, Hx-spam-relays-external:sk:webmail, H*RU:sk:webmail, H*F:D*nl X-HELO: lb1-smtp-cloud9.xs4all.net Received: from lb1-smtp-cloud9.xs4all.net (HELO lb1-smtp-cloud9.xs4all.net) (194.109.24.22) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Sat, 01 Dec 2018 08:57:17 +0000 Received: from webmail.xs4all.nl ([IPv6:2001:888:0:22:194:109:20:216]) by smtp-cloud9.xs4all.net with ESMTPA id T15PgFRiCfa12T15PgoT1G; Sat, 01 Dec 2018 09:57:15 +0100 Received: from a83-162-234-136.adsl.xs4all.nl ([83.162.234.136]) by webmail.xs4all.nl with HTTP (HTTP/1.1 POST); Sat, 01 Dec 2018 09:57:15 +0100 MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII; format=flowed Content-Transfer-Encoding: 7bit Date: Sat, 01 Dec 2018 08:57:00 -0000 From: Houder To: cygwin@cygwin.com Subject: Re: MinTTY requires gdiplus.dll ? (2) In-Reply-To: <20181130131918.GI30649@calimero.vinschen.de> References: <1953c30851fd83b67ee9b162b29f4195@xs4all.nl> <20181129195845.GE30649@calimero.vinschen.de> <4286450150901731f39f9514b8044ded@xs4all.nl> <20181130131918.GI30649@calimero.vinschen.de> Message-ID: X-Sender: houder@xs4all.nl User-Agent: XS4ALL Webmail X-IsSubscribed: yes X-SW-Source: 2018-12/txt/msg00004.txt.bz2 On 2018-11-30 14:19, Corinna Vinschen wrote: [snip] > I'm trying to avoid remote debugging so I rather try to reproduce this > @work. However, if you're interested in debugging this, set a > breakpoint to clk_monotonic_t::now() and observe how the call to the > virtual init() method hangs or crashes. If you find out why, I'd be > most grateful. Below I included parts of the diff between 1126 and 1129. You have been refactoring the code related to "timing". Above you state that the call to init() (clk_monotonic_t::init(), is my understanding) from clk_monotonic_t::now() makes the cygwin1.dll end up in "some mysterious loop" (my wording). At least on pre-W10 ... Looking at the code (trying to understand it), it appears to me that it is NOT "Windows version" dependent ... My question: why do you claim in https://cygwin.com/ml/cygwin/2018-11/msg00261.html that Windows 10 is NOT affected? Does W10 run a different "thread" in the Cygwin codebase? Regards, Henri ====== https://cygwin.com/snapshots/x86/cygwin-diffs-20181126-20181129 FILE: winsup/cygwin/clock.h: +class clk_t +{ + protected: + LONG inited; + LONGLONG ticks_per_sec; + virtual void init (); + virtual int now (clockid_t, struct timespec *) = 0 ... +class clk_monotonic_t : public clk_t +{ + protected: + virtual void init (); + private: + virtual int now (clockid_t, struct timespec *); +}; ... FILE: winsup/cygwin/clock.cc: +void +clk_t::init () +{ + spinlock spin (inited, 1); + if (!spin) + ticks_per_sec = system_tickcount_resolution (); +} + ... +void +clk_monotonic_t::init () +{ + spinlock spin (inited, 1); + if (!spin) + ticks_per_sec = system_qpc_resolution (); +} ... +int +clk_monotonic_t::now (clockid_t clockid, struct timespec *ts) +{ + if (wincap.has_precise_interrupt_time ()) + { + /* Suspend time not taken into account, as on Linux */ + ULONGLONG now; + + QueryUnbiasedInterruptTimePrecise (&now); + ts->tv_sec = now / NS100PERSEC; + now %= NS100PERSEC; + ts->tv_nsec = now * (NSPERSEC/NS100PERSEC); + } + else + { + /* https://stackoverflow.com/questions/24330496. Skip rounding since + its almost always wrong when working with timestamps */ + UINT64 bias; + LARGE_INTEGER now; + struct timespec bts; + + if (inited <= 0) + init (); // Henri: invocation of clk_monotonic_t::init() + do + { + bias = SharedUserData.InterruptTimeBias; + QueryPerformanceCounter(&now); + } + while (bias != SharedUserData.InterruptTimeBias); + /* Convert perf counter to timespec */ + ts->tv_sec = now.QuadPart / ticks_per_sec; + now.QuadPart %= ticks_per_sec; + ts->tv_nsec = (now.QuadPart * NSPERSEC) / ticks_per_sec; + /* Convert bias to timespec */ + bts.tv_sec = bias / NS100PERSEC; + bias %= NS100PERSEC; + bts.tv_nsec = bias * (NSPERSEC/NS100PERSEC); + /* Subtract bias from perf */ + ts_diff (bts, *ts); + } + return 0; +} ===== -- Problem reports: http://cygwin.com/problems.html FAQ: http://cygwin.com/faq/ Documentation: http://cygwin.com/docs.html Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple