From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from NAM10-DM6-obe.outbound.protection.outlook.com (mail-dm6nam10on20718.outbound.protection.outlook.com [IPv6:2a01:111:f400:7e88::718]) by sourceware.org (Postfix) with ESMTPS id C2FA63943541 for ; Tue, 13 Apr 2021 14:47:38 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org C2FA63943541 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=FAF72REkETdRe/skg3j9iT9Fan9V3W7Ejr0AXYH1PaWdfLh7fYnb9TAh8h81H17cD+Lt0GDOD450SxILI1H4C0JjAbnjgbLgHp/bwdLabhxDF80ueGGWDg1gO57YK1gOtJa5PMvX34LddabtcWGfjQu53xxSE8b1blY3mCm92ZPJt47ciJQmX5vrKeStpyoSkMklKqeUe61Q+vzxyICdG3+8GlXC9iqK8wys0mF7s6pr4hIAC4A0HFBn1FSWqBoJ3IfkKeoscHj4A2bNFdP8mkqWwF+zEsxIC6nM1PCEU7a9KK/zWDwOMLn40PTMqkser/qddCh23IizR1bcyBCLzA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=Bx5O2QKXC0ZuL+DePLTDcSd0XKFyVVFWTb86/JiseHQ=; b=dPhaqRBVm7N8vecy7w3zri7POV1Z+NOeNTuNCyRs/Sjfz2AurLf6RGyZkgRGFAVOB/FbLXWyNg0AoM+45oiCPTj7ommIiJ4EersAp/R7XkVROF8mDmbcRSWzR9Oe31RHDlTfhMLdXOU3PRArLvjf4/XbVHcN8DXo2rEUEWJ823A7FN22nWdRE0L+vM/sLRBFLTsCW6ifMgKc/KjvN/c+ioehPygo0br389BRhr8X294YOOJaddcZob5oLpsWATO2IWEcWxBCilXuzxNRdoZTpMub4lxPKzcQQgrZavzh8n+Q2xwryhR6VBynK9gZcMGdNj7at3FrAnP74cEFTbiyEQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=cornell.edu; dmarc=pass action=none header.from=cornell.edu; dkim=pass header.d=cornell.edu; arc=none Received: from BN7PR04MB4388.namprd04.prod.outlook.com (2603:10b6:406:f8::19) by BN8PR04MB5619.namprd04.prod.outlook.com (2603:10b6:408:a2::32) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4020.22; Tue, 13 Apr 2021 14:47:36 +0000 Received: from BN7PR04MB4388.namprd04.prod.outlook.com ([fe80::59f8:fcc4:f07e:9a89]) by BN7PR04MB4388.namprd04.prod.outlook.com ([fe80::59f8:fcc4:f07e:9a89%4]) with mapi id 15.20.4020.023; Tue, 13 Apr 2021 14:47:36 +0000 Subject: Re: AF_UNIX/SOCK_DGRAM is dropping messages To: sten.kristian.ivarsson@gmail.com, cygwin@cygwin.com References: <04cc01d71ffa$7d1e6cf0$775b46d0$@gmail.com> <00d901d7208e$97c05c50$c74114f0$@gmail.com> <860668bf-8cf9-0969-6a01-7fbf8b782db1@cornell.edu> <000901d72607$55dc5a90$01950fb0$@gmail.com> <3346cd1c-b93f-83c4-ff26-553ac95ec692@cornell.edu> <7c21a430-9609-7fd4-1a02-8b7c1978d2f8@cornell.edu> <001901d72af4$4009cd50$c01d67f0$@gmail.com> <134074c1-4c0b-0842-b88b-536a1ed4aefe@cornell.edu> <000e01d7306e$3c265580$b4730080$@gmail.com> From: Ken Brown Message-ID: <19cf8626-c653-76db-a409-730a5aa5c955@cornell.edu> Date: Tue, 13 Apr 2021 10:47:34 -0400 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101 Thunderbird/78.9.1 In-Reply-To: <000e01d7306e$3c265580$b4730080$@gmail.com> Content-Type: text/plain; charset=windows-1252; format=flowed Content-Language: en-US Content-Transfer-Encoding: 8bit X-Originating-IP: [24.194.34.31] X-ClientProxiedBy: CH0PR04CA0034.namprd04.prod.outlook.com (2603:10b6:610:77::9) To BN7PR04MB4388.namprd04.prod.outlook.com (2603:10b6:406:f8::19) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from [192.168.0.17] (24.194.34.31) by CH0PR04CA0034.namprd04.prod.outlook.com (2603:10b6:610:77::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4042.16 via Frontend Transport; Tue, 13 Apr 2021 14:47:36 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 61424eb6-5538-4183-e401-08d8fe8b1422 X-MS-TrafficTypeDiagnostic: BN8PR04MB5619: X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:10000; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 0DLA2KnZ3Xgmuvg0rRAcM6jl6O09QNCfM2mIJmBHqAF7TH3t3WOxauEQnHhF5zEK65hZ8W9Q/88Mfh8odPb3Jdfiyjn0k4pEatA8wudKqpYFjzoOG+XHr02SofsdlU2YAivQBphcLYKh5jzA3TQ2IV/HYHzU1ieKweXAfoI/hHt4cDx6frCFqlV3PaNvL+bd6EFSRadhJqEyuzZLcOMrPZcOd3nAuO4VpZLivzMQtEhXIR/lAHaG1F1LzhkYmPGuW43oIDQ2A4q7EV+UsEWLFvWPPDTi2BuotqBHgnzoaOyAWR2mMPIjDCKproBEJ8KWBVfxeZHpUtwcVCAL39R8Fhs02BMWHaboK19xIr3GWrcKlg8uwDCenfRErVrFtDUycbMJERjD6Ib7C32YRx+Vgu5JpkQnChgP0vvHyA1uqk4MwcBZ+c22tI3cRGonNpR9SBPL5ITiLxDRA4cHVPKVTtqhYB2CuPQhKKLIKU0lPWPfUaHu5B1J9tF3/GU0GhQsLhtbq7EzykqnvQomfVKC8+FHVxZ3rHhacZs4SyWZphWv8TdXjtyqIqrT2vNNaG26K8uGpVYTYJJ9h0xnyjhTWH4qW0Nee3H81ZxDY4E6CAWt09u3gKivwjayM1T9ejzgFLO9kcQdkTYw5ZrqcstMFIjo7+1JA+Yl/NH4inmU7peyqi0tvL6a4UWv83lRvO+RJvXq4DlFWvBiyzksLhq7SPf5o9F8jao/4Twy01UvKWJv1Zdv6biqIamEm/yFl4hKZNn6eMYM1Gzep2j1WjfFt/Cd5nN/S9l1JLpBsXTzQrM= X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:BN7PR04MB4388.namprd04.prod.outlook.com; PTR:; CAT:NONE; SFS:(4636009)(366004)(83380400001)(66574015)(66556008)(38100700002)(26005)(86362001)(36756003)(52116002)(2616005)(66476007)(8936002)(956004)(186003)(15650500001)(38350700002)(8676002)(31696002)(31686004)(53546011)(966005)(6486002)(75432002)(5660300002)(498600001)(66946007)(2906002)(16576012)(16526019)(43740500002)(45980500001); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData: =?Windows-1252?Q?nZ2l6L9s7U1Q1KC4oD5vZqEPhy1Snwj34r+oxbSe+HAeYxcnfhqq0S9j?= =?Windows-1252?Q?x5BXa7RK6EP2y9TncBrGbywUsUGAHFqIBVHUJLZRIzKviZPC95bjr+tK?= =?Windows-1252?Q?EA7IhZ/7mTiv6rzdAjU8myJoc89PEEfrclBXAKymWTOYeMiFkvmxlWog?= =?Windows-1252?Q?pYkr/5JjNzYUC898HHYSH488CyQF7Dkf5Z8NnGhZ1hUeJLWSwZdtOn+O?= =?Windows-1252?Q?zxAb5TNRwshl6ru+lLEnUCmocY2oqerjFhg6x4m6dM5u40LgFZx3psiY?= =?Windows-1252?Q?xiUjEulnOE7pICZ1T+JvJ7X6cBPVvSbY1lYf2i9v0RIQlgaXxh5+cmsn?= =?Windows-1252?Q?5gsZgoG7hbWI/H/HjZ5B7mAII1EppL9mWDFXinRjBja5apDPcgOPwrTj?= =?Windows-1252?Q?5RMt4LRcGlXyXFyVCrww4z1IG7QEDwmFH88u88P3zHmvGo4IQ/d3AorK?= =?Windows-1252?Q?4vYVt8DeTSDWkc/NeXdVkNps/SzXONx3wBRlZUcG8S47LKLoijaj9Z8z?= =?Windows-1252?Q?RjlIikxJngYHYx+dn1h92kOedp4ZXxPYJVMG8nLBYe9fa9XOtHzOPYXE?= =?Windows-1252?Q?4cEuJ52uq4KXiMqzqxCgAy/LAhfmlTdm7nCIu+Odn3/gmawF2uPjtLBd?= =?Windows-1252?Q?IT1QLOMah79ZDjbxoCgdUcZdv1Hce1Vi/CFccBHVPFZqSHMYZ9n0kTbK?= =?Windows-1252?Q?C70g6E9UQZztq4fceAfbLvzvMqCw0Pen8Mje0g5gLbwTwxZ7H15xsI/s?= =?Windows-1252?Q?PtRls0RYv+wQo1CaZZK4LQYxpRq+hDo7FJdd1hzOzf2zV/vs78Ih6J4p?= =?Windows-1252?Q?3Vuyg7LEt69soaUvq8emPOdVD9H7+n+uGDLJDo5t0kPmRRa7Bs20ZYTm?= =?Windows-1252?Q?TZKu5sRBct7jErmTV0yHXeQVo6TuT30kCf12JPFRSfQHpmkFsiIfGlKV?= =?Windows-1252?Q?psPHk75PFdGao6gBHfkjl0yKaeUCICQkIIJp3ij5e53CJZF9dkK23DH/?= =?Windows-1252?Q?TLJUu/Nt58Nda6B+7AJp8prLiMuJV3JMMysZW8qp0u3wCb/fs4fLAGtv?= =?Windows-1252?Q?VJwaPEUG5abPtewrNZiS02CN2cpBCg1jths7yeCi7PBZN7cibKtEHznf?= =?Windows-1252?Q?9qZHobhfu0zA+O1M55rGG6MKhyUTlReTGn48+B3x9VkEh5UMKNSLIkof?= =?Windows-1252?Q?29JOdDiw6ieK/jExnwsTWj+bzgAD6RQLR4X6+FW8s3v0CqAhOaqG6tT0?= =?Windows-1252?Q?5I9q7r4BRyJDHyK7Z0RYL1PA7ms4u0QkfDabzVRxoiHvTTAxAGQCxN4h?= =?Windows-1252?Q?V+tUVVvYTongFcBUPloEXKNzKLvxkNDvR52PlodL7B6ANSiHxuobKYMr?= =?Windows-1252?Q?Fno6bm9hp9N4+nitRXhO4PIdaNmqLRInpZp4XsjlXG+TD1j/bETKR+6Y?= X-OriginatorOrg: cornell.edu X-MS-Exchange-CrossTenant-Network-Message-Id: 61424eb6-5538-4183-e401-08d8fe8b1422 X-MS-Exchange-CrossTenant-AuthSource: BN7PR04MB4388.namprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 13 Apr 2021 14:47:36.6334 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 5d7e4366-1b9b-45cf-8e79-b14b27df46e1 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: 09UFwLCP1ivnjEnsr+nyZ8bnOG17Pf/eNYJ0AagvRBltcHFhsb+SOiusmkoBUD8e9UvEgSx2wcaC1KSpJjGc0A== X-MS-Exchange-Transport-CrossTenantHeadersStamped: BN8PR04MB5619 X-Spam-Status: No, score=1.3 required=5.0 tests=BAYES_00, DKIM_INVALID, DKIM_SIGNED, KAM_DMARC_STATUS, MSGID_FROM_MTA_HEADER, NICE_REPLY_A, SPF_HELO_PASS, SPF_PASS, TXREP, URIBL_SBL, URIBL_SBL_A autolearn=no autolearn_force=no version=3.4.2 X-Spam-Level: * X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) 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, 13 Apr 2021 14:47:40 -0000 On 4/13/2021 10:06 AM, sten.kristian.ivarsson@gmail.com wrote: > Hi Ken > >>>>>>>>>> Using AF_UNIX/SOCK_DGRAM with current version (3.2.0) seems >> to >>>>>>>>>> drop messages or at least they are not received in the same >>>>>>>>>> order they are sent >>>>>> >>>>>> [snip] >>>>>> >>>>>>> Thanks for the test case. I can confirm the problem. I'm not >>>>>>> familiar enough with the current AF_UNIX implementation to debug >>>>>>> this easily. I'd rather spend my time on the new implementation >>>>>>> (on the topic/af_unix branch). It turns out that your test case >>>>>>> fails there too, but in a completely different way, due to a bug >>>>>>> in sendto for datagrams. I'll see if I can fix that bug and then try again. >>>>>>> >>>>>>> Ken >>>>>> >>>>>> Ok, too bad it wasn't our own code base but good that the "mystery" >>>>>> is verified >>>>>> >>>>>> I finally succeed to build topic/af_unix (after finding out what >>>>>> version of zlib was needed), but not with -D__WITH_AF_UNIX to >>>>>> CXXFLAGS though and thus I haven’t tested it yet >>>>>> >>>>>> Is it sufficient to add the define to the "main" Makefile or do you >>>>>> have to add it to all the Makefile:s ? I guess I can find out >>>>>> though >>>>> >>>>> I do it on the configure line, like this: >>>>> >>>>> ../af_unix/configure CXXFLAGS="-g -O0 -D__WITH_AF_UNIX" -- >> prefix=... >>>>> >>>>>> Is topic/af_unix fairly up to date with master branch ? >>>>> >>>>> Yes, I periodically cherry-pick commits from master to topic/af_unix. >>>>> I'lldo that again right now. >>>>> >>>>>> Either way, I'll be glad to help out testing topic/af_unix >>>>> >>>>> Thanks! >>>> >>>> I've now pushed a fix for that sendto bug, and your test case runs >>>> without error on the topic/af_unix branch. >>> >>> It seems like the test-case do work now with topic/af_unix in blocking >>> mode, but when using non-blocking (with MSG_DONTWAIT) there are >> some >>> issues I think >>> >>> 1. When the queue is empty with non-blocking recv(), errno is set to >>> EPIPE but I think it should be EAGAIN (or maybe the pipe is getting >>> broken for real of some reason ?) >>> >>> 2. When using non-blocking recv() and no message is written at all, it >>> seems like recv() blocks forever >>> >>> 3. Using non-blocking recv() where the "client" does send less than >>> "count" messages, sometimes recv() blocks forever (as well) >>> >>> >>> My naïve analysis of this is that for the first issue (if any) the >>> wrong errno is set and for the second issue it blocks if no sendto() >>> is done after the first recv(), i.e. nothing kicks the "reader thread" >>> in the butt to realise the queue is empty. It is not super clear >>> though what POSIX says about creating blocking descriptors and then >>> using non-blocking-flags with recv(), but this works in Linux any way >> >> The explanation is actually much simpler. In the recv code where a bound >> datagram socket waits for a remote socket to connect to the pipe, I simply >> forget to handle MSG_DONTWAIT. I've pushed a fix. Please retest. >> >> I should add that in all my work so far on the topic/af_unix branch, I've >> thought mainly about stream sockets. So there may still be things remaining >> to be implemented for the datagram case. > > I finally got some time to test topic/af_unix in our "real" cygwin-application (casual) and unfortunately very few of our unittests pass > > The symptoms are that there's unexpected eternal blocking, sometimes there's unexpected EADDRNOTAVAIL, sometimes it looks like some memory corruption (and core-dumps) > > Of course the memory corruption etc could be our self and the core-dumps might be because of uncaught exceptions > > Needles to say is that all unittests pass on Linux, but of course cygwin-topic/af_unix could act according to POSIX-standard and the behaviour could be due to our own misinterpretation of how POSIX works More likely it's due to bugs in the topic/af_unix branch. This is still very much a work in progress. > I will try to narrow down the quite complex logic and reproduce the problems That would be ideal. > If you of some reason wanna try it with casual, I'd be glad to help you out (it should be easier now that last time (but there might be some documentation missing for Cygwin still)) > > https://bitbucket.org/casualcore/ I'm going on vacation in a few days, but I might do this when I get back. Thanks for your testing. Ken