delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/2017/12/29/16:26:58

X-Authentication-Warning: delorie.com: mail set sender to djgpp-bounces using -f
X-Recipient: djgpp AT delorie DOT com
X-Virus-Scanned: Debian amavisd-new at medvecky.net
X-Spam-Flag: NO
X-Spam-Score: -2.823
X-Spam-Level:
X-Spam-Status: No, score=-2.823 tagged_above=-999 required=3.8
tests=[ALL_TRUSTED=-1, BAYES_00=-1.9, TW_CR=0.077] autolearn=ham
Subject: Re: valloc() returns NULL for larger requests, but malloc works fine
To: djgpp AT delorie DOT com, andrewwu DOT tw AT gmail DOT com
References: <3459b672-8f4d-9840-5a01-246db011ed06 AT assembler DOT cz>
<6a051ffc-c379-8b88-76ed-26e938107c68 AT iki DOT fi>
From: "Rudolf Marek (r DOT marek AT assembler DOT cz) [via djgpp AT delorie DOT com]" <djgpp AT delorie DOT com>
Message-ID: <baf20a8f-ce06-f95f-e042-f62f58aa4e51@assembler.cz>
Date: Fri, 29 Dec 2017 22:26:18 +0100
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101
Thunderbird/52.5.0
MIME-Version: 1.0
In-Reply-To: <6a051ffc-c379-8b88-76ed-26e938107c68@iki.fi>
X-MIME-Autoconverted: from quoted-printable to 8bit by delorie.com id vBTLQpam002081
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

Hi Andris,

Thanks for the pointers. I tried to recompile the libc with that patch you mentioned
and it fixes the issue.

For flashrom, I developed a workaround, so the users will not be affected.

Now, how to get the official DJGPP fixed?

Thanks
Rudolf

Dne 29.12.2017 v 16:37 Andris Pavenis (andris DOT pavenis AT iki DOT fi) [via djgpp AT delorie DOT com] napsal(a):
> 
> 
> On 29.12.2017 14:39, Rudolf Marek (r DOT marek AT assembler DOT cz) [via djgpp AT delorie DOT com] wrote:
>> Hi,
>>
>> I was testing the flashrom DOS port before new release, and it turns out
>> there is something wrong with the valloc(). It refuses to allocate larger
>> areas, but malloc with same size works fine. The very same code was working fine with the 2.04 from 2009.
> 
> 1) I tried cross-compiler under ArchLinux (my own versions I should sometime commit to aur.archlinux.org to update versions already there). No failures observed when I run cross-compiled exe file in Win 10 32-bit VM (the same I'm using for building native compiler packages for ftp.delorie.com)
> 
> 2) recompiled it Win 10 32-bit VM and observed similar behavior as described in report
> 
> ArchLinux build has additional probably related patch:
> https://aur.archlinux.org/cgit/aur.git/tree/nmemalign.patch?h=djgpp-djcrx
> 
> I kept the changes (except gcc version compatibility fixes which I replaced) in my new not yet submitted version
> 
> Andris
> 
>> I performed my experiment with following rpms installed:
>>
>> djcross-binutils-2.29.1-1ap.x86_64.rpm
>> djcross-gcc-7.2.0-1ap.x86_64.rpm
>> djcrx-2.05-5.x86_64.rpm
>>
>> #include <stdio.h>
>> #include <stdlib.h>
>> #include <malloc.h>
>>
>> int main(void)
>> {
>>     printf("VALLOC %lx\n", valloc(1024*1024)); /* Fails with 0 */
>>     printf("MALLOC %lx\n", malloc(1024)); /* Works fine */
>>     printf("MALLOC %lx\n", malloc(1024*1024)); /* Works fine */
>>     printf("VALLOC %lx\n", valloc(1024)); /* Fails with 0 */
>>     printf("MEMALIGN %lx\n", memalign(4096, 1024)); /* Fails with 0 */
>>     printf("MEMALIGN %lx\n", memalign(64, 1024)); /* Fails with 0 */
>>     printf("MEMALIGN %lx\n", memalign(32, 64)); /* Works fine */
>> }
>>
>> I suspect something went wrong with memalign() internally, as for larger allocations it does some advanced trickery.
>>
>> Thanks
>> Rudolf
>>
> 

- Raw text -


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