summaryrefslogtreecommitdiff
path: root/pthread_support.c
diff options
context:
space:
mode:
authorivmai <ivmai>2011-03-13 14:08:16 +0100
committerIvan Maidanski <ivmai@mail.ru>2011-07-26 19:06:56 +0200
commit667fb0512a70f7756a2c64f0e71c03e1e49a8a4c (patch)
tree67a5fa56f2df6166f717bb634e2370db9091b73f /pthread_support.c
parent35260b7ff2dc15a5194758ab6f3c73fbfb40acb3 (diff)
2011-03-13 Ivan Maidanski <ivmai@mail.ru>
* dbg_mlc.c (GC_make_closure): Fix SEGV in case GC_malloc returns NULL. * dbg_mlc.c (GC_debug_register_finalizer, GC_debug_register_finalizer_no_order, GC_debug_register_finalizer_unreachable, GC_debug_register_finalizer_ignore_self): Handle out of memory case properly (similar to GC_register_finalizer_inner). * headers.c (GC_install_header): Handle the case when alloc_hdr() returns NULL. * os_dep.c (GC_get_maps_len): Defend against missing "maps" file. * pthread_support.c (GC_mark_thread): Place a dummy return statement (which uses "id" argument) before the actual use of "id" as an array index (to suppress a warning produced by some static code analysis tools). * win32_threads.c (GC_mark_thread): Ditto. * pthread_support.c (GC_thr_init): Abort (with the appropriate message) if out of memory.
Diffstat (limited to 'pthread_support.c')
-rw-r--r--pthread_support.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/pthread_support.c b/pthread_support.c
index 2cd012d..d592bba 100644
--- a/pthread_support.c
+++ b/pthread_support.c
@@ -363,6 +363,7 @@ STATIC void * GC_mark_thread(void * id)
word my_mark_no = 0;
IF_CANCEL(int cancel_state;)
+ if ((word)id == (word)-1) return 0; /* to make compiler happy */
DISABLE_CANCEL(cancel_state);
/* Mark threads are not cancellable; they */
/* should be invisible to client. */
@@ -374,8 +375,6 @@ STATIC void * GC_mark_thread(void * id)
marker_mach_threads[(word)id] = mach_thread_self();
# endif
- if ((word)id == (word)-1) return 0; /* to make compiler happy */
-
for (;; ++my_mark_no) {
/* GC_mark_no is passed only to allow GC_help_marker to terminate */
/* promptly. This is important if it were called from the signal */
@@ -921,6 +920,8 @@ GC_INNER void GC_thr_init(void)
/* Add the initial thread, so we can stop it. */
{
GC_thread t = GC_new_thread(pthread_self());
+ if (t == NULL)
+ ABORT("Failed to allocate memory for the initial thread.");
# ifdef GC_DARWIN_THREADS
t -> stop_info.mach_thread = mach_thread_self();
# else