Subject: large memory allocation via new causes segmentation fault in G++ compiled programs
From: "Bruce Rosen" <[email-masked]>
To: <[email-masked]>
Cc: "Bruce Rosen"@delorie.com
Date: Mon, 7 Aug 2000 12:23:36 -0700

I'm running cygwin on a WINNT PIII machine with 785 meg of memory. The
program below compiles
without error both in g++ and MSVC6.0. The MSVC compile executable runs
correctly, but the
G++ compiled executable gives me a segmentation fault (returning 0 from new)
when over 128 meg
of memory is allocated.
 Is there some way to correct the error?  Here is the program:

int main()
{
char *p;
        // allocate 150,000,000 bytes > 128 Meg limit
        p = new char[150000000];
        p[50] = 'a';
}

And here are the g++ parameters:

 /bin/../lib/gcc-lib/i686-pc-cygwin/2.95.2/cpp.exe -lang-c -v -iprefix
/bin/../l
ib/gcc-lib/i686-pc-cygwin/2.95.2/ -D__GNUC__=2 -D__GNUC_MINOR__=95 -Di386 -D
_X86
=1 -D__STDC__=1 -D__stdcall=__attribute__((__stdcall__)) -D__cdecl=__attribu
te__
((__cdecl__)) -D__declspec(x)=__attribute__((x)) -D__i386__ -D_X86=1 -D__STD
C__=
1 -D__stdcall=__attribute__((__stdcall__)) -D__cdecl=__attribute__((__cdecl_
_))
-D__declspec(x)=__attribute__((x)) -D__i386 -Asystem(winnt) -Acpu(i386) -Ama
chin
e(i386) -remap -Acpu(i386) -Amachine(i386) -Di386 -D__i386 -D__i386__ -Di686
 -Dp
entiumpro -D__i686 -D__i686__ -D__pentiumpro -D__pentiumpro__ -D__CYGWIN32__
 -D_
_CYGWIN__ -Dunix -D_WIN32 -DWINNT --help help-dummy /tmp/ccgw0dun.i
GNU CPP version 2.95.2 19991024 (release-2) (80386, BSD syntax)

 /bin/../lib/gcc-lib/i686-pc-cygwin/2.95.2/collect2.exe -Bdynamic --help
/usr/li
b/gcc-lib/i686-pc-cygwin/2.95.2/../../../../i686-pc-cygwin/lib/crt0.o -L/bin
/../
lib/gcc-lib/i686-pc-cygwin/2.95.2 -L/bin/../lib/gcc-lib -L/usr/lib/gcc-lib/i
686-
pc-cygwin/2.95.2 -L/usr/lib/gcc-lib/i686-pc-cygwin/2.95.2/../../../../i686-p
c-cy
gwin/lib
/tmp/ccCJG2dS.o -lstdc++ -lgcc -lcygwin -luser32 -lkernel32 -ladvapi32
-lshell32 -lgcc

    Any help would be appreciated.
    thanks
    bruce
Here is the cygcheck output:

cygcheck

Cygnus Win95/NT Configuration Diagnostics
Current System Time: Mon Aug 07 12:19:10 2000

WinNT Ver 4.0 build 1381 Service Pack 4

Path:
        .
        /usr/local/bin
        /bin
        /WINNT/system32
        /WINNT
        /Program Files/Mt

SysDir: C:\WINNT\System32
WinDir: C:\WINNT

HOME = `/WINNT/Profiles/rosen/Desktop'
MAKE_MODE = `unix'
PWD = `/WINNT/Profiles/rosen/Desktop/cyg'
USER = `administrator'

Use `-r' to scan registry

a:  fd           N/A    N/A
c:  hd  NTFS    4000Mb  95% CP CS UN PA FC
d:  cd  CDFS     498Mb 100%    CS              TIPSTER_VOL_1
e:  hd  NTFS   10660Mb  19% CP CS UN PA FC
x:  net NTFS   16159Mb  73% CP CS UN PA FC

C:\\bin  /usr/bin  user    binmode
C:\\lib  /usr/lib  user    binmode
C:    /        user    binmode

Found: C:\bin\bash.exe
Found: \bin\bash.exe
Found: C:\bin\cat.exe
Found: \bin\cat.exe
Found: C:\bin\cpp.exe
Found: \bin\cpp.exe
Found: C:\bin\find.exe
Found: \bin\find.exe
Found: C:\bin\gcc.exe
Found: \bin\gcc.exe
Found: C:\bin\gdb.exe
Found: \bin\gdb.exe
Found: C:\bin\ld.exe
Found: \bin\ld.exe
Found: C:\bin\ls.exe
Found: \bin\ls.exe
Found: C:\bin\make.exe
Found: \bin\make.exe
Found: C:\bin\sh.exe
Found: \bin\sh.exe

   83k 2000/06/11 C:\bin\cygitcl30.dll
   35k 2000/06/11 C:\bin\cygitk30.dll
  402k 2000/06/11 C:\bin\cygtcl80.dll
    5k 2000/06/11 C:\bin\cygtclpip80.dll
   10k 2000/06/11 C:\bin\cygtclreg80.dll
 639k 2000/06/11 C:\bin\cygtk80.dll
 587k 2000/03/01 C:\bin\cygwin1.dll
   Cygwin DLL version info:
       dll major: 1001
       dll minor: 0
       dll epoch: 19
       dll bad signal mask: 19005
       dll old termios: 00005
       api major: 0
       api minor: 17
       shared data: 3
       dll identifier: cygwin1
       mount registry: 2
       cygnus registry name: Cygnus Solutions
       cygwin registry name: Cygwin
       program options name: Program Options
       cygwin mount registry name: mounts v2
       build date: Wed Mar 1 00:15:19 EST 2000
       snapshot date: 2000-02-29-23:55-EST
       shared id: cygwin1S3-2000-03-01 00:15:19

Bruce Rosen, Ph.D.
Chief Scientist, Oingo Inc
10474 Santa Monica Bl.
Los Angeles, CA 90025
Phone: (310) 446 8162
E-mail: [email-masked]
----------------------------------------------------------------------------
------------

The information contained in this email is Confidential, and is intended for
the recipient's review only. Any unauthorized review, use, disclosure or
distribution is not allowed. If you are not the intended recipient, please
contact the sender by email and destroy all copies of the original message.