public inbox for cygwin-cvs@sourceware.org
help / color / mirror / Atom feed
From: Corinna Vinschen <corinna@sourceware.org>
To: cygwin-cvs@sourceware.org
Subject: [newlib-cygwin] Cygwin: timerfd: add a sleep when being debugged
Date: Tue, 26 Feb 2019 09:46:00 -0000	[thread overview]
Message-ID: <20190226094639.73002.qmail@sourceware.org> (raw)

https://sourceware.org/git/gitweb.cgi?p=newlib-cygwin.git;h=639645a2fd753f29ed9693b7c34f015c01de1741

commit 639645a2fd753f29ed9693b7c34f015c01de1741
Author: Corinna Vinschen <corinna@vinschen.de>
Date:   Tue Feb 26 10:46:05 2019 +0100

    Cygwin: timerfd: add a sleep when being debugged
    
    A sleep is required on Windows 10 64 bit only before calling
    RegisterClassW in the timerfd thread, and only when running
    under strace.  One of the child processes inheriting the timerfd
    descriptor will get a STATUS_FLOAT_INEXACT_RESULT exception inside
    of msvcrt.dll.  It's apparently some timing problem.  It occurs
    in 4 out of 5 runs under strace only.  WOW64 and Windows 7 64 bit
    don't have this problem.
    
    Signed-off-by: Corinna Vinschen <corinna@vinschen.de>

Diff:
---
 winsup/cygwin/timerfd.cc | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/winsup/cygwin/timerfd.cc b/winsup/cygwin/timerfd.cc
index b0d4db9..8e4c94e 100644
--- a/winsup/cygwin/timerfd.cc
+++ b/winsup/cygwin/timerfd.cc
@@ -32,6 +32,15 @@ timerfd_tracker::create_timechange_window ()
   wclass.lpfnWndProc = DefWindowProcW;
   wclass.hInstance = user_data->hmodule;
   wclass.lpszClassName = cname;
+  /* This sleep is required on Windows 10 64 bit only, and only when running
+     under strace.  One of the child processes inheriting the timerfd
+     descriptor will get a STATUS_FLOAT_INEXACT_RESULT exception inside of
+     msvcrt.dll.  While this is completely crazy in itself, it's apparently
+     some timing problem.  It occurs in 4 out of 5 runs under strace only.
+     The sleep is required before calling RegisterClassW.  Moving it before
+     CreateWindowExW does not work.  What the heck? */
+  if (being_debugged ())
+    Sleep (1L);
   atom = RegisterClassW (&wclass);
   if (!atom)
     debug_printf ("RegisterClass %E");


                 reply	other threads:[~2019-02-26  9:46 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20190226094639.73002.qmail@sourceware.org \
    --to=corinna@sourceware.org \
    --cc=cygwin-cvs@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).