* Makefile.in (MALLOC_OFILES): Always fill in with correct malloc object.

* configure.in: Fill in MALLOC_OFILES with either debugging or regular malloc.
* configure: Regenerate.
* dlmalloc.c: Make various fruitless changes to attempt to get to work.
* dlmalloc.h: Ditto.
* malloc.cc (free): Check malloc pool when debugging.
* path.cc (win32_device_name): Eliminate compiler warning.
* sigproc.cc (sig_dispatch_pending): Remove use of was_pending.  Let
thisframe.call_signal_handler decide if handler should be called rather than
using bogus was_pending check.
* exceptions.cc (interrupt_setup): Remove accidentally checked in debugging
code.
* heap.cc (sbrk): Save rounded addess in user_heap_max.
This commit is contained in:
Christopher Faylor 2003-08-31 18:26:58 +00:00
parent 110a4b87df
commit f8e2f358c4
10 changed files with 78 additions and 72 deletions

View File

@ -1,3 +1,27 @@
2003-08-31 Christopher Faylor <cgf@redhat.com>
* Makefile.in (MALLOC_OFILES): Always fill in with correct malloc
object.
* configure.in: Fill in MALLOC_OFILES with either debugging or regular
malloc.
* configure: Regenerate.
* dlmalloc.c: Make various fruitless changes to attempt to get to work.
* dlmalloc.h: Ditto.
* malloc.cc (free): Check malloc pool when debugging.
* path.cc (win32_device_name): Eliminate compiler warning.
* sigproc.cc (sig_dispatch_pending): Remove use of was_pending. Let
thisframe.call_signal_handler decide if handler should be called rather
than using bogus was_pending check.
* exceptions.cc (interrupt_setup): Remove accidentally checked in
debugging code.
2003-08-30 Christopher Faylor <cgf@redhat.com>
* heap.cc (sbrk): Save rounded addess in user_heap_max.
2003-08-30 Christopher Faylor <cgf@redhat.com> 2003-08-30 Christopher Faylor <cgf@redhat.com>
* sigproc.cc (sig_dispatch_pending): Remove explicit call to * sigproc.cc (sig_dispatch_pending): Remove explicit call to

View File

@ -152,7 +152,7 @@ DLL_OFILES:=assert.o autoload.o cxx.o cygheap.o cygthread.o dcrt0.o debug.o \
fhandler_socket.o fhandler_tape.o fhandler_termios.o \ fhandler_socket.o fhandler_tape.o fhandler_termios.o \
fhandler_tty.o fhandler_virtual.o fhandler_windows.o \ fhandler_tty.o fhandler_virtual.o fhandler_windows.o \
fhandler_zero.o fnmatch.o fork.o glob.o grp.o heap.o init.o ioctl.o \ fhandler_zero.o fnmatch.o fork.o glob.o grp.o heap.o init.o ioctl.o \
ipc.o localtime.o malloc.o malloc_wrapper.o miscfuncs.o mmap.o msg.o \ ipc.o localtime.o malloc_wrapper.o miscfuncs.o mmap.o msg.o \
net.o netdb.o ntea.o passwd.o path.o pinfo.o pipe.o poll.o pthread.o \ net.o netdb.o ntea.o passwd.o path.o pinfo.o pipe.o poll.o pthread.o \
regcomp.o regerror.o regexec.o regfree.o registry.o resource.o \ regcomp.o regerror.o regexec.o regfree.o registry.o resource.o \
scandir.o sched.o sec_acl.o sec_helper.o security.o select.o sem.o \ scandir.o sched.o sec_acl.o sec_helper.o security.o select.o sem.o \

View File

@ -1916,7 +1916,7 @@ esac
fi fi
MALLOC_OFILES= MALLOC_OFILES=malloc.o
# Check whether --enable-malloc-debugging or --disable-malloc-debugging was given. # Check whether --enable-malloc-debugging or --disable-malloc-debugging was given.
if test "${enable_malloc_debugging+set}" = set; then if test "${enable_malloc_debugging+set}" = set; then
enableval="$enable_malloc_debugging" enableval="$enable_malloc_debugging"

View File

@ -145,7 +145,7 @@ no) LIBSERVER=;;
esac esac
]) ])
MALLOC_OFILES= MALLOC_OFILES=malloc.o
AC_ARG_ENABLE(malloc-debugging, AC_ARG_ENABLE(malloc-debugging,
[ --enable-malloc-debugging Build a cygwin DLL with heap sanity checking (this is very slow, use only if you have heap corruption problems)], [ --enable-malloc-debugging Build a cygwin DLL with heap sanity checking (this is very slow, use only if you have heap corruption problems)],
[case "${enableval}" in [case "${enableval}" in

View File

@ -28,6 +28,21 @@
* malloc_usable_size(P) is equivalent to realloc(P, malloc_usable_size(P)) * malloc_usable_size(P) is equivalent to realloc(P, malloc_usable_size(P))
* *
* $Log$ * $Log$
* Revision 1.6 2003/08/31 18:26:58 cgf
* * Makefile.in (MALLOC_OFILES): Always fill in with correct malloc object.
* * configure.in: Fill in MALLOC_OFILES with either debugging or regular malloc.
* * configure: Regenerate.
* * dlmalloc.c: Make various fruitless changes to attempt to get to work.
* * dlmalloc.h: Ditto.
* * malloc.cc (free): Check malloc pool when debugging.
* * path.cc (win32_device_name): Eliminate compiler warning.
* * sigproc.cc (sig_dispatch_pending): Remove use of was_pending. Let
* thisframe.call_signal_handler decide if handler should be called rather than
* using bogus was_pending check.
* * exceptions.cc (interrupt_setup): Remove accidentally checked in debugging
* code.
* * heap.cc (sbrk): Save rounded addess in user_heap_max.
*
* Revision 1.5 2001/10/03 03:49:25 cgf * Revision 1.5 2001/10/03 03:49:25 cgf
* * cygheap.cc (cfree): Remove malloc debugging probe. * * cygheap.cc (cfree): Remove malloc debugging probe.
* * dlmalloc.c (errprint): Remove abort() call which causes interesting error * * dlmalloc.c (errprint): Remove abort() call which causes interesting error
@ -973,31 +988,31 @@ extern Void_t* sbrk();
#else #else
#ifndef cALLOc #ifndef cALLOc
#define cALLOc calloc #define cALLOc dlcalloc
#endif #endif
#ifndef fREe #ifndef fREe
#define fREe free #define fREe dlfree
#endif #endif
#ifndef mALLOc #ifndef mALLOc
#define mALLOc malloc #define mALLOc dlmalloc
#endif #endif
#ifndef mEMALIGn #ifndef mEMALIGn
#define mEMALIGn memalign #define mEMALIGn dlmemalign
#endif #endif
#ifndef rEALLOc #ifndef rEALLOc
#define rEALLOc realloc #define rEALLOc dlrealloc
#endif #endif
#ifndef vALLOc #ifndef vALLOc
#define vALLOc valloc #define vALLOc dlvalloc
#endif #endif
#ifndef pvALLOc #ifndef pvALLOc
#define pvALLOc pvalloc #define pvALLOc dlpvalloc
#endif #endif
#ifndef mALLINFo #ifndef mALLINFo
#define mALLINFo mallinfo #define mALLINFo dlmallinfo
#endif #endif
#ifndef mALLOPt #ifndef mALLOPt
#define mALLOPt mallopt #define mALLOPt dlmallopt
#endif #endif
#endif #endif
@ -1012,7 +1027,6 @@ extern Void_t* sbrk();
#define memalign(align, size) memalign_dbg(align, size, __FILE__, __LINE__) #define memalign(align, size) memalign_dbg(align, size, __FILE__, __LINE__)
#define valloc(size) valloc_dbg(size, __FILE__, __LINE__) #define valloc(size) valloc_dbg(size, __FILE__, __LINE__)
#define pvalloc(size) pvalloc_dbg(size, __FILE__, __LINE__) #define pvalloc(size) pvalloc_dbg(size, __FILE__, __LINE__)
#define cfree(p) cfree_dbg(p, __FILE__, __LINE__)
#define malloc_trim(pad) malloc_trim_dbg(pad, __FILE__, __LINE__) #define malloc_trim(pad) malloc_trim_dbg(pad, __FILE__, __LINE__)
#define malloc_usable_size(p) malloc_usable_size_dbg(p, __FILE__, __LINE__) #define malloc_usable_size(p) malloc_usable_size_dbg(p, __FILE__, __LINE__)
#define malloc_stats(void) malloc_stats_dbg(__FILE__, __LINE__) #define malloc_stats(void) malloc_stats_dbg(__FILE__, __LINE__)
@ -1027,7 +1041,6 @@ Void_t* calloc_dbg(size_t, size_t, const char *, int);
Void_t* memalign_dbg(size_t, size_t, const char *, int); Void_t* memalign_dbg(size_t, size_t, const char *, int);
Void_t* valloc_dbg(size_t, const char *, int); Void_t* valloc_dbg(size_t, const char *, int);
Void_t* pvalloc_dbg(size_t, const char *, int); Void_t* pvalloc_dbg(size_t, const char *, int);
void cfree_dbg(Void_t*, const char *, int);
int malloc_trim_dbg(size_t, const char *, int); int malloc_trim_dbg(size_t, const char *, int);
size_t malloc_usable_size_dbg(Void_t*, const char *, int); size_t malloc_usable_size_dbg(Void_t*, const char *, int);
void malloc_stats_dbg(const char *, int); void malloc_stats_dbg(const char *, int);
@ -1041,7 +1054,6 @@ Void_t* calloc_dbg();
Void_t* memalign_dbg(); Void_t* memalign_dbg();
Void_t* valloc_dbg(); Void_t* valloc_dbg();
Void_t* pvalloc_dbg(); Void_t* pvalloc_dbg();
void cfree_dbg();
int malloc_trim_dbg(); int malloc_trim_dbg();
size_t malloc_usable_size_dbg(); size_t malloc_usable_size_dbg();
void malloc_stats_dbg(); void malloc_stats_dbg();
@ -1060,7 +1072,6 @@ Void_t* cALLOc(size_t, size_t);
Void_t* mEMALIGn(size_t, size_t); Void_t* mEMALIGn(size_t, size_t);
Void_t* vALLOc(size_t); Void_t* vALLOc(size_t);
Void_t* pvALLOc(size_t); Void_t* pvALLOc(size_t);
void cfree(Void_t*);
int malloc_trim(size_t); int malloc_trim(size_t);
size_t malloc_usable_size(Void_t*); size_t malloc_usable_size(Void_t*);
void malloc_stats(void); void malloc_stats(void);
@ -1074,7 +1085,6 @@ Void_t* cALLOc();
Void_t* mEMALIGn(); Void_t* mEMALIGn();
Void_t* vALLOc(); Void_t* vALLOc();
Void_t* pvALLOc(); Void_t* pvALLOc();
void cfree();
int malloc_trim(); int malloc_trim();
size_t malloc_usable_size(); size_t malloc_usable_size();
void malloc_stats(); void malloc_stats();
@ -1102,7 +1112,6 @@ extern "C" {
#undef memalign #undef memalign
#undef valloc #undef valloc
#undef pvalloc #undef pvalloc
#undef cfree
#undef malloc_trim #undef malloc_trim
#undef malloc_usable_size #undef malloc_usable_size
#undef malloc_stats #undef malloc_stats
@ -1117,7 +1126,6 @@ Void_t* cALLOc(size_t, size_t);
Void_t* mEMALIGn(size_t, size_t); Void_t* mEMALIGn(size_t, size_t);
Void_t* vALLOc(size_t); Void_t* vALLOc(size_t);
Void_t* pvALLOc(size_t); Void_t* pvALLOc(size_t);
void cfree(Void_t*);
int malloc_trim(size_t); int malloc_trim(size_t);
size_t malloc_usable_size(Void_t*); size_t malloc_usable_size(Void_t*);
void malloc_stats(void); void malloc_stats(void);
@ -1131,7 +1139,6 @@ Void_t* cALLOc();
Void_t* mEMALIGn(); Void_t* mEMALIGn();
Void_t* vALLOc(); Void_t* vALLOc();
Void_t* pvALLOc(); Void_t* pvALLOc();
void cfree();
int malloc_trim(); int malloc_trim();
size_t malloc_usable_size(); size_t malloc_usable_size();
void malloc_stats(); void malloc_stats();
@ -1901,7 +1908,6 @@ static void malloc_err(const char *err, mchunkptr p)
#undef valloc #undef valloc
#undef pvalloc #undef pvalloc
#undef calloc #undef calloc
#undef cfree
#undef malloc_trim #undef malloc_trim
#undef malloc_usable_size #undef malloc_usable_size
#undef malloc_stats #undef malloc_stats
@ -1959,20 +1965,17 @@ Void_t* realloc_dbg(Void_t *oldmem, size_t bytes, dbgargs) {
skelr(Void_t*, realloc(oldmem, bytes)); skelr(Void_t*, realloc(oldmem, bytes));
} }
Void_t* memalign_dbg(size_t alignment, size_t bytes, dbgargs) { Void_t* memalign_dbg(size_t alignment, size_t bytes, dbgargs) {
skelr(Void_t*, memalign(alignment, bytes)); skelr(Void_t*, dlmemalign(alignment, bytes));
} }
Void_t* valloc_dbg(size_t bytes, dbgargs) { Void_t* valloc_dbg(size_t bytes, dbgargs) {
skelr(Void_t*, valloc(bytes)); skelr(Void_t*, dlvalloc(bytes));
} }
Void_t* pvalloc_dbg(size_t bytes, dbgargs) { Void_t* pvalloc_dbg(size_t bytes, dbgargs) {
skelr(Void_t*, pvalloc(bytes)); skelr(Void_t*, dlpvalloc(bytes));
} }
Void_t* calloc_dbg(size_t n, size_t elem_size, dbgargs) { Void_t* calloc_dbg(size_t n, size_t elem_size, dbgargs) {
skelr(Void_t*, calloc(n, elem_size)); skelr(Void_t*, calloc(n, elem_size));
} }
void cfree_dbg(Void_t *mem, dbgargs) {
skelv(cfree(mem));
}
int malloc_trim_dbg(size_t pad, dbgargs) { int malloc_trim_dbg(size_t pad, dbgargs) {
skelr(int, malloc_trim(pad)); skelr(int, malloc_trim(pad));
} }
@ -1983,10 +1986,10 @@ void malloc_stats_dbg(dbgargs) {
skelv(malloc_stats()); skelv(malloc_stats());
} }
int mallopt_dbg(int flag, int value, dbgargs) { int mallopt_dbg(int flag, int value, dbgargs) {
skelr(int, mallopt(flag, value)); skelr(int, dlmallopt(flag, value));
} }
struct mallinfo mallinfo_dbg(dbgargs) { struct mallinfo mallinfo_dbg(dbgargs) {
skelr(struct mallinfo, mallinfo()); skelr(struct mallinfo, dlmallinfo());
} }
#undef skel #undef skel
@ -3536,24 +3539,6 @@ Void_t* cALLOc(n, elem_size) size_t n; size_t elem_size;
} }
} }
/*
cfree just calls free. It is needed/defined on some systems
that pair it with calloc, presumably for odd historical reasons.
*/
#if !defined(INTERNAL_LINUX_C_LIB) || !defined(__ELF__)
#if __STD_C
void cfree(Void_t *mem)
#else
void cfree(mem) Void_t *mem;
#endif
{
free(mem);
}
#endif
/* /*
@ -3580,7 +3565,7 @@ void cfree(mem) Void_t *mem;
*/ */
#if __STD_C #if __STD_C
int malloc_trim(size_t pad) int dlmalloc_trim(size_t pad)
#else #else
int malloc_trim(pad) size_t pad; int malloc_trim(pad) size_t pad;
#endif #endif
@ -3653,7 +3638,7 @@ int malloc_trim(pad) size_t pad;
*/ */
#if __STD_C #if __STD_C
size_t malloc_usable_size(Void_t* mem) size_t dlmalloc_usable_size(Void_t* mem)
#else #else
size_t malloc_usable_size(mem) Void_t* mem; size_t malloc_usable_size(mem) Void_t* mem;
#endif #endif
@ -3745,7 +3730,7 @@ static void malloc_update_mallinfo(void)
*/ */
void malloc_stats(void) void dlmalloc_stats(void)
{ {
malloc_update_mallinfo(); malloc_update_mallinfo();
fprintf(stderr, "max system bytes = %10u\n", fprintf(stderr, "max system bytes = %10u\n",

View File

@ -8,7 +8,7 @@
* *
* bbclabel: autogenerated * bbclabel: autogenerated
*/ */
#define _INCLUDE_MALLOC_H_ 1
void malloc_outofmem(void (*)(void)); void malloc_outofmem(void (*)(void));
@ -41,19 +41,18 @@ struct mallinfo {
#ifdef MALLOC_DEBUG #ifdef MALLOC_DEBUG
#define malloc(size) malloc_dbg(size, __FILE__, __LINE__) #define dmalloc(size) malloc_dbg(size, __FILE__, __LINE__)
#define free(p) free_dbg(p, __FILE__, __LINE__) #define dfree(p) free_dbg(p, __FILE__, __LINE__)
#define realloc(p, size) realloc_dbg(p, size, __FILE__, __LINE__) #define drealloc(p, size) realloc_dbg(p, size, __FILE__, __LINE__)
#define calloc(n, size) calloc_dbg(n, size, __FILE__, __LINE__) #define dcalloc(n, size) calloc_dbg(n, size, __FILE__, __LINE__)
#define memalign(align, size) memalign_dbg(align, size, __FILE__, __LINE__) #define dmemalign(align, size) memalign_dbg(align, size, __FILE__, __LINE__)
#define valloc(size) valloc_dbg(size, __FILE__, __LINE__) #define dvalloc(size) valloc_dbg(size, __FILE__, __LINE__)
#define pvalloc(size) pvalloc_dbg(size, __FILE__, __LINE__) #define dpvalloc(size) pvalloc_dbg(size, __FILE__, __LINE__)
#define cfree(p) cfree_dbg(p, __FILE__, __LINE__) #define dmalloc_trim(pad) malloc_trim_dbg(pad, __FILE__, __LINE__)
#define malloc_trim(pad) malloc_trim_dbg(pad, __FILE__, __LINE__) #define dmalloc_usable_size(p) malloc_usable_size_dbg(p, __FILE__, __LINE__)
#define malloc_usable_size(p) malloc_usable_size_dbg(p, __FILE__, __LINE__) #define dmalloc_stats() malloc_stats_dbg(__FILE__, __LINE__)
#define malloc_stats() malloc_stats_dbg(__FILE__, __LINE__) #define dmallopt(flag, val) mallopt_dbg(flag, val, __FILE__, __LINE__)
#define mallopt(flag, val) mallopt_dbg(flag, val, __FILE__, __LINE__) #define dmallinfo() mallinfo_dbg(__FILE__, __LINE__)
#define mallinfo() mallinfo_dbg(__FILE__, __LINE__)
#ifdef __cplusplus #ifdef __cplusplus
@ -66,7 +65,6 @@ void* calloc_dbg(size_t, size_t, const char *, int);
void* memalign_dbg(size_t, size_t, const char *, int); void* memalign_dbg(size_t, size_t, const char *, int);
void* valloc_dbg(size_t, const char *, int); void* valloc_dbg(size_t, const char *, int);
void* pvalloc_dbg(size_t, const char *, int); void* pvalloc_dbg(size_t, const char *, int);
void cfree_dbg(void*, const char *, int);
int malloc_trim_dbg(size_t, const char *, int); int malloc_trim_dbg(size_t, const char *, int);
size_t malloc_usable_size_dbg(void*, const char *, int); size_t malloc_usable_size_dbg(void*, const char *, int);
void malloc_stats_dbg(const char *, int); void malloc_stats_dbg(const char *, int);
@ -87,7 +85,6 @@ void* calloc(size_t, size_t);
void* memalign(size_t, size_t); void* memalign(size_t, size_t);
void* valloc(size_t); void* valloc(size_t);
void* pvalloc(size_t); void* pvalloc(size_t);
void cfree(void*);
int malloc_trim(size_t); int malloc_trim(size_t);
size_t malloc_usable_size(void*); size_t malloc_usable_size(void*);
void malloc_stats(void); void malloc_stats(void);

View File

@ -688,7 +688,6 @@ interrupt_setup (int sig, void *handler, DWORD retaddr, DWORD *retaddr_on_stack,
{ {
sigsave.retaddr = retaddr; sigsave.retaddr = retaddr;
sigsave.retaddr_on_stack = retaddr_on_stack; sigsave.retaddr_on_stack = retaddr_on_stack;
small_printf ("retaddr_on_stack %p\n", retaddr_on_stack);
/* FIXME: Not multi-thread aware */ /* FIXME: Not multi-thread aware */
sigsave.oldmask = myself->getsigmask (); sigsave.oldmask = myself->getsigmask ();
sigsave.newmask = sigsave.oldmask | siga.sa_mask | SIGTOMASK (sig); sigsave.newmask = sigsave.oldmask | siga.sa_mask | SIGTOMASK (sig);

View File

@ -3744,6 +3744,7 @@ void fREe(mem) Void_t* mem;
mchunkptr bck; /* misc temp for linking */ mchunkptr bck; /* misc temp for linking */
mchunkptr fwd; /* misc temp for linking */ mchunkptr fwd; /* misc temp for linking */
check_malloc_state();
/* free(0) has no effect */ /* free(0) has no effect */
if (mem != 0) { if (mem != 0) {
p = mem2chunk(mem); p = mem2chunk(mem);
@ -3878,6 +3879,7 @@ void fREe(mem) Void_t* mem;
#endif #endif
} }
} }
check_malloc_state();
} }
/* /*

View File

@ -1124,7 +1124,7 @@ win32_device_name (const char *src_path, char *win32_path,
case FH_SOCKET: case FH_SOCKET:
char *c; char *c;
strcpy (win32_path, src_path); strcpy (win32_path, src_path);
while (c = strchr (win32_path, '/')) while ((c = strchr (win32_path, '/')))
*c = '\\'; *c = '\\';
break; break;
case FH_RANDOM: case FH_RANDOM:

View File

@ -540,12 +540,11 @@ sig_dispatch_pending ()
sigframe thisframe (mainthread); sigframe thisframe (mainthread);
int was_pending = pending_signals;
#ifdef DEBUGGING #ifdef DEBUGGING
sigproc_printf ("pending_signals %d", was_pending); sigproc_printf ("pending_signals %d", pending_signals);
#endif #endif
if (!was_pending) if (!pending_signals)
#ifdef DEBUGGING #ifdef DEBUGGING
sigproc_printf ("no need to wake anything up"); sigproc_printf ("no need to wake anything up");
#else #else
@ -559,7 +558,7 @@ sig_dispatch_pending ()
#endif #endif
} }
return was_pending; return thisframe.call_signal_handler ();
} }
/* Message initialization. Called from dll_crt0_1 /* Message initialization. Called from dll_crt0_1