From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from conssluserg-04.nifty.com (conssluserg-04.nifty.com [210.131.2.83]) by sourceware.org (Postfix) with ESMTPS id 6D8663858406 for ; Mon, 20 Dec 2021 23:58:27 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 6D8663858406 Authentication-Results: sourceware.org; dmarc=fail (p=none dis=none) header.from=nifty.ne.jp Authentication-Results: sourceware.org; spf=fail smtp.mailfrom=nifty.ne.jp Received: from Express5800-S70 (v050141.dynamic.ppp.asahi-net.or.jp [124.155.50.141]) (authenticated) by conssluserg-04.nifty.com with ESMTP id 1BKNw8jJ013925 for ; Tue, 21 Dec 2021 08:58:08 +0900 DKIM-Filter: OpenDKIM Filter v2.10.3 conssluserg-04.nifty.com 1BKNw8jJ013925 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nifty.ne.jp; s=dec2015msa; t=1640044688; bh=4D+J0tklSF5cxdgPYVDV/bTksHDz35KA8kejTY2MAcM=; h=Date:From:To:Subject:In-Reply-To:References:From; b=hc9n594VdqIgVep6/LUsW1WVsFx3048rCYeXRFJdsEhV4CQklv0FRgmZKLVLNt+VN 8r3Y2L6uaTFk4v6N1xLEY8F+I43iE3/A9ammyrcKyDwkVTdtmNlat3i68O9qjorzdT w1AcA89KEF6lHUq8MjvSWqpCbPyp4SJgchdgZEamOH/Hh+Nr6PHw3H5fzeagpbv+4z BblCFtZvU7Ttxb57j19qfyUx26u4vAH6OW7hLd81hXAgUr3VCAbBOFfankE9UPMMrs b3md4HDQikanOTGTR2IDiJ0pkvQ/gv0xIJR1EXyVdrDaj3KfjxoPr2tvyzpi3ASLVe 7laPmFzqUN7nQ== X-Nifty-SrcIP: [124.155.50.141] Date: Tue, 21 Dec 2021 08:58:13 +0900 From: Takashi Yano To: cygwin-developers@cygwin.com Subject: Re: thread safety of fhandler_base_overlapped Message-Id: <20211221085813.6113e8f4e9cae4ac33ef4653@nifty.ne.jp> In-Reply-To: References: X-Mailer: Sylpheed 3.7.0 (GTK+ 2.24.30; i686-pc-mingw32) Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-6.4 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, NICE_REPLY_A, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on server2.sourceware.org X-BeenThere: cygwin-developers@cygwin.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Cygwin core component developers mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 20 Dec 2021 23:58:30 -0000 On Mon, 20 Dec 2021 19:02:56 -0400 David McFarland wrote: > I'm seeing a problem where occasionally write() returns EAGAIN on a > blocking pipe. I believe this happens when multiple threads are writing > concurrently to the pipe, and the overlapped structure is modified by > one thread while another one is between calls to WFMO and > GetOverlappedResult. > > I found this change: > > ===== > commit 2a4b1de773e6159ea8197b6fc3f7e4845479b476 > Author: Corinna Vinschen > Date: Mon Mar 23 21:06:00 2020 +0100 > > Cygwin: serial: use per call OVERLAPPED structs > > Sharing the OVERLAPPED struct and event object in there between > read and select calls in the fhandler might have been a nice > optimization way back when, but it is a dangerous, not thread-safe > approach. Fix this by creating per-fhandler, per-call OVERLAPPED > structs and event objects on demand. > > Signed-off-by: Corinna Vinschen > ===== > > which seems to fix a similar problem in fhandler_serial. > > Is is possible that this needs to be done for fhandler_base_overlapped > as well? I'll try using per-call buffers to see if it fixes my problem. Pipe code was completely overhauled. Could you please try the latest developer snapshot? https://cygwin.com/snapshots/ -- Takashi Yano