delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin-developers/1999/06/26/23:04:18

Mailing-List: contact cygwin-developers-help AT sourceware DOT cygnus DOT com; run by ezmlm
Sender: cygwin-developers-owner AT sourceware DOT cygnus DOT com
Delivered-To: mailing list cygwin-developers AT sourceware DOT cygnus DOT com
From: Chris Faylor <cgf AT cygnus DOT com>
Date: Sat, 26 Jun 1999 23:05:19 -0400
To: John Fortin <fortinj AT ibm DOT net>
Cc: chris AT ibm DOT net,
"cygwin-developers AT sourceware DOT cygnus DOT com" <cygwin-developers AT sourceware DOT cygnus DOT com>
Subject: Re: efence problems - answered
Message-ID: <19990626230519.A13628@cygnus.com>
References: <377594D4 DOT 3E910C8A AT ibm DOT net>
Mime-Version: 1.0
X-Mailer: Mutt 0.95.3i
In-Reply-To: <377594D4.3E910C8A@ibm.net>; from John Fortin on Sat, Jun 26, 1999 at 11:04:52PM -0400

Linking in an "alien" malloc into cygwin is going to be very tough.
I've got cygwin linked with a debugging malloc now and seem to have
located my problems.  Now I'm suffering from gcc problems.  I can't
even build cygwin right now.  Sigh.

-chris

On Sat, Jun 26, 1999 at 11:04:52PM -0400, John Fortin wrote:
>	I was messing around with efence because of the discussions in the
>developers list.  Here is what I have discovered...  All the following
>occurs during cygwin1.dll startup.  The program was a simple hello world
>program with a malloc(1000) thrown in.
>
>1) during DLL initialization, a call to malloc is made.  Since I am
>linked with efence, the efence malloc gets called.  In
>efence.c:initialize() a call to getenv() is made to find is there is an
>environment variable EF_ALIGNMENT.  
>
>Program received signal SIGSEGV, Segmentation fault.
>0x61006f92 in _findenv (name=0x401663 "EF_ALIGNMENT", offset=0x258fd70)
>    at /d/src/winsup/environ.cc:147
>147       return NULL;
>(gdb) where
>#0  0x61006f92 in _findenv (name=0x401663 "EF_ALIGNMENT",
>offset=0x258fd70)
>    at /d/src/winsup/environ.cc:147
>#1  0x61006fb7 in getenv (name=0x401663 "EF_ALIGNMENT")
>    at /d/src/winsup/environ.cc:161
>#2  0x4016e0 in initialize () at efence.c:326
>#3  0x402435 in malloc (size=16) at efence.c:892
>#4  0x6101da9e in malloc (size=16) at /d/src/winsup/malloc.cc:42
>#5  0x6101ddff in malloc_init () at /d/src/winsup/malloc.cc:156
>#6  0x6101bf9a in heap_init () at /d/src/winsup/heap.cc:46
>#7  0x610041d3 in dll_crt0_1 () at /d/src/winsup/dcrt0.cc:616
>#8  0x610045d7 in dll_crt0 (uptr=0x4040e0) at /d/src/winsup/dcrt0.cc:770
>#9  0x402b6a in cygwin_crt0 (f=0x40152c <main>) at
>/d/src/winsup/libccrt0.cc:82
>(gdb)
>
>However, It looks like the 'environ' variable which holds the
>environment is not inited yet.  Hence, a seg-fault.
>(The following is in environ.cc)
>
>(gdb) n
>137           len++;
>(gdb) n
>140       for (p = environ; *p; ++p)
>(gdb) p environ
>$1 = (char **) 0x0
>(gdb) p *p
>$2 = 0x258fe0c "\034_X\002j+@"
>(gdb) whatis p
>type = char **
>(gdb) whatis *p
>type = char *
>(gdb) p (short)(char *)p
>$3 = 16608
>(gdb) whatis p
>type = char **
>(gdb) n
>
>Program received signal SIGSEGV, Segmentation fault.
>0x61006f92 in _findenv (name=0x401663 "EF_ALIGNMENT", offset=0x258fd70)
>    at /d/src/winsup/environ.cc:147
>147       return NULL;
>
>I modified efence not to use the environment variables, and this
>behavior stopped.  Then the following occurred...
>
>
>2)  in efence.c:initialize() it calls page.c:Page_Create(). 
>Page_Create() calls mmap().
>
>(mmap.cc:175)   mmapped_areas = new map;
>     	 	if (mmapped_areas == 0)
>        	{
>        	  	set_errno (ENOMEM);
>          		syscall_printf ("-1 = mmap(): ENOMEM");
>          		return (caddr_t) -1;
>        	}
>    		
>
>mmap() uses the C++ new method for allocating memory.  However, when we
>look at the stack trace we see that 
>'new' eventually uses malloc(), which call efence.c:malloc which calls
>efence.c:initialize() which calls page.c:Page_Create() which calls
>mmap().........  This continues until a seg-fault occurs.  I don't know
>a solution for this one.
>
>Thanks,
>John Fortin
>
>(gdb) run
>The program being debugged has been started already.
>Start it from the beginning? (y or n) y
>Starting program: /e/efence/hello.exe
>GDI32.DLL (symbols previously loaded)
>USER32.DLL (symbols previously loaded)
>KERNEL32.DLL (symbols previously loaded)
>ADVAPI32.DLL (symbols previously loaded)
>CYGWIN1.DLL (symbols previously loaded)
>
>Program received signal SIGSEGV, Segmentation fault.
>write (fd=4198520, buf=0x59205c, cnt=0)
>    at /d/src/newlib/libc/syscalls/syswrite.c:11
>11      {
>(gdb) where
>#0  write (fd=4198520, buf=0x59205c, cnt=0)
>    at /d/src/newlib/libc/syscalls/syswrite.c:11
>#1  0x402465 in EF_Print (
>    pattern=0x401078 "\n  Electric Fence 2.2.0 Copyright (C) 1987-1999
>Bruce Per
>ens <bruce AT perens DOT com>\n") at print.c:182
>#2  0x40113d in initialize () at efence.c:297
>#3  0x401ead in malloc (size=12) at efence.c:892
>#4  0x6101da9e in malloc (size=12) at /d/src/winsup/malloc.cc:42
>#5  0x6105ffbb in new_eh_context ()
>#6  0x6106003d in eh_context_static ()
>#7  0x6105fffa in __get_eh_context ()
>#8  0x61060eb9 in __builtin_new (sz=12)
>#9  0x6101e324 in mmap (addr=0x0, len=1048576, prot=3, flags=34, fd=-1,
>off=0)
>    at /d/src/winsup/mmap.cc:175
>#10 0x401f8d in Page_Create (size=1048576) at page.c:71
>#11 0x40139c in initialize () at efence.c:395
>#12 0x401ead in malloc (size=12) at efence.c:892
>#13 0x6101da9e in malloc (size=12) at /d/src/winsup/malloc.cc:42
>#14 0x6105ffbb in new_eh_context ()
>#15 0x6106003d in eh_context_static ()
>#16 0x6105fffa in __get_eh_context ()
>#17 0x61060eb9 in __builtin_new (sz=12)
>#18 0x6101e324 in mmap (addr=0x0, len=1048576, prot=3, flags=34, fd=-1,
>off=0)
>    at /d/src/winsup/mmap.cc:175
>#19 0x401f8d in Page_Create (size=1048576) at page.c:71
>#20 0x40139c in initialize () at efence.c:395
>#21 0x401ead in malloc (size=12) at efence.c:892
>#22 0x6101da9e in malloc (size=12) at /d/src/winsup/malloc.cc:42
>#23 0x6105ffbb in new_eh_context ()
>#24 0x6106003d in eh_context_static ()
>#25 0x6105fffa in __get_eh_context ()
>#26 0x61060eb9 in __builtin_new (sz=12)
>#27 0x6101e324 in mmap (addr=0x0, len=1048576, prot=3, flags=34, fd=-1,
>off=0)
>    at /d/src/winsup/mmap.cc:175
>#28 0x401f8d in Page_Create (size=1048576) at page.c:71
>#29 0x40139c in initialize () at efence.c:395
>#30 0x401ead in malloc (size=12) at efence.c:892
>#31 0x6101da9e in malloc (size=12) at /d/src/winsup/malloc.cc:42
>#32 0x6105ffbb in new_eh_context ()
>#33 0x6106003d in eh_context_static ()
>#34 0x6105fffa in __get_eh_context ()
>#35 0x61060eb9 in __builtin_new (sz=12)
>#36 0x6101e324 in mmap (addr=0x0, len=1048576, prot=3, flags=34, fd=-1,
>off=0)
>    at /d/src/winsup/mmap.cc:175
>#37 0x401f8d in Page_Create (size=1048576) at page.c:71

- Raw text -


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