www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/2017/12/29/10:37:43

X-Authentication-Warning: delorie.com: mail set sender to djgpp-bounces using -f
X-Recipient: djgpp AT delorie DOT com
Subject: Re: valloc() returns NULL for larger requests, but malloc works fine
To: djgpp AT delorie DOT com
References: <3459b672-8f4d-9840-5a01-246db011ed06 AT assembler DOT cz>
From: "Andris Pavenis (andris DOT pavenis AT iki DOT fi) [via djgpp AT delorie DOT com]" <djgpp AT delorie DOT com>
Message-ID: <6a051ffc-c379-8b88-76ed-26e938107c68@iki.fi>
Date: Fri, 29 Dec 2017 17:37:26 +0200
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101
Thunderbird/52.5.2
MIME-Version: 1.0
In-Reply-To: <3459b672-8f4d-9840-5a01-246db011ed06@assembler.cz>
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 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