From 0f9cf7898b9b7c2ee495f546c770c376a64738eb Mon Sep 17 00:00:00 2001 From: Tim Janik Date: Fri, 29 Dec 2006 12:29:55 +0000 Subject: [PATCH] turned detection of too late g_thread_init() calls into a warning. this is Fri Dec 29 13:28:07 2006 Tim Janik * glib/gslice.c: turned detection of too late g_thread_init() calls into a warning. this is a temporary work-around for some head-room to fix affected programs, memory corruption still occours regardless. --- ChangeLog | 6 ++++++ glib/gslice.c | 18 ++++++++++++++---- 2 files changed, 20 insertions(+), 4 deletions(-) diff --git a/ChangeLog b/ChangeLog index ddaf5ad..9920bcb 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +Fri Dec 29 13:28:07 2006 Tim Janik + + * glib/gslice.c: turned detection of too late g_thread_init() calls + into a warning. this is a temporary work-around for some head-room + to fix affected programs, memory corruption still occours regardless. + 2006-12-29 Matthias Clasen * tests/gobject/Makefile.am: diff --git a/glib/gslice.c b/glib/gslice.c index 505020a..c9e1e81 100644 --- a/glib/gslice.c +++ b/glib/gslice.c @@ -42,6 +42,9 @@ #include #endif +#include /* fputs/fprintf */ + + /* the GSlice allocator is split up into 4 layers, roughly modelled after the slab * allocator and magazine extensions as outlined in: * + [Bonwick94] Jeff Bonwick, The slab allocator: An object-caching kernel @@ -370,8 +373,17 @@ _g_slice_thread_init_nomessage (void) { /* we may not use g_error() or friends here */ if (sys_page_size) - mem_error ("g_thread_init() must be called before GSlice is used, memory corrupted..."); - g_slice_init_nomessage(); + { + /* mem_error ("g_thread_init() must be called before GSlice is used, memory corrupted..."); */ + fputs ("\n***MEMORY-WARNING***: ", stderr); + const char *pname = g_get_prgname(); + fprintf (stderr, "%s[%u]: GSlice: ", pname ? pname : "", getpid()); + fputs ("g_thread_init() must be called before all other GLib functions; " + "memory corruption due to late invocation of g_thread_init() has been detected; " + "this program is likely to crash, leak or unexpectedly abort soon...\n", stderr); + } + if (!sys_page_size) + g_slice_init_nomessage(); private_thread_memory = g_private_new (private_thread_memory_cleanup); allocator->magazine_mutex = g_mutex_new(); allocator->slab_mutex = g_mutex_new(); @@ -1135,8 +1147,6 @@ allocator_memfree (gsize memsize, #endif } -#include - static void mem_error (const char *format, ...) -- 2.7.4