From a88f5da5bf2e3a76859438477a152daed3e2dedc Mon Sep 17 00:00:00 2001 From: Ivan Maidanski Date: Mon, 10 Dec 2012 08:40:19 +0400 Subject: [PATCH] Remove abort on open log failure from GC_write (Win32) * misc.c (GC_write): Do not abort (unconditionally) if GC_CreateLogFile failed, return -1 (or, even, 0 if NO_DEBUGGING) instead; update comment (Win32 only). --- misc.c | 22 ++++++++++------------ 1 file changed, 10 insertions(+), 12 deletions(-) diff --git a/misc.c b/misc.c index aabda705..d22ed6ea 100644 --- a/misc.c +++ b/misc.c @@ -1345,8 +1345,7 @@ GC_API void GC_CALL GC_enable_incremental(void) { BOOL res; DWORD written; -# if (defined(THREADS) && defined(GC_ASSERTIONS)) \ - || !defined(GC_PRINT_VERBOSE_STATS) +# if defined(THREADS) && defined(GC_ASSERTIONS) static GC_bool inside_write = FALSE; /* to prevent infinite recursion at abort. */ if (inside_write) @@ -1362,18 +1361,17 @@ GC_API void GC_CALL GC_enable_incremental(void) ABORT("Assertion failure: GC_write called with write_disabled"); } # endif + if (GC_log == 0) { + GC_log = GC_CreateLogFile(); + } if (GC_log == INVALID_HANDLE_VALUE) { - IF_NEED_TO_LOCK(LeaveCriticalSection(&GC_write_cs)); + IF_NEED_TO_LOCK(LeaveCriticalSection(&GC_write_cs)); +# ifdef NO_DEBUGGING + /* Ignore open log failure (e.g., it might be caused by */ + /* read-only folder of the client application). */ + return 0; +# else return -1; - } else if (GC_log == 0) { - GC_log = GC_CreateLogFile(); - /* Ignore open log failure if the collector is built with */ - /* print_stats always set on. */ -# ifndef GC_PRINT_VERBOSE_STATS - if (GC_log == INVALID_HANDLE_VALUE) { - inside_write = TRUE; - ABORT("Open of log file failed"); - } # endif } res = WriteFile(GC_log, buf, (DWORD)len, &written, NULL); -- 2.50.1