From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from conssluserg-02.nifty.com (conssluserg-02.nifty.com [210.131.2.81]) by sourceware.org (Postfix) with ESMTPS id E271A386F454 for ; Tue, 5 Jul 2022 08:41:15 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org E271A386F454 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 HP-Z230 (ak044095.dynamic.ppp.asahi-net.or.jp [119.150.44.95]) (authenticated) by conssluserg-02.nifty.com with ESMTP id 2658evUn031441 for ; Tue, 5 Jul 2022 17:40:57 +0900 DKIM-Filter: OpenDKIM Filter v2.10.3 conssluserg-02.nifty.com 2658evUn031441 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nifty.ne.jp; s=dec2015msa; t=1657010457; bh=FJlqxHSKZV09XlCzgp9nBJ6+4tPPW7/H9eI06b68Yn4=; h=Date:From:To:Subject:In-Reply-To:References:From; b=AuwUVTJLfuAPJJDX+BdItusGEnLMNfxjoXFI266kcP8q2c+SQRB+77+GfoLoWbJYl VhT4F6IhrADlXdSCjpYhYvIeA5x90T/Ik+7OcGiTD74y6MpTKpltvKa6/nsXBuVAr2 Ez7EYUhGp3krwgqfBrmfa9LDtbCOIeWKq3a+CX/fd2lJLUSdlABI+TfmaW7ws3yvpn /9ESV4fFGrQ1+W8kcFY9IVOtnROIRt5FAfC8Mb4H2weX5DYxRgc3RwDkpvPXCx3WCV Fb5Ei26XLnu9d6U66sR4x2mqr6hErxciqK42z7FjJZy2fQDEdPqLLPJZRvcdtY87F/ JSjOFT3ADSy3A== X-Nifty-SrcIP: [119.150.44.95] Date: Tue, 5 Jul 2022 17:40:58 +0900 From: Takashi Yano To: cygwin@cygwin.com Subject: Re: /dev/clipboard sometimes fails to set CF_UNICODETEXT data. Message-Id: <20220705174058.b4d8cb5ce54f7fac8700aaa9@nifty.ne.jp> In-Reply-To: <62975088-7bc3-7dde-d08c-3972126304f1@maxrnd.com> References: <20220702122056.39a6c5e49c637d028694412e@nifty.ne.jp> <62975088-7bc3-7dde-d08c-3972126304f1@maxrnd.com> 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=-4.6 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, NICE_REPLY_A, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: cygwin@cygwin.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: General Cygwin discussions and problem reports List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 05 Jul 2022 08:41:21 -0000 On Tue, 5 Jul 2022 00:42:50 -0700 Mark Geisert wrote: > Hi Takashi, > > Takashi Yano wrote: > > Hello, > > > > In one of my PCs, > > dd if=/dev/urandom count=10 | xxd > /dev/clipboard > > sometimes fails to set CF_UNICODETEXT data. > > As a result, pasting clipboard to notepad does not work. > > > > Even in the case, cygnativeformat data is set correctly. > > So, "cat /dev/clipboard" works. > > > > This problem depends on machine very much. > > > > My one PC with Xeon E3-1281 v3 CPU has a high probability of failure, > > however, another machine with Core i7-6700K CPU does not. > > > > I looked into this problem, and found OpenClipboard() for > > CF_UNICODETEXT fails. It seems that OpenClipboard() just > > after CloseClipboard() has high probability of failure. > > > > You can see the following test case immediately stops with error. > > Even with Core i7-6700K CPU machine above, the test case fails. Additional information: In the machine with Xeon E3-1281 v3 CPU, the test case fails in a several times of the loop, while it fails after 1000 to 3000 times of the loop in the machine with Core i7-6700K CPU. The probability of failure depends much on machine. > > #include > > #include > > > > int main() > > { > > for (;;) { > > if (!OpenClipboard(0)) { > > printf("Open error.\n"); > > break; > > } > > if (!EmptyClipboard()) { > > printf("Empty error.\n"); > > break; > > } > > if (!CloseClipboard()) { > > printf("Cloes error.\n"); > > break; > > } > > } > > return 0; > > } > > > > I also found the patch attached solves the issue. > > > > I would appreciate any suggestion. > > Would be neet if this patch wasn't needed, but, oh well. My only comment on the > patch would be to possibly call the new wrapper function MyOpenClipboard, or > CygOpenClipboard, to help keep the name paired with CloseClipboard. Thanks for the comment. IIUC, the camel case name should be used only for Win32 APIs related. However, this is the wrapper for Win32 API. So, it might be acceptable. In other places, some wrapper functions are named as camel case. Corinna, WDYT? > I suppose it might happen in the future that a faster processor will require the > loop count to be made larger. Once again, oh well. Maybe. In my most cases, OpenClipboard() successes after one or two times of retrying. So, I think max_retry = 10 is enough for the time being. > My 2c (adjusted for inflation), -- Takashi Yano