delorie.com/archives/browse.cgi | search |
X-Recipient: | archive-cygwin AT delorie DOT com |
X-SWARE-Spam-Status: | No, hits=-4.5 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,KHOP_RCVD_TRUST,RCVD_IN_DNSWL_LOW,RCVD_IN_HOSTKARMA_YE,T_RP_MATCHES_RCVD |
X-Spam-Check-By: | sourceware.org |
X-Google-DKIM-Signature: | v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=mime-version:date:message-id:subject:from:to:content-type :x-system-of-record:x-gm-message-state; bh=nG90xDM713gyDprB8ZhgMskW7htK0NASOmrIJ3Z9fzU=; b=H8clhHuAuIuip7DKDLhMc+WtcgMT8Qx8kHnIshrlJGH9mf6ln6PqAqtDcORW4BlnnG 9TxoCElHCcQZfe18Fx8eIM0KMpRJnMcmRnq15ZlFQUAjCh60551rQ0xKU8ypZNa+7hFD kdWleTCmBWLmj0ZLGrJpFQCFQIiPZz/TqWvM7zzFij2xn1rlPkLcmHXWB/o9DmE8bIHP /kcwcIwBmNIeu3De43cV/FwzpRhWC1AaWzUxTPBXSq1W2sQMc16GTGW+NuNiClW4E42K XbVZKHYsY/0NYxIZlhzc6bd0qEhyqL758YmJxSNPvim7aYrYJqUh4dUv6aO1Lvl+Id+0 0ATA== |
MIME-Version: | 1.0 |
Date: | Tue, 24 Jul 2012 17:25:43 +0400 |
Message-ID: | <CACgPhYpV-M477Mfugp3DjdWCEvbJ-8LhyH12y=iGP_MuK6VTAQ@mail.gmail.com> |
Subject: | Race condition that leads to random crashes in cygwin-based builds. |
From: | Andrey Khalyavin <halyavin AT google DOT com> |
To: | cygwin AT cygwin DOT com |
X-System-Of-Record: | true |
X-Gm-Message-State: | ALoCoQnab5EvVADlBdr04pUiPqMaN3j5/EIgwhAjsGoHACW6/c1p0R6c8r+uO70WmUc3dUDiabGJ0pa/v9T01a1+FYlF76Txjj6vyzKefu9XmV90qEF2Xrmi8v2jO62fxfxS0cimNwwPXRxGgJ4X7LEDmJ7sOk8GCPi654+1gxw4Q3Z5OBB6Lmsvfpm/6jlktxZzmfF5S60I |
Mailing-List: | contact cygwin-help AT cygwin DOT com; run by ezmlm |
List-Id: | <cygwin.cygwin.com> |
List-Subscribe: | <mailto:cygwin-subscribe AT cygwin DOT com> |
List-Archive: | <http://sourceware.org/ml/cygwin/> |
List-Post: | <mailto:cygwin AT cygwin DOT com> |
List-Help: | <mailto:cygwin-help AT cygwin DOT com>, <http://sourceware.org/ml/#faqs> |
Sender: | cygwin-owner AT cygwin DOT com |
Mail-Followup-To: | cygwin AT cygwin DOT com |
Delivered-To: | mailing list cygwin AT cygwin DOT com |
Hi, we have build bots that crash randomly on Windows XP and rarely on Windows 7. These bots use our compiler that runs under cygwin. Although crashes are rare, we have ~20 bots what makes green builds almost impossible. I tried to reproduce these crashes on my local Windows XP computer and after several days (on bots crashes are much more frequent may be due to them using virtual machines) I got a crash dump. Investigation of this crash dump showed that wincapc::init in winsup\cygwin\wincap.cc called api_fatal ("Cygwin requires at least Windows 2000."). This function is called at cygwin1.dll initialization even before any code in our compiler (cc1.exe) have been executed. Further investigation showed that wincapc variable is in shared section: wincapc wincap __attribute__((section (".cygwin_dll_common"), shared)); but wincapc::init() function doesn't have any synchronization and is called from dll_crt0_0 without any synchronization. Using shared variables without synchronization is sure way to get random failures. Here is one scenario that can lead to api_fatal called: 1. No cygwin processes exist in a system. 2. Two cygwin processes are started simultaneously. 3. First process enters wincapc::init, clears version field with memset and executes version.dwOSVersionInfoSize = sizeof (OSVERSIONINFOEX) 4. Task switching happens and second process enters wincapc::init. It sees that caps field is still not initialized yet and cleaders version field with memset. 5. Task switching happens and first process proceeds to execute GetVersionEx with version cleared by memset and so not having its size set. 6. GetVersionEx returns error and first process fails to start. If there is no easy way to add synchronization to wincapc::init, I suggest to make wincap a regular (not shared) variable. Andrey Khalyavin -- 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
webmaster | delorie software privacy |
Copyright © 2019 by DJ Delorie | Updated Jul 2019 |