From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-qv1-xf31.google.com (mail-qv1-xf31.google.com [IPv6:2607:f8b0:4864:20::f31]) by sourceware.org (Postfix) with ESMTPS id 3C0633858D39 for ; Mon, 20 Dec 2021 23:03:02 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 3C0633858D39 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-qv1-xf31.google.com with SMTP id ke6so10838383qvb.1 for ; Mon, 20 Dec 2021 15:03:02 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:mime-version; bh=F3TtgV+FzWRZSY0f2YrhyRzUAee1OLNN3SDCAloXneI=; b=bjd/Xu5x8LuHA+5TbAIPby0xEQiHwLcsGlyn6WvKce3CqXUVLnAq9Zp/xgireHEb3N uW9ABgAMMdt8YemGtShUi5AWXbGCL5JbJ0xXME8XpK3K+q2jH6uEpeWK7edZhzFWJ6rG ebiolz2mwn/NAyOqGWGCW95mLoOJRkC9osAKjFUcqukW6TGg53Z3EiunTUeepM+4Saey SrHH2pfd8AwOhgonUkHnl5szwv2v4z+9Q2doEJWn7xAHTFb/cQkhssTQdpFapxsTfmR7 LupMoIccC3EMKIdmrNOe4/UmRE7N56M9TAezdWxusdzIgyPTla6x0KMZzYuqaxym+QZx AYyw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version; bh=F3TtgV+FzWRZSY0f2YrhyRzUAee1OLNN3SDCAloXneI=; b=KjZUgbc2+ukqfJiAuNGoD8VKBMsC3vzuR2B7uJ69/ofkx68NJBlLmGoyRfn24duLUS fsl+EgNbYzZH2GXHjSBxhE2hMdDvybAyh72xvMwjNUGGReQDBgJmNv2asKBVDuOskjaZ cJBbrUNdQLGhEkce4JXpnPmO9dVQSj8BPe6GkO0psxyUU95RBcK+R/j3n7pW/ToqRzi+ Gq/UDj51MlVgqftylcZqmOmlyyohMQhNMEuOwly/6kDVbfp6r7P0JA60lfouUEIZrFDj 2Op8PHEe/uq63mYOrSNJQbQxGDM/CjP8nT+aVyzL3oDffQ+hjcYXcPNLpF++zP6PV/QH dbGQ== X-Gm-Message-State: AOAM5330ZOt+hl2ReqWoU56PC6WRbUrJ6hSrn4VVxkXrlChmqm7ogzhN oN2DwQq/hCBec8tzSdnJLdg= X-Google-Smtp-Source: ABdhPJwqMyhGfiXgRcvnpW6LbnEZQYB2Y59PO6sLWc/BqKX/CSlCNpdQHyvD1pHS84Dt+/vPKo5TiA== X-Received: by 2002:ad4:5bec:: with SMTP id k12mr335951qvc.94.1640041381780; Mon, 20 Dec 2021 15:03:01 -0800 (PST) Received: from davidm-laptop (host-24-138-77-139.public.eastlink.ca. [24.138.77.139]) by smtp.gmail.com with ESMTPSA id l9sm12276990qkj.37.2021.12.20.15.02.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 20 Dec 2021 15:03:00 -0800 (PST) From: David McFarland To: cygwin-developers@cygwin.com Cc: corngood@gmail.com Subject: thread safety of fhandler_base_overlapped Date: Mon, 20 Dec 2021 19:02:56 -0400 Message-ID: MIME-Version: 1.0 Content-Type: text/plain X-Spam-Status: No, score=-3.6 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, FREEMAIL_FROM, RCVD_IN_DNSWL_NONE, 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:03:07 -0000 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.