summaryrefslogtreecommitdiff
path: root/win32_threads.c
diff options
context:
space:
mode:
authorivmai <ivmai>2011-07-01 11:53:44 +0200
committerIvan Maidanski <ivmai@mail.ru>2011-07-26 19:07:00 +0200
commit463d083ff1404570a30cbf8f4d780d041598e9e6 (patch)
tree9b0224d07f1d154f8cbf8a814df31db7d19d16ae /win32_threads.c
parentcea7d64af0f72989c690b0b0b8655a5f2d7ab2ad (diff)
2011-07-01 Ivan Maidanski <ivmai@mail.ru>
* win32_threads.c (CHECK_LOOKUP_MY_THREAD): New macro definition. * win32_threads.c (GC_reset_finalizer_nested, GC_check_finalizer_nested, GC_unregister_my_thread, GC_do_blocking_inner, GC_call_with_gc_active, GC_init_parallel): Insert CHECK_LOOKUP_MY_THREAD before dereferencing thread descriptor pointer (to instruct a LINT-like tool that it is ok to dereference the pointer). * win32_threads.c (GC_get_next_stack): Assert plast_stack_min is non-NULL if current_min is not ADDR_LIMIT (for a LINT-like tool). * win32_threads.c (GC_init_parallel): Define and use "me" local variable. * cord/cordtest.c (test_basics): Test CORD_substr() result is non-NULL. * cord/cordtest.c (test_extras): Test fopen() result is non-NULL. * cord/cordtest.c (test_basics, test_extras, test_printf, main): Replace the K&R-style function definition with the ANSI C one. * cord/cordtest.c: Expand all tabs to spaces; remove trailing spaces at EOLn. * include/private/gc_priv.h (ABORT): Define as abort() when checking the code with a LINT-like tool (Win32 only). * tests/test.c (FAIL): Ditto. * tests/test.c (CHECH_GCLIB_VERSION): New macro (to check that the version of libgc.so used at runtime matches that at compile time). * tests/test.c (GC_COND_INIT): Use CHECH_GCLIB_VERSION. * tests/test.c (CHECK_OUT_OF_MEMORY): New macro (to test malloc result for out of memory). * tests/test.c (cons, small_cons, small_cons_uncollectable, gcj_cons, reverse_test_inner, mktree, alloc8bytes, typed_test, run_one_test): Use CHECK_OUT_OF_MEMORY.
Diffstat (limited to 'win32_threads.c')
-rw-r--r--win32_threads.c24
1 files changed, 19 insertions, 5 deletions
diff --git a/win32_threads.c b/win32_threads.c
index 47dc39c..0c84110 100644
--- a/win32_threads.c
+++ b/win32_threads.c
@@ -529,11 +529,19 @@ STATIC GC_thread GC_lookup_thread_inner(DWORD thread_id)
}
}
+#ifdef LINT2
+# define CHECK_LOOKUP_MY_THREAD(me) \
+ if (!(me)) ABORT("GC_lookup_thread_inner(GetCurrentThreadId) failed")
+#else
+# define CHECK_LOOKUP_MY_THREAD(me) /* empty */
+#endif
+
/* Called by GC_finalize() (in case of an allocation failure observed). */
/* GC_reset_finalizer_nested() is the same as in pthread_support.c. */
GC_INNER void GC_reset_finalizer_nested(void)
{
GC_thread me = GC_lookup_thread_inner(GetCurrentThreadId());
+ CHECK_LOOKUP_MY_THREAD(me);
me->finalizer_nested = 0;
}
@@ -546,7 +554,9 @@ GC_INNER void GC_reset_finalizer_nested(void)
GC_INNER unsigned char *GC_check_finalizer_nested(void)
{
GC_thread me = GC_lookup_thread_inner(GetCurrentThreadId());
- unsigned nesting_level = me->finalizer_nested;
+ unsigned nesting_level;
+ CHECK_LOOKUP_MY_THREAD(me);
+ nesting_level = me->finalizer_nested;
if (nesting_level) {
/* We are inside another GC_invoke_finalizers(). */
/* Skip some implicitly-called GC_invoke_finalizers() */
@@ -765,6 +775,7 @@ GC_API int GC_CALL GC_unregister_my_thread(void)
LOCK();
# if defined(THREAD_LOCAL_ALLOC) || defined(GC_PTHREADS)
me = GC_lookup_thread_inner(thread_id);
+ CHECK_LOOKUP_MY_THREAD(me);
GC_ASSERT(!KNOWN_FINISHED(me));
# endif
# if defined(THREAD_LOCAL_ALLOC)
@@ -800,6 +811,7 @@ GC_INNER void GC_do_blocking_inner(ptr_t data, void * context)
LOCK();
me = GC_lookup_thread_inner(thread_id);
+ CHECK_LOOKUP_MY_THREAD(me);
GC_ASSERT(me -> thread_blocked_sp == NULL);
# ifdef IA64
me -> backing_store_ptr = stack_ptr;
@@ -826,7 +838,7 @@ GC_API void * GC_CALL GC_call_with_gc_active(GC_fn_type fn,
LOCK(); /* This will block if the world is stopped. */
me = GC_lookup_thread_inner(GetCurrentThreadId());
-
+ CHECK_LOOKUP_MY_THREAD(me);
/* Adjust our stack base value (this could happen unless */
/* GC_get_stack_base() was used which returned GC_SUCCESS). */
GC_ASSERT(me -> stack_base != NULL);
@@ -1462,7 +1474,7 @@ GC_INNER void GC_get_next_stack(char *start, char *limit,
return;
}
- GC_ASSERT(current_min > start);
+ GC_ASSERT(current_min > start && plast_stack_min != NULL);
# ifdef MSWINCE
if (GC_dont_query_stack_min) {
*lo = GC_wince_evaluate_stack_min(current_min);
@@ -2633,6 +2645,7 @@ GC_INNER void GC_thr_init(void)
GC_INNER void GC_init_parallel(void)
{
# if defined(THREAD_LOCAL_ALLOC)
+ GC_thread me;
DCL_LOCK_STATE;
# endif
@@ -2651,8 +2664,9 @@ GC_INNER void GC_init_parallel(void)
/* Initialize thread local free lists if used. */
# if defined(THREAD_LOCAL_ALLOC)
LOCK();
- GC_init_thread_local(
- &GC_lookup_thread_inner(GetCurrentThreadId())->tlfs);
+ me = GC_lookup_thread_inner(GetCurrentThreadId());
+ CHECK_LOOKUP_MY_THREAD(me);
+ GC_init_thread_local(&me->tlfs);
UNLOCK();
# endif
}