X-Recipient: archive-cygwin AT delorie DOT com DomainKey-Signature: a=rsa-sha1; c=nofws; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:mime-version:from:date:message-id:subject:to :content-type; q=dns; s=default; b=Llf+GFnX1R7GN4QbTSgjRIAdV5BAA 4405JYcN0/t7jv01Tlv47/8krUiMpunlBjQ3BWYmK72zxHgb/0Gf2trPrjdXRkYx 7V12Vkstyvv/FEaQhrcA8iv5n4Se8+qjRavsaYfSBidXVmWyY/Zyt9BXrfTm+ESx dwNXr/SX4k+7OE= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:mime-version:from:date:message-id:subject:to :content-type; s=default; bh=s7nYDzj0wENyC9vAvRKRYKKpF94=; b=S37 qv75h+W1dhKzH8GUpDOgsbhr7A97AiONv8Vju9hZOC9VtO8sny4EU+mr9XQ/X08w KD/Mne4vBZ8nUyXAEybI3dhONL0JwoaGrIfZdNG+4i5x+FvKWLCHxgENEKOQq+ni VZ6JyBSKo/p2b26PZCilJ392QDpQ3fOeb6PRkk5I= Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: cygwin-owner AT cygwin DOT com Mail-Followup-To: cygwin AT cygwin DOT com Delivered-To: mailing list cygwin AT cygwin DOT com Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-1.9 required=5.0 tests=BAYES_00,FREEMAIL_FROM,RCVD_IN_DNSWL_NONE,SPF_PASS autolearn=ham version=3.3.2 spammy=fear, madison, Madison, unusual X-HELO: mail-it1-f177.google.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:from:date:message-id:subject:to; bh=gnLlOAwuJ1beIDFQDR51/v/J3mjKEnTT6tXLAqOaZFI=; b=kPsjsKSBtn/r58hfE1IKZeaYXgz/qVlKkSQN1R+JpeaN+2gfzyYU8aGOeG3PALOdAE Wqg4Kev83R5I95ukzkEWYvMdI4DtdI6mbVGq61T3AdrmHwTA6rG4cNjin7VOK0Jo8x17 2E0Vfst1l1k8SumUZTwqV73tNp0arXoa9Utdn9Ry317Ht9yWlImpr0r3YZpEXfEWiXW+ sr7li6zh4n6Hg7rQjByke+Fdl2qOx58KQPcxVOqqoD9BnW421NnPyehn2p6zL2xaegHz K5qSX4FCBxtSkXR57irhZ6C9+v1HWnysFyyxOZxuUwMtAhKRg8bgPIWY9UkIeCBgdtJ5 HqBg== MIME-Version: 1.0 From: "E. Madison Bray" Date: Wed, 27 Feb 2019 16:38:10 +0100 Message-ID: Subject: Consider exposing mmap_is_attached_or_noreserve To: cygwin AT cygwin DOT com Content-Type: text/plain; charset="UTF-8" X-IsSubscribed: yes Hello, A very technical request regarding Cygwin internals: In mmap.c there is a function mmap_is_attached_or_noreserve(void *addr, size_t len) which is called from Cygwin's exception handler in the case of a STATUS_ACCESS_VIOLATION. This is called in case an access violation occurs in memory that was allocated with Cygwin's mmap() with the MAP_NORESERVE flag, and allows us to commit the relevant pages when they are accessed. After a successful call of mmap_is_attached_or_noreserve(), the Cygwin exception handler returns with ExceptionContinueExecution. Unfortunately, if the application happens to have a Vectored Continue Handler registered which happens to do something in the case of STATUS_ACCESS_VIOLATION (see [1]) there is no obvious way to tell if we're handling this sort of case. Normally this isn't too much of a problem: E.g. we could just check the address that caused the access violation and see if its status is now MEM_COMMIT (i.e. Cygwin ran its exception handler and all is good). However, due to the bug described in [1], if an exception occurs in code running on a sigaltstack, the Cygwin exception handler isn't run. This makes for a tricky to handle use case: What if some code in a signal handler function tries to access uncommitted memory in a MAP_NORESERVE mmap? It's probably an unusual, undesirable case, and I haven't personally encountered it *yet*, but I could imagine some cases where it might happen. In order to handle such a case it might be nice if mmap_is_attached_or_noreserve were able to be called by user code, perhaps as a new cygwin_internal(...) call. I'd happily provide a patch, but I fear this might be an X/Y problem that I'm not seeing. Thanks, Madison [1] https://cygwin.com/ml/cygwin/2018-05/msg00333.html -- Problem reports: http://cygwin.com/problems.html FAQ: http://cygwin.com/faq/ Documentation: http://cygwin.com/docs.html Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple