Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.84_2) (envelope-from ) id 1d2ZmZ-0008BZ-4B for pgsql-hackers@arkaria.postgresql.org; Mon, 24 Apr 2017 08:55:43 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.84_2) (envelope-from ) id 1d2ZmY-00037H-E2 for pgsql-hackers@arkaria.postgresql.org; Mon, 24 Apr 2017 08:55:42 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1d2ZmX-00036I-1q for pgsql-hackers@postgresql.org; Mon, 24 Apr 2017 08:55:41 +0000 Received: from mail-wr0-x231.google.com ([2a00:1450:400c:c0c::231]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.84_2) (envelope-from ) id 1d2ZmT-0006B0-Dq for pgsql-hackers@postgresql.org; Mon, 24 Apr 2017 08:55:40 +0000 Received: by mail-wr0-x231.google.com with SMTP id l50so13605629wrc.3 for ; Mon, 24 Apr 2017 01:55:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=83TqSIlMCcRpLLP9idzSuLMNsBtJYBxOdpVz+bNSqUo=; b=LetnbWKvgWAgebntnSe0pV42wZwSCX3UTckHdkVwsaiKCRH52nlqMK4thwOQI9byTT OSG5A2Onia3halJkOjW9qeJ4V2ZF6FYbPo6EqevjyHUc4T3aTt4QCDesh4t6ng0qTS1v h8nPBmhW6agCjf1IZ0Fsszrrd06n5sjb07xjP80iNPIp9kNCsD8L54qR28qIXD9cO6M3 V0Pp5x7zQhdFtWH3KoooLaI0hXA6qtErUl02fvL8F4phFY87bv7VIyoz9pEYinLGm0WL 6II8kOcbysQGrSXG+ZK3bsXslfxhwlB1VB9X7iPWBTTN5EbcypEtkqXs+SIetYKHLmf+ ex8w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=83TqSIlMCcRpLLP9idzSuLMNsBtJYBxOdpVz+bNSqUo=; b=FG4ADSsEJl9/3NrYl3ky6M59HeNWNuS4gybdMham40TW40t27AuiUt0pZwWLUpF23j TtLmTe4RGo/vpwArz3hKF8HrW1etJVG5GNTRfboG3OEeXeBeFmfnjQLPBP/a4QNxpMjh 1yFsE0fuGRiBLRdeafGjISxYSkvSfv1y7mp3M6R9NC1f/CFHuRpa3zZvio5aXzf12HeB LjThWkvWN8HZC/MZQUFWUfTGBdf7zFJ6qfIcaDGbAx4isJ7ym9q+zlCN8piXLJQ8/gJN VbWdISWaoziaLhVzQO+TgqSVvB75OwYz99cT+zYZNcSKprcgBiv603jhOyRTNNX0HM4l IsxA== X-Gm-Message-State: AN3rC/6BGHmDVoCVWbYpKCQanoigsxFAZb6y8+43K+7ZpA6e7YtVMAJK iFig2VmQ2KBGzpyePvyeZ+eplBhc0w== X-Received: by 10.223.161.65 with SMTP id r1mr5561915wrr.114.1493024135210; Mon, 24 Apr 2017 01:55:35 -0700 (PDT) MIME-Version: 1.0 Received: by 10.28.228.69 with HTTP; Mon, 24 Apr 2017 01:55:34 -0700 (PDT) In-Reply-To: <20170420192500.gaagaaopc2kjmort@alap3.anarazel.de> References: <20170415210643.cdapwhwmbiwaqd6e@alap3.anarazel.de> <2829.1492290578@sss.pgh.pa.us> <20170415211810.vsing3muvqfcswqx@alap3.anarazel.de> <3667.1492291494@sss.pgh.pa.us> <20170415213017.co7gkjlbcy44zlmw@alap3.anarazel.de> <4180.1492292046@sss.pgh.pa.us> <6309.1492611331@sss.pgh.pa.us> <20170419153151.y5bfp4kdo377ycps@alap3.anarazel.de> <20170420192500.gaagaaopc2kjmort@alap3.anarazel.de> From: Amit Kapila Date: Mon, 24 Apr 2017 14:25:34 +0530 Message-ID: Subject: Re: OK, so culicidae is *still* broken To: Andres Freund Cc: Tom Lane , pgsql-hackers Content-Type: text/plain; charset=UTF-8 X-Pg-Spam-Score: -1.8 (-) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-hackers Precedence: bulk Sender: pgsql-hackers-owner@postgresql.org On Fri, Apr 21, 2017 at 12:55 AM, Andres Freund wrote: > On 2017-04-20 16:57:03 +0530, Amit Kapila wrote: >> On Wed, Apr 19, 2017 at 9:01 PM, Andres Freund wrote: >> > On 2017-04-19 10:15:31 -0400, Tom Lane wrote: >> >> Amit Kapila writes: >> >> > On Sun, Apr 16, 2017 at 3:04 AM, Tom Lane wrote: >> >> >> Obviously, any such fix would be a lot more likely to be reliable in >> >> >> 64-bit machines. There's probably not enough daylight to be sure of >> >> >> making it work in 32-bit Windows, so I suspect we'd need some retry >> >> >> logic anyway for that case. >> >> >> >> > Yeah, that kind of thing can work assuming we don't get conflicts too >> >> > often, but it could be possible that conflicts are not reported from >> >> > ASLR enabled environments because of commit 7f3e17b4. >> >> >> >> Right, but Andres' point is that we should make an effort to undo that >> >> hack and instead allow ASLR to happen. Not just because it's allegedly >> >> more secure, but because we may have no choice in future Windows versions. >> > >> > FWIW, I think it *also* might make us more secure, because addresses in >> > the postgres binary won't be predictable anymore. >> > >> >> Agreed. I have done some further study by using VMMap tool in Windows >> and it seems to me that all 64-bit processes use address range >> (0000000000010000 ~ 000007FFFFFE0000). I have attached two screen >> shots to show the address range (lower range and upper range). You >> need to refer the lower half of the window in attached screenshots. >> At this stage, I am not completely sure whether we can assume some >> address out of this range to use in MapViewOfFileEx. Let me know your >> thoughts. > > That seems like a fairly restricted range (good!), and squares with > memories of reading about this (can't find the reference anymore). Just > using something like 0x00000F0000000000 as the address might work > sufficiently well. What happens if you just hardcode that in the first > MapViewOfFileEx call, and change RandomizedBaseAddress="FALSE" in > src/tools/msvc/VCBuildProject.pm to true? > The server start generates an error: 2017-04-24 12:02:05.771 IST [8940] FATAL: could not create shared memory segment: error code 87 2017-04-24 12:02:05.771 IST [8940] DETAIL: Failed system call was MapViewOfFileEx. Error code 87 means "invalid parameter". Some googling [1] indicates such an error occurs if we pass the out-of-range address to MapViewOfFileEx. Another possible theory is that we must pass the address as multiple of the system's memory allocation granularity as that is expected by specs of MapViewOfFileEx. I can try doing that but I am not confident that this is the right approach because of below text mentioned in docs (msdn) of MapViewOfFileEx. "While it is possible to specify an address that is safe now (not used by the operating system), there is no guarantee that the address will remain safe over time. Therefore, it is better to let the operating system choose the address.". I have printed the addresses that system automatically picks for MapViewOfFileEx (3a20000, 3770000, 3520000, 3720000, 3730000) and they seem to be in a range which I have posted up thread for 64-bit processes. Another thing I have tried is to just start the server by setting RandomizedBaseAddress="TRUE". I have tried about 15-20 times but could not reproduce the problem related to shared memory attach. We have tried the same on one of my colleagues (Ashutosh Sharma) machine as well, there we could see that error once or twice out of many tries but couldn't get it consistently. I think if the chances of this problem to occur are so less, then probably the suggestion made by Tom to retry if we get collision doesn't sound bad. [1] - https://support.microsoft.com/en-us/help/125713/common-file-mapping-problems-and-platform-differences -- With Regards, Amit Kapila. EnterpriseDB: http://www.enterprisedb.com -- Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-hackers