From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from m0.truegem.net (m0.truegem.net [69.55.228.47]) by sourceware.org (Postfix) with ESMTPS id 836DC385828E for ; Tue, 5 Jul 2022 07:42:59 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 836DC385828E Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=maxrnd.com Authentication-Results: sourceware.org; spf=none smtp.mailfrom=maxrnd.com Received: (from daemon@localhost) by m0.truegem.net (8.12.11/8.12.11) id 2657gumF024279 for ; Tue, 5 Jul 2022 00:42:56 -0700 (PDT) (envelope-from mark@maxrnd.com) Received: from 162-235-43-67.lightspeed.irvnca.sbcglobal.net(162.235.43.67), claiming to be "[192.168.1.100]" via SMTP by m0.truegem.net, id smtpdrNWKAN; Tue Jul 5 00:42:49 2022 Subject: Re: /dev/clipboard sometimes fails to set CF_UNICODETEXT data. To: cygwin@cygwin.com References: <20220702122056.39a6c5e49c637d028694412e@nifty.ne.jp> From: Mark Geisert Message-ID: <62975088-7bc3-7dde-d08c-3972126304f1@maxrnd.com> Date: Tue, 5 Jul 2022 00:42:50 -0700 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:52.0) Gecko/20100101 Firefox/52.0 SeaMonkey/2.49.4 MIME-Version: 1.0 In-Reply-To: <20220702122056.39a6c5e49c637d028694412e@nifty.ne.jp> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-2.6 required=5.0 tests=BAYES_00, KAM_DMARC_STATUS, KAM_LAZY_DOMAIN_SECURITY, NICE_REPLY_A, SPF_HELO_NONE, SPF_NONE, TXREP, T_SCC_BODY_TEXT_LINE autolearn=no 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 07:43:01 -0000 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. > > #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. 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. My 2c (adjusted for inflation), ..mark