delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp-workers/2026/09/03/13:45:55

DMARC-Filter: OpenDMARC Filter v1.4.2 delorie.com 683Hjse72388968
Authentication-Results: delorie.com; dmarc=none (p=none dis=none) header.from=delorie.com
Authentication-Results: delorie.com; spf=pass smtp.mailfrom=delorie.com
X-Authentication-Warning: delorie.com: mail set sender to djgpp-workers-bounces using -f
DMARC-Filter: OpenDMARC Filter v1.4.2 delorie.com 683Hjr0l2388947
Authentication-Results: delorie.com; dmarc=pass (p=none dis=none) header.from=gmail.com
Authentication-Results: delorie.com; spf=pass smtp.mailfrom=gmail.com
DKIM-Filter: OpenDKIM Filter v2.11.0 delorie.com 683Hjr0l2388947
Authentication-Results: delorie.com;
dkim=pass (2048-bit key, unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20251104 header.b=EZUKGDdk
X-Recipient: djgpp-workers AT delorie DOT com
X-Original-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
d=gmail.com; s=20251104; t=1788457551; x=1789062351; darn=delorie.com;
h=content-transfer-encoding:content-type:in-reply-to:from
:content-language:references:to:subject:user-agent:mime-version:date
:message-id:from:to:cc:subject:date:message-id:reply-to:content-type;
bh=PoHUErOypqPA8Se8q3qtB5ORsjzHlsu6mTKD8BnGJC8=;
b=EZUKGDdk+0CRSvunkf1aK4nNXEtW3RDYTjrYviZ6+wgM0yZdG0RLUHoVsl2RDWKSMp
d8CZbVUIZaQqdV50cW9y1A+wbioChiDxCcsv5XpHtG50+OVJ6CbgkbPa9SyKOiCppw/w
v297p1E4OZyCKEW+1kEjP3sJ0MOPlnjfInjNIX9RfH4JZ0G+vGBobZ/a9qV729sxlaBI
geZXTNEfnEp4wH6qicen70yWx99J+L+2t0jZKhyooHRzyX4JhWSw4jzCxLnO0pLy1kZl
vp/JMTpVGq2KcnGLyTjULzh8LQrU6fpA6f6FqUYmWPONK4l4lhVB1cVWY9Ec9Xa7pkhp
uHqw==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
d=1e100.net; s=20251104; t=1788457551; x=1789062351;
h=content-transfer-encoding:content-type:in-reply-to:from
:content-language:references:to:subject:user-agent:mime-version:date
:message-id:x-gm-gg:x-gm-message-state:from:to:cc:subject:date
:message-id:reply-to:content-type;
bh=PoHUErOypqPA8Se8q3qtB5ORsjzHlsu6mTKD8BnGJC8=;
b=SNxhcPYP7mcTmIgI8XGEpbMGlatMR6n6wjgroHJB0F3wepCS3nmetdyC+0i8O0pdsV
vYpi6q6jcSJENHWTNcMvRayJKPOEm+NqDp3gQpgRe4zYabA/7RYCFDIr0vUpkrFSkvzt
fCYb3Raqe/77IW3CEyVPjE0shtsUlrUAgHawFl0FRc8wZuuCo+IkWIK9dZ8sDkEumwaT
ha2Zvka7/esOYaiJixsP4Wkn2hDu7/KabgGPQvrMmYo/pvjajHfnTv+JghcIchxa4+GP
9CLmpa0Xevm8D55zuZIOzdfOyDF8x89UI5izSUjWS08PyiVkx44APk6QwGnyHKo8iI5v
Tv6g==
X-Gm-Message-State: AFuF++nJ32NTJrS8EjihW0sXqcMJ4r4j4+vukxy18eFZCe4NsPzk/5Sy
78eAUxJA/4As3ea5uBw5cMI4anCVTsNkrX/46PMRVtQZIzaYbEg0vaXMDWtKY05I
X-Gm-Gg: AYBFou2F+m7KiHKAS8er3uWpDVUJIjpTeLUR7IvYbnsPK398flvOamn+jgs95fVVbDi
1G6XtvYWAZbsNKvSMVbRDSpqrrV4V/YRUv0CvoGocfkEKvk2WdOZ0tca373y6hKioX/x4IIasoh
BbMkiafzarargpOY3s54ac9FUOa03YosnTH3iSgTLiq4KOoarXdRliteanH51cbb7R3zJEpk57W
eDUJpZ4ujnP8n5PsP1KmoUpSGrViCyKlnXCM327a2k1ne7pNfTW5UQ4BBjkOBuYctthJ8CgYFUg
zm6cRJDNT1fXgYA7vfReBpxkgPc0s8ZGeeex1RSTbmYpuR+1jQFrrI8XsAVXrIktX7vDdlje07Z
3WQFPMYRJRB2v6ps25FzMObveiuAQNUkg0MshgxleDn6ujkxji5iiJsBX/2yvNNdFH2q+kWK1Dh
odHOqyZ7N7L9TkIaQYSPa0lkYirGJ1zSkqWpyp2nn+/Egfi+pNgOaHvbJtVwVTLCrOMYgSsgQLG
5sUumuM/DbnUo9cW598I0NXgZv5e7j8G5SdCyAE+MzRC/OF6MQI
X-Received: by 2002:a05:620a:8386:b0:939:6d22:6fd with SMTP id af79cd13be357-939803712c1mr19829585a.18.1788457550717;
Thu, 03 Sep 2026 10:45:50 -0700 (PDT)
Message-ID: <73ea67bd-ae77-4338-8698-e755bee80959@gmail.com>
Date: Thu, 3 Sep 2026 13:45:48 -0400
MIME-Version: 1.0
User-Agent: Mozilla Thunderbird
Subject: Re: memalign broken (again)
To: djgpp-workers AT delorie DOT com
References: <xn1pbaxnji DOT fsf AT envy DOT delorie DOT com>
From: "Frank Sapone (emoaddict15 AT gmail DOT com) [via djgpp-workers AT delorie DOT com]" <djgpp-workers AT delorie DOT com>
In-Reply-To: <xn1pbaxnji.fsf@envy.delorie.com>
Reply-To: djgpp-workers AT delorie DOT com
Errors-To: nobody AT delorie DOT com
X-Mailing-List: djgpp-workers AT delorie DOT com
X-Unsubscribes-To: listserv AT delorie DOT com

On 9/3/2026 1:17 PM, DJ Delorie (dj AT delorie DOT com) [via 
djgpp-workers AT delorie DOT com] wrote:
> "Frank Sapone (emoaddict15 AT gmail DOT com) [via djgpp-workers AT delorie DOT com]"
> <djgpp-workers AT delorie DOT com> writes:
>>> @@ -141,7 +142,9 @@ void *nmemalign(size_t alignment, size_t size)
>>>                /* two or more chunks to release */
>>>                DBGPRTM("  Complex case, release multiple chunks");
>>>                DBGEOLN;
>>> -            nfree(PTR(__nmalloc_split(&m, alignment - misalign)));
>>> +            malign = (char *)(((ulong)minit + XTRA - 1) & ~(alignment - 1));
>>> +            m1 = MEMBLKp(malign);
>>> +            nfree(PTR(__nmalloc_split(&m, (ulong)m1 - (ulong)m)));
>>>                return nrealloc(PTR(m), size);
>>>             }
>>>          } /* alignment > ALIGN */
>> Bringing this up again.  I have had a small handful of complaints about
>> combinelo: memory fouled on some machines for my Quake DOS port.  This
>> was never tested and vetted, but the patch looks and sounds reasonable.
> I assume you *did* test it with your port?
>
> My thoughts after years of fixing glibc malloc bugs... ;-)
>
> If the minimum chunk size is 3 (2 overhead, 1 data), and you want to
> align to something more than 3 chunks, the worst case is the front-extra
> is slightly less than a chunk (2 units, in this case).  To fix that, you
> have to move the aligned pointer by an extra "alignment", making it
> 2+alignment past the original allocation.
>
> Example: alignment is 64, ALIGN is 8, size is 1024, and the returned
> pointer is 0xff8 (chunk at 0xff8 - 0x10 = 0xfe8)
>
> The next valid chunk after the above (if smallest split) would be
> 0x1000/0x1010 but 0x1010 is not sufficiently aligned.
>
> The next aligned address after that is 0x1040 (chunk 0x1030, so 0x1030/0x1040)
>
> So the needed adjustment would be 0x1030/0x1040 - 0xfe8/0xff8 = 0x48 (72).
>
> malign in the above would be (0xff8 + (16+64) - 1) & ~ 63 or 0x1040
> m1 would thus be 0x1040 - 0x10 = 0x1030.
>
> (note: I did a full analysis before I remembered that XTRA included
> "alignment" and was going to claim the patch was wrong, so my confidence
> in this new analysis is not 100% ;)

Hey DJ,

I admit I did NOT test it, yet.  I'd have to recompile the libc for this 
and never made time to do so.  For the users with the memory fouled 
errors I don't always hear back from them.  They just send me 
screenshots complaining about it on 486 machines (which are not 
appropriate for Quake 1... but...).  So who knows?

Frank

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2026   by DJ Delorie     Updated Sep 20 2026