summaryrefslogtreecommitdiff
path: root/pthread_support.c
diff options
context:
space:
mode:
authorIvan Maidanski <ivmai@mail.ru>2011-11-15 12:01:52 +0100
committerIvan Maidanski <ivmai@mail.ru>2011-11-15 12:52:00 +0100
commit1df91789635037bf316e824ff6e3354416c96c4d (patch)
tree85850889921659a64b36bc77f77a1bc3734c920c /pthread_support.c
parent5651cb612de85c8c84773da02213e8fe3a45754d (diff)
Implement precise value boundary check in GC_is_thread_tsd_valid
* pthread_support.c (GC_is_thread_tsd_valid): Check tsd more correctly using GC_thread and thread_local_freelists declarations; remove FIXME. * win32_threads.c (GC_is_thread_tsd_valid): Likewise.
Diffstat (limited to 'pthread_support.c')
-rw-r--r--pthread_support.c12
1 files changed, 6 insertions, 6 deletions
diff --git a/pthread_support.c b/pthread_support.c
index 38f4476..90af826 100644
--- a/pthread_support.c
+++ b/pthread_support.c
@@ -312,6 +312,7 @@ STATIC long GC_nprocs = 1;
# if defined(USE_CUSTOM_SPECIFIC)
void GC_check_tsd_marks(tsd *key);
# endif
+
/* Check that all thread-local free-lists are completely marked. */
/* Also check that thread-specific-data structures are marked. */
void GC_check_tls(void)
@@ -331,6 +332,7 @@ STATIC long GC_nprocs = 1;
# endif
}
# endif /* GC_ASSERTIONS */
+
#endif /* THREAD_LOCAL_ALLOC */
#ifdef PARALLEL_MARK
@@ -600,16 +602,14 @@ GC_INNER unsigned char *GC_check_finalizer_nested(void)
/* This is called from thread-local GC_malloc(). */
GC_bool GC_is_thread_tsd_valid(void *tsd)
{
- char *me;
+ GC_thread me;
DCL_LOCK_STATE;
LOCK();
- me = (char *)GC_lookup_thread(pthread_self());
+ me = GC_lookup_thread(pthread_self());
UNLOCK();
- /* FIXME: We can check tsd more correctly (since now we have access */
- /* to the right declarations). This old algorithm (moved from */
- /* thread_local_alloc.c) checks only that it's close. */
- return((char *)tsd > me && (char *)tsd < me + 1000);
+ return (char *)tsd >= (char *)&me->tlfs
+ && (char *)tsd < (char *)&me->tlfs + sizeof(me->tlfs);
}
#endif /* GC_ASSERTIONS && THREAD_LOCAL_ALLOC */