[svn:parrot] r40934 - in trunk/src: . gc ops
chromatic at svn.parrot.org
chromatic at svn.parrot.org
Thu Sep 3 00:10:48 UTC 2009
Author: chromatic
Date: Thu Sep 3 00:10:47 2009
New Revision: 40934
URL: https://trac.parrot.org/parrot/changeset/40934
Log:
[PMC] Ensure that all accesses to PMC_sync check the PMC shared flag first, to
avoid dereferencing an absent PMC_sync structure.
Modified:
trunk/src/gc/api.c
trunk/src/hll.c
trunk/src/ops/set.ops
Modified: trunk/src/gc/api.c
==============================================================================
--- trunk/src/gc/api.c Wed Sep 2 23:57:29 2009 (r40933)
+++ trunk/src/gc/api.c Thu Sep 3 00:10:47 2009 (r40934)
@@ -406,10 +406,13 @@
Parrot_gc_add_pmc_sync(PARROT_INTERP, ARGMOD(PMC *pmc))
{
ASSERT_ARGS(Parrot_gc_add_pmc_sync)
+
+ /* This mutex already exists, leave it alone. */
if (PMC_sync(pmc))
- /* This mutex already exists, leave it alone. */
return;
+
PMC_sync(pmc) = mem_allocate_typed(Sync);
+
if (!PMC_sync(pmc))
Parrot_ex_throw_from_c_args(interp, NULL, EXCEPTION_ALLOCATION_ERROR,
"Parrot VM: PMC Sync allocation failed!\n");
Modified: trunk/src/hll.c
==============================================================================
--- trunk/src/hll.c Wed Sep 2 23:57:29 2009 (r40933)
+++ trunk/src/hll.c Thu Sep 3 00:10:47 2009 (r40934)
@@ -53,7 +53,7 @@
#define END_READ_HLL_INFO(interp, hll_info)
#define START_WRITE_HLL_INFO(interp, hll_info) \
do { \
- if (PMC_sync((interp)->HLL_info)) { \
+ if (PObj_is_PMC_shared_TEST(obj) && PMC_sync((interp)->HLL_info)) { \
(hll_info) = (interp)->HLL_info = \
Parrot_clone((interp), (interp)->HLL_info); \
if (PMC_sync((interp)->HLL_info)) \
@@ -362,8 +362,8 @@
"no such HLL ID (%vd)", hll_id);
/* the type might already be registered in a non-conflicting way, in which
- * case we can avoid copying */
- if (PMC_sync(hll_info)) {
+ * ca se we can avoid copying */
+ if (PObj_is_PMC_shared_TEST(obj) && PMC_sync(hll_info)) {
if (hll_type == Parrot_get_HLL_type(interp, hll_id, core_type))
return;
}
Modified: trunk/src/ops/set.ops
==============================================================================
--- trunk/src/ops/set.ops Wed Sep 2 23:57:29 2009 (r40933)
+++ trunk/src/ops/set.ops Thu Sep 3 00:10:47 2009 (r40934)
@@ -508,10 +508,10 @@
/* don't let the clone's destruction destroy the destination's data */
PObj_active_destroy_CLEAR(clone);
- PMC_data(clone) = NULL;
- PMC_metadata(clone) = NULL;
+ PMC_data(clone) = NULL;
+ PMC_sync(clone) = NULL;
+ PMC_metadata(clone) = NULL;
PMC_next_for_GC(clone) = NULL;
- PMC_sync(clone) = NULL;
/* Restore metadata. */
if (!PMC_IS_NULL(meta)) {
More information about the parrot-commits
mailing list