#1681 msys can't malloc memory biger than 268169196

MSYS
closed
Cesar Strauss
MSYS (75)
works-for-me
Unreproducible
2013-01-21
2012-12-01
SquallATF
No

here is the test code

#include <stdio.h>
#include <stdlib.h>

int main()
{
void *okmem = malloc(1024*1024*256 - 1024*260 -20); //ok size 268169196
if(okmem) {
printf("malloc ok\n");
}
void *failedmem = malloc(1024*1024*256 - 1024*260 -19); //failed size 268169197
if(!okmem) {
printf("malloc failed\n");
}
return 0;
}

Discussion

  • SquallATF
    SquallATF
    2012-12-01

    so that when mingw link large program may failed.

     
  • Earnie Boyd
    Earnie Boyd
    2012-12-01

    • assigned_to: nobody --> cstrauss
     
  • Earnie Boyd
    Earnie Boyd
    2012-12-01

    @squallatf: This has nothing to do with linking large programs. Please use the mingw-users@lists.sourceforge.net list to discuss your issue and not this ticket.

     
  • SquallATF
    SquallATF
    2012-12-02

    I'm sorry because too much time and I remember correctly.
    The right is i use msys gcc complie subversion. I get this error

    cc1.exe: out of memory allocation 172600 bytes after a total of 268120064 bytes

    So I debug the msysCore then found in source\winsup\cygwin\heap.cc at line 120

    commitbytes = pround (newtop - (char *) cygheap->heaptop);
    if (VirtualAlloc(cygheap->heaptop, commitbytes, MEM_COMMIT, PAGE_READWRITE) != NULL)
    goto good;

    the VirtualAlloc failed.
    If too large source code to compile will appear this error

     
  • Earnie Boyd
    Earnie Boyd
    2012-12-02

    Okay, then I'll leave it to Cesar to figure out a fix.

     
  • Earnie Boyd
    Earnie Boyd
    2013-01-08

    Ping, Cesar, any comment on this issue?

     
  • Cesar Strauss
    Cesar Strauss
    2013-01-09

    I can't reproduce it.

    $ gcc -o bug.exe bug3591569.c

    $ ./bug.exe
    malloc ok

    OS: Windows 7 Home Premium N (64-bit)
    MSYS runtime: 1.0.18
    gcc version 3.4.4 (msys special)

     
  • Earnie Boyd
    Earnie Boyd
    2013-01-09

    • milestone: --> Unreproducible
    • status: open --> closed-works-for-me
     
  • Earnie Boyd
    Earnie Boyd
    2013-01-21

    • status: closed-works-for-me --> closed
    • resolution: --> works-for-me
    • category: --> Unreproducible
    • milestone: Unreproducible --> MSYS