delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/2019/06/20/17:38:14

X-Authentication-Warning: delorie.com: mail set sender to djgpp-bounces using -f
X-Recipient: djgpp AT delorie DOT com
X-Original-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
d=gmail.com; s=20161025;
h=subject:to:references:from:openpgp:autocrypt:message-id:date
:user-agent:mime-version:in-reply-to:content-language
:content-transfer-encoding;
bh=0sX6iB0E+f2w2Q17iWONyy0fMnb1tuMCa5Z543VIUdM=;
b=jzR7NHwuygSKfF8QocrnyAhek/XCkVWx02yEbX0ozkB1jZb4fnu5MVsX7Zl6h+8TnR
kB6LOwF9taMZW+U3lEftkZ2D9qSlAj5PNeRpE4WhvEjJlGfmrnujh+GKYfQrnOeEge74
W02aExGOGQw8hytDdh99hbb5KLrjZHh/kSCphzymERZwetdBN2kTuPxlcFLjZTiuYoSh
tY12L5UzIJ2q/QJXlszpDYK5Hj6EgXA2jgvV7/wJowf9iSVs4vGG9AV2ivfP2GUka3Ic
OT9IFHxB1wKY4MRSEOan+zVgJUmSzzwxPyMjhUeMEZC4IO78oYahTIoIZlx2SKx1H6hu
8weA==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
d=1e100.net; s=20161025;
h=x-gm-message-state:subject:to:references:from:openpgp:autocrypt
:message-id:date:user-agent:mime-version:in-reply-to
:content-language:content-transfer-encoding;
bh=0sX6iB0E+f2w2Q17iWONyy0fMnb1tuMCa5Z543VIUdM=;
b=b+jaBwp4cZIR+T/2EYqQW8wnZbna9gRQLZwjtwE1YJvz3NTYRXPSTiI+bR02Iy66y3
76iEaUTLYxlZA5bUdT9Jx0jTvYW4F32BgzhGfRFisArTErat687rUk8lkKcMqQHYuWZz
YeX1sKxhsBGHewQKD/bu9PO95wVzE76VQZt2oSCiOOcnc5xrSnGIZ/Bxr8hQJSKriiNg
f3pb9ibZNZoPqbdgNQnQgpu2jIZApl4lJOeQXB59wfVgDwVM4xl7YC0riJPlvvpox5KA
k8EqOPhKphlWeQ9Q1mf3zPVoxqWh+HxtGQf5pyJezvyXRATGJshxG/Viw5n258wMlW8q
DsWg==
X-Gm-Message-State: APjAAAWV/4wmoqGjLXNUEyPKnEuqc+9VAnJTG8Mu4bUCdwmU9MQmo9dT
iMY6O1mVxYOcb5qhRhk8lffmo3vV
X-Google-Smtp-Source: APXvYqx9YRDRL/hYAva55wnLJ/S6DJcQFSWeAuOzDMGdEzIctwSCMTTy9DSlw2EyXDbR2PtyKeiKFw==
X-Received: by 2002:a50:d751:: with SMTP id i17mr141808816edj.121.1561066468852;
Thu, 20 Jun 2019 14:34:28 -0700 (PDT)
Subject: Re: malloc() returns pointer to already allocated memory
To: djgpp AT delorie DOT com
References: <158e5d20-0a90-4beb-de48-da328379d8fb AT gmail DOT com>
<qe76u1$1kj8$1 AT gioia DOT aioe DOT org>
<f0b68226-f6f4-244a-6dd5-a8ecbabb584b AT gmail DOT com>
<qe79eb$1urs$1 AT gioia DOT aioe DOT org> <qe7ar9$52r$1 AT gioia DOT aioe DOT org>
<qe7avt$52r$2 AT gioia DOT aioe DOT org> <qe7bve$9ti$1 AT gioia DOT aioe DOT org>
<qe7f8g$oak$1 AT gioia DOT aioe DOT org>
<b035cc97-1261-e26e-2d3c-b3672928c9af AT gmail DOT com>
<qec3qv$1hdk$1 AT gioia DOT aioe DOT org>
<64786234-be30-3862-b2ee-133d2c49fb1a AT gmail DOT com>
<qefq2m$1o7d$1 AT gioia DOT aioe DOT org>
From: "J.W. Jagersma (jwjagersma AT gmail DOT com) [via djgpp AT delorie DOT com]" <djgpp AT delorie DOT com>
Openpgp: id=D1694EA4DA1338AF4905293BA5102F469FA45960
Autocrypt: addr=jwjagersma AT gmail DOT com; prefer-encrypt=mutual; keydata=
mJMEWlMYlBMJKyQDAwIIAQENBAMEORD9eiW30pI0XzJbuE7/4WF3ZyEOkpRgrmZnpTRmzXMW
z22N+2YrczEM+q+NzM/wn8XOVH4hZ7eSaUsLT86YLS+gF/F44IbRZVCHxdrL+qSQQ0SafwDM
Aaddx2azX+6MtlFO2B6oDbCHT7Nn5oQi3IgR+pgBzaCkfxyOnU1wjvO0JEouVy4gSmFnZXJz
bWEgPGp3amFnZXJzbWFAZ21haWwuY29tPojQBBMTCgA4FiEE0WlOpNoTOK9JBSk7pRAvRp+k
WWAFAlpTGJQCGwMFCwkIBwIGFQgJCgsCBBYCAwECHgECF4AACgkQpRAvRp+kWWA3xAH/WIBG
sLngyIrTsn5uKz4JygtlCfjMRRSwl3/UIaW96VvIM/wUyzHl+vlyLmuclOjAiTVia/Js03Ar
zB9iCHZQ0QH/W8cRwHjRNZRukU2IR8eqoGsl6hTUrrAAOKOVO04wrjO4jGDHg3Sw2GxBx7Md
mD0QRId/gFwR/1UWS0jBdSUWC7iXBFpTGJQSCSskAwMCCAEBDQQDBFipNF/RUEAer/hhT6yJ
5no1ZLAZgpypvWZ3xJSrBKmcDTaOmNKNRrw1dNtSZ6M6wYcBmtCq7uvR5iiGyK3nD+olwe7a
4WDkhEEvbmdAYl2LnBsYeyruoW+N+KiMalvf9SphDmBi2NwdSZ1IhnBpxlUns8jqlgZGvG1G
xE1sleq7AwEKCYi4BBgTCgAgFiEE0WlOpNoTOK9JBSk7pRAvRp+kWWAFAlpTGJQCGwwACgkQ
pRAvRp+kWWBnyAH+JLrW/cK2aVDvq2nxn471opBgHyExzMi0hvbuy8BjyEt+AfL0RNCFcdds
CQakIGDv5k69TAgOftECgASwv6CG5wH8D3jnksh6YvYMf0hCBlSfwJ5ehIeqQTj0m2410RgC
KWywqmfU1X5YVXgmuXatRNgV/ggXS2Q7GnSP/StQzlh3sQ==
Message-ID: <19ff3320-4068-663e-ca70-d3e4dc459ba7@gmail.com>
Date: Thu, 20 Jun 2019 23:33:12 +0200
User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:60.0) Gecko/20100101
Thunderbird/60.7.1
MIME-Version: 1.0
In-Reply-To: <qefq2m$1o7d$1@gioia.aioe.org>
Reply-To: djgpp AT delorie DOT com
Errors-To: nobody AT delorie DOT com
X-Mailing-List: djgpp AT delorie DOT com
X-Unsubscribes-To: listserv AT delorie DOT com

On 2019-06-20 13:21, Rod Pemberton wrote:
> On Thu, 20 Jun 2019 02:22:43 +0200
> "J.W. Jagersma (jwjagersma AT gmail DOT com) [via djgpp AT delorie DOT com]"
> <djgpp AT delorie DOT com> wrote:
> 
>> On 2019-06-19 03:43, Rod Pemberton wrote:
> 
>>> b) how did you notice this issue originally?
>>> c) is the "clobbering" actually causing corruption in your
>>> program?
>>
>> It is causing very obvious corruption, that's how I discovered it.
>> Variables changing for no reason. Then a pointer or some offset
>> changes and the next access triggers a page or GP fault.
> 
> Does DJGPP's symify tell you anything about the page fault or GP fault?

Not really, I can look up the fault locations in a disassembly and then 
manually work out where it occured. Besides I implemented my own 
exception handlers and backtrace so symify wouldn't know how to deal 
with that.

> Does a printf() placed nearby eliminate the issue? (memory allocation)

Doesn't eliminate it, but any code change (including adding printf/cout) 
tends to change the memory location where the corruption occurs.

> Are you accessing memory that hasn't been allocated? (buffer overflow)

As far as I'm aware, no. (and if I was, I would stop doing it :))
For the most part I'm using c++ constructs like std::vector and 
std::unique_ptr which are designed to prevent these sort of issues.

> Are you using any assembly? (register corruption) > Are you using any other "advanced" features of DJGPP like DPMI to
> allocate memory, nearptr's or farptr's, transfer buffer, etc?

There's a lot of that going on, and most of those features I implemented 
myself to be more in line with idiomatic c++ code. However I used those 
same routines in other programs and it doesn't cause any issues there.

- Raw text -


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