X-Recipient: archive-cygwin AT delorie DOT com DomainKey-Signature: a=rsa-sha1; c=nofws; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:date:from:to:subject:message-id:reply-to :references:mime-version:content-type:in-reply-to; q=dns; s= default; b=kfGGT6MJqO4spKy7ZELaE/0pNw005fgOoOysbgRi+uwxfNScpY94p TVkjYXxYOpewaVTBMtnRVQ8N2nWjdFRwlOBmtKrRhFVQaRBlxFRHxfD3bIEk/1nf Q2aRrbbxNvBgYrkMTDbWWoto+pOzhPKEi2byiSKfb2B1Wk2lpdp1ws= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:date:from:to:subject:message-id:reply-to :references:mime-version:content-type:in-reply-to; s=default; bh=Jy9HxOQtmqsO/oVYtt5XbyJM4iM=; b=t85Uvvlb0liMMh+KOZFyk/zVm4m7 nxl0KqcJmivMAaFqsSSjFSl1SP66dEZFIAgejsXzPKBtllV/aU3I9S8kKU7UVv4r DC6sCih/CuIxBvIIE8v9CsShYznOSW/vmKAXVd6I7+3L1a1sSK7wQvTRrcNAR9fI ceUjX84/gZ9/yxc= Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: cygwin-owner AT cygwin DOT com Mail-Followup-To: cygwin AT cygwin DOT com Delivered-To: mailing list cygwin AT cygwin DOT com Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-4.5 required=5.0 tests=AWL,BAYES_20,KAM_LAZY_DOMAIN_SECURITY autolearn=no version=3.3.2 X-HELO: calimero.vinschen.de Date: Tue, 8 Sep 2015 10:30:40 +0200 From: Corinna Vinschen To: cygwin AT cygwin DOT com Subject: Re: [OT] Wine + Cygwin: `script -e` exit status forwarding randomly return zero for non zero child process Message-ID: <20150908083040.GA24811@calimero.vinschen.de> Reply-To: cygwin AT cygwin DOT com Mail-Followup-To: cygwin AT cygwin DOT com References: <20150903105549 DOT GT23669 AT calimero DOT vinschen DOT de> <20150907122836 DOT GB20288 AT calimero DOT vinschen DOT de> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="9amGYk9869ThD9tj" Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.23 (2014-03-12) --9amGYk9869ThD9tj Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Sep 8 01:13, Qian Hong wrote: > Hi Corinna, >=20 > Thanks again for the quick reply. >=20 > On Mon, Sep 7, 2015 at 8:28 PM, Corinna Vinschen wrote: > > The terminate_thread_frees_stack flag is set to false for XP/2003 and to > > true for any newer OS. I guess this is a double-free because Wine's > > TerminateThread already freed the stack and Cygwin got the info it's > > supposedly running under XP/2003, so it tries to workaround the fact > > that TerminateThread on these systems didn't free the stack by themselv= es. > > >=20 > Wine emulates Windows XP here, I double checked Wine source code and I > can confirm Wine doesn't free the stack: > NtTerminateThread() -> abort_thread() -> terminate_thread() > https://github.com/wine-compholio/wine-patched/blob/8b3a785e97a7e28ff5873= 1b58d19237a59239acc/dlls/ntdll/thread.c#L369 >=20 > Cygwin reports wincap as wincap_xpsp2 which is also correct here. Ok. > > we need to know what address ret=3D61005767 is refering to. addr2line = would help. >=20 > As you point out, ret=3D61005767 is the call to VirtualFree() inside > cygthread::terminate_thread () > https://sourceware.org/git/?p=3Dnewlib-cygwin.git;a=3Dblob;f=3Dwinsup/cyg= win/cygthread.cc;h=3De48a73e545e7ca90884fc891f1b188e0ab3bf863;hb=3DHEAD#l324 >=20 > After combine the information we have so far, I think the problem is > clear now. It's not Cygwin's fault, it's Wine's fault. Wine's > WaitForSingleObject() needs to wait long enough after the > TerminateThread() call, so the target thread has enough time to finish > the system cleanup and return correct exit_code before Cygwin call > VirtualFree to free the stack. But in our current implementation > Wine's WaitForSingleObject returns too early, it shouldn't return > before the system thread cleanup done, as a result there is a race > here. We are thinking of a solution in Wine. Thanks again for the > great help! No worries. I'm glad if we can help each other. Corinna --=20 Corinna Vinschen Please, send mails regarding Cygwin to Cygwin Maintainer cygwin AT cygwin DOT com Red Hat --9amGYk9869ThD9tj Content-Type: application/pgp-signature -----BEGIN PGP SIGNATURE----- Version: GnuPG v2 iQIcBAEBCAAGBQJV7pywAAoJEPU2Bp2uRE+gy4MP/iV/ZCSAfo32f69PCpI1LTzB aKHw8WV3HSOTrGBF4JLu/7XRnZnAEELorzWtBfSyLCjEJUFll3HugRVQECwPne2d gdQMHjFsVv94Q4LpNrnfGE1zSAUur6c3Xhm4ujTMQ/WXHuTacwOhrQLRt6Kngbch ZZZpkTZgTyyO4TnI66eUtLTzfNGCns+OPGJCnD52ICnn0Own+kCEiDfiLhr8W6W2 4gF1MfGrEEZYjGMjA6kzUe54qihEZ+u3LtW7q7LFyM1i7mkGbE2Pu5PwG6Sbjle7 6K1SyPtOsIJzaVPMADu7WFByFIlettjSSe4FoOaeWGKvUcoefEotu1tdMm5NzZug Wjr3ZiOBzU0Gm62mQ7xyY8FiYqCZawtjpt/KHa5dNtdroUukxoPjBZFt9MKGy4hs +wHKiqDSLuVS1SroevUmlvo4DW2EwLlP52SV/27NYjEq0wInTnO+3WS7YC+6BZIN P1E1yQGzTBeapmRg0F+QbZNH9HGkh0gPsQxzCPZLKV96bZvxF/DZfTbfcSoawMux Pe+dvT3YXdJIu/ih/oqTEzWVA/dCbtToEEgpxlI1Ue6dT79RPGYJTvCxGEbXnK/L LDaBtzJnWmHfmcxNi5ZQmkRnqE64uw/uWhUVUDVdCb/MUj0LmRZ6SSy4400jBwd2 QeXD+2N7qfS6tSudTOCZ =/IUI -----END PGP SIGNATURE----- --9amGYk9869ThD9tj--