From: Ivan Maidanski Date: Sat, 17 Dec 2016 15:15:02 +0000 (+0300) Subject: Disable implicit multi-threaded mode for Win32 to avoid LOCK crash X-Git-Tag: v7.6.2~288 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=8bb919baf4708c358d45d0ce0180b479c74dc591;p=gc Disable implicit multi-threaded mode for Win32 to avoid LOCK crash (fix commit d5c6531) * include/private/gc_locks.h [GC_ALWAYS_MULTITHREADED] (GC_need_to_lock): Do not define to TRUE unless USE_PTHREAD_LOCKS or USE_SPIN_LOCK; issue #error otherwise (excluding CPPCHECK case) as PCR and Windows-based lock implementation requires it to be initialized first. * include/private/gc_locks.h [UNCOND_LOCK && !LOCK && LINT2] (LOCK, UNLOCK): Define (to UNCOND_[UN]LOCK) only if USE_PTHREAD_LOCKS. --- diff --git a/include/private/gc_locks.h b/include/private/gc_locks.h index 38c73507..8cc1b835 100644 --- a/include/private/gc_locks.h +++ b/include/private/gc_locks.h @@ -36,7 +36,7 @@ # include # include GC_EXTERN PCR_Th_ML GC_allocate_ml; -# if defined(CPPCHECK) +# if defined(CPPCHECK) # define DCL_LOCK_STATE /* empty */ # else # define DCL_LOCK_STATE \ @@ -192,9 +192,14 @@ # define EXIT_GC() GC_collecting = 0; GC_INNER void GC_lock(void); # endif /* GC_PTHREADS */ -# ifdef GC_ALWAYS_MULTITHREADED +# if defined(GC_ALWAYS_MULTITHREADED) \ + && (defined(USE_PTHREAD_LOCKS) || defined(USE_SPIN_LOCK)) # define GC_need_to_lock TRUE # else +# if defined(GC_ALWAYS_MULTITHREADED) && !defined(CPPCHECK) +# error Runtime initialization of GC lock is needed! +# endif +# undef GC_ALWAYS_MULTITHREADED GC_EXTERN GC_bool GC_need_to_lock; # endif @@ -211,7 +216,8 @@ # endif /* !THREADS */ #if defined(UNCOND_LOCK) && !defined(LOCK) -# if defined(LINT2) || defined(GC_ALWAYS_MULTITHREADED) +# if (defined(LINT2) && defined(USE_PTHREAD_LOCKS)) \ + || defined(GC_ALWAYS_MULTITHREADED) /* Instruct code analysis tools not to care about GC_need_to_lock */ /* influence to LOCK/UNLOCK semantic. */ # define LOCK() UNCOND_LOCK()