Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

[GH #880/#875] Try to fix some GC thread bugs

Do not ascent into parent_interpreter with a threaded interp. (No influence)
Do not mark PMCs when threaded interp is different to the current interp
(Parrot_gc_mark_PMC_alive)
  • Loading branch information...
commit 196907ebd87811ccca24028d2c463050c7300a57 1 parent 6a6dc5e
Reini Urban rurban authored
Showing with 21 additions and 10 deletions.
  1. +8 −3 include/parrot/gc_api.h
  2. +5 −1 src/gc/api.c
  3. +8 −6 src/gc/mark_sweep.c
11 include/parrot/gc_api.h
View
@@ -552,15 +552,20 @@ void Parrot_unblock_GC_sweep(PARROT_INTERP)
# define Parrot_gc_mark_PMC_alive(interp, obj) \
do if (!PMC_IS_NULL(obj) \
&& (!PObj_is_shared_TEST(obj) || !Interp_flags_TEST((interp), PARROT_IS_THREAD))) { \
- PARROT_ASSERT((obj)->orig_interp == (interp)); \
- Parrot_gc_mark_PMC_alive_fun((interp), (obj)); \
+ if (!interp->thread_data) { \
+ PARROT_ASSERT((obj)->orig_interp == (interp)); \
+ Parrot_gc_mark_PMC_alive_fun((interp), (obj)); \
+ } else if (interp == interp->thread_data->main_interp) { \
+ Parrot_gc_mark_PMC_alive_fun((interp), (obj)); \
+ } \
} \
while (0)
#else
# define Parrot_gc_mark_PMC_alive(interp, obj) \
do if (!PMC_IS_NULL(obj) \
&& (!PObj_is_shared_TEST(obj) || !Interp_flags_TEST((interp), PARROT_IS_THREAD))) { \
- Parrot_gc_mark_PMC_alive_fun((interp), (obj)); \
+ if (!interp->thread_data || interp == interp->thread_data->main_interp) \
+ Parrot_gc_mark_PMC_alive_fun((interp), (obj)); \
} \
while (0)
#endif
6 src/gc/api.c
View
@@ -143,7 +143,11 @@ void
Parrot_gc_mark_PMC_alive_fun(PARROT_INTERP, ARGMOD_NULLOK(PMC *obj))
{
ASSERT_ARGS(Parrot_gc_mark_PMC_alive_fun)
- if (obj)
+ if (obj
+#ifndef PARROT_IN_CORE
+ && (!interp->thread_data || interp == interp->thread_data->main_interp)
+#endif
+ )
interp->gc_sys->mark_pmc_header(interp, obj);
}
14 src/gc/mark_sweep.c
View
@@ -1,5 +1,5 @@
/*
-Copyright (C) 2001-2010, Parrot Foundation.
+Copyright (C) 2001-2012, Parrot Foundation.
=head1 NAME
@@ -258,13 +258,15 @@ mark_interp(PARROT_INTERP)
if (!PMC_IS_NULL(interp->final_exception))
Parrot_gc_mark_PMC_alive(interp, interp->final_exception);
- if (interp->parent_interpreter)
- mark_interp(interp->parent_interpreter);
+ if (!Interp_flags_TEST(interp, PARROT_IS_THREAD)) {
+ /* Do not ascend with threads, only walk down */
+ if (interp->parent_interpreter)
+ mark_interp(interp->parent_interpreter);
- /* code should be read only and is currently not cloned into other threads
- * so only mark it in the main thread */
- if (! Interp_flags_TEST(interp, PARROT_IS_THREAD))
+ /* code should be read only and is currently not cloned into other threads
+ * so only mark it in the main thread */
mark_code_segment(interp);
+ }
}
/*
Please sign in to comment.
Something went wrong with that request. Please try again.