www.delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2022/10/20/04:24:01

X-Recipient: archive-cygwin AT delorie DOT com
X-Original-To: cygwin AT cygwin DOT com
Delivered-To: cygwin AT cygwin DOT com
DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org A0EE53851C25
Authentication-Results: sourceware.org;
dmarc=none (p=none dis=none) header.from=tarides.com
Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=tarides.com
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
d=tarides-com.20210112.gappssmtp.com; s=20210112;
h=cc:to:subject:message-id:date:from:in-reply-to:references
:mime-version:from:to:cc:subject:date:message-id:reply-to;
bh=YETfLDaD1EeC/YXuZ3E8gN/mKKqFiToIPKYMp2cc4ng=;
b=V5S5HEpFAPSmoopMWa7HI79NDjcLr+AsyOx2tQR7+izZzyAbnqjpZeMVmrmty4Xt1p
H2a5n3mbBsFPLwOHrGdO6mckK0qNAdmI1ffalk7dX1V/xzjIl3Psw7DXJYHAF2pIXHOn
iZJg7ZnZz8Y0OoAfLnEAip5YK1OuvOgbQBFdbzpoV5gPWMzJ+u3oVcLMoi0IofRGjcsb
6DdDx7Zhm04ja+83DY5BX6EWsDzVSkDVqkoROqPIxEjZ/T4fygUZPYyaCghsoiCtiMzq
ErPnBsA6b56S00nq3FnF68YZiJx/KH5k+aJGpYeRYTW9I2Xep/e9UcGMJWUdsDI6OQ9W
mbwg==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
d=1e100.net; s=20210112;
h=cc:to:subject:message-id:date:from:in-reply-to:references
:mime-version:x-gm-message-state:from:to:cc:subject:date:message-id
:reply-to;
bh=YETfLDaD1EeC/YXuZ3E8gN/mKKqFiToIPKYMp2cc4ng=;
b=JPg8Y9yjY3vbumpFhX4a2UHOX67ATY24rZerGnnPmo3pNNVj3KbFm3744m/rCgj1md
L+yRse30aHGSdoiOBqDpl13BronB6Yb6mAweTeEXLd3LmE6AS6qmJUfZdU6SnxRz6q+Q
/74KC5y/ok6ZJMLEzzxvNdEZKXYntDuxnBI0IsNNru3ztI5VI3w6eWP8GtFR5DyEpUjp
UNNelEPeSnD8Vj7CyM3erS1+2NF9wEErCzVs1QHBpMOYGmows0gFcXozleQvFZSrAbYP
vxiCoe4PeFyqIauIxWkEzOg5KdctRoaleEuSaAkLUCeu3lSy4qSF3Q1xyHpeL0JBpIKU
fJ7g==
X-Gm-Message-State: ACrzQf38gvoJNF+8I+L0nIjX1BO1bIbCaEHxjGsuAE3A7M494JvEvrY+
WMao5lJ0Xqae8kkfDrHGe6F8mKleWC4oINdHjHszBXAo+j8=
X-Google-Smtp-Source: AMsMyM5sYVE1NFOJV3RVZt2qIsph3aXQpWW1AnRWvVFjBJ+9koEA9UJ/qPw+pHSjiiUPoVYB4q3ixAo5SNQlJZlb2ZY=
X-Received: by 2002:a05:6214:5006:b0:4b4:9a51:f811 with SMTP id
jo6-20020a056214500600b004b49a51f811mr10099061qvb.44.1666254143932; Thu, 20
Oct 2022 01:22:23 -0700 (PDT)
MIME-Version: 1.0
References: <000001d8e2dd$51be37a0$f53aa6e0$@cl.cam.ac.uk>
<f4e9c183-a4b5-7c59-c608-9922beb76961 AT dronecode DOT org DOT uk>
In-Reply-To: <f4e9c183-a4b5-7c59-c608-9922beb76961@dronecode.org.uk>
From: David Allsopp <david AT tarides DOT com>
Date: Thu, 20 Oct 2022 09:22:53 +0100
Message-ID: <CAJQQdJhkJrzJaGVNnbQNqHSDeq1kaXLt5AOXCk3akszCjp=jLA@mail.gmail.com>
Subject: Re: Debugging malloc crash in gdb
To: Jon Turney <jon DOT turney AT dronecode DOT org DOT uk>
X-Spam-Status: No, score=-0.5 required=5.0 tests=BAYES_00, DKIM_SIGNED,
DKIM_VALID, JMQ_SPF_NEUTRAL, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS,
TXREP 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 AT cygwin DOT com
X-Mailman-Version: 2.1.29
List-Id: General Cygwin discussions and problem reports <cygwin.cygwin.com>
List-Archive: <https://cygwin.com/pipermail/cygwin/>
List-Post: <mailto:cygwin AT cygwin DOT com>
List-Help: <mailto:cygwin-request AT cygwin DOT com?subject=help>
List-Subscribe: <https://cygwin.com/mailman/listinfo/cygwin>,
<mailto:cygwin-request AT cygwin DOT com?subject=subscribe>
Cc: The Cygwin Mailing List <cygwin AT cygwin DOT com>
Sender: "Cygwin" <cygwin-bounces+archive-cygwin=delorie DOT com AT cygwin DOT com>

On Tue, 18 Oct 2022 at 20:09, Jon Turney wrote:
>
> On 18/10/2022 11:35, David Allsopp wrote:
> > I'm wondering if I may be able to have some pointers for debugging what
> > seems to be an unexpected interaction between mmap/mprotect/munmap and
> > malloc with the OCaml runtime.
> >
> > At the moment, I know that we crash in malloc, so my main question is how to
> > go further in gdb. I installed the cygwin-debuginfo package, but all I'm
> > getting is:
>
> Firstly, if the crash is inside the cygwin DLL, you must follow the
> advice in [1], and use 'set cygwin-exceptions on' to tell gdb to stop on
> an exception inside cygwin itself.
>
> [1] https://cygwin.com/faq.html#faq.programming.debugging-cygwin
>
>
> > /cygdrive/d/a/scallywag/gdb/gdb-11.2-1.x86_64/src/gdb-11.2/gdb/infrun.c:2550
> > : internal-error: void resume_1(gdb_signal): Assertion
> > `pc_in_thread_step_range (pc, tp)' failed.

I'm not sure now which combination of stepping directly into the
malloc call, adding set cygwin-exceptions on or switching to gdb 12.1,
but either way I was able to get to an invalid memory access in
mmap_alloc in malloc.cc. At this point, p was a pointer to the start
of the 256M block which had been passed to munmap.

What I then noticed from that is a bug in our code - the mmap'd region
was actually 256M+64K but the size passed to munmap was 256M... so the
munmap call was not releasing the entire block. Fixing that on the
OCaml side fixes the error completely - I don't know whether what we
were seeing before counts as a bug in Cygwin's allocator?

Many thanks!


David

-- 
Problem reports:      https://cygwin.com/problems.html
FAQ:                  https://cygwin.com/faq/
Documentation:        https://cygwin.com/docs.html
Unsubscribe info:     https://cygwin.com/ml/#unsubscribe-simple

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019