Author: petergibbs
Date: Sat Feb 23 07:54:48 2008
New Revision: 26025

Modified:
   trunk/src/hll.c
   trunk/src/pmc/parrotinterpreter.pmc
   trunk/src/pmc/string.pmc

Log:
More complete fix for the constant string problems in hll_info causing
segfaults, refer also r25990 and RT#51122.
This now enforces that constant String PMCs embed constant parrot strings.


Modified: trunk/src/hll.c
==============================================================================
--- trunk/src/hll.c     (original)
+++ trunk/src/hll.c     Sat Feb 23 07:54:48 2008
@@ -57,8 +57,6 @@
     } while (0)
 #define END_WRITE_HLL_INFO(interp, hll_info)
 
-#define ASSERT_CONST_STRING(src) PARROT_ASSERT(PObj_constant_TEST(src))
-
 
 /*
 
@@ -160,7 +158,6 @@
 
     /* register HLL name */
     name     = constant_pmc_new_noinit(interp, enum_class_String);
-    ASSERT_CONST_STRING(hll_name);
 
     VTABLE_set_string_native(interp, name, hll_name);
     VTABLE_set_pmc_keyed_int(interp, entry, e_HLL_name, name);
@@ -235,7 +232,6 @@
 
     /* register dynlib */
     name    = constant_pmc_new_noinit(interp, enum_class_String);
-    ASSERT_CONST_STRING(hll_lib);
 
     VTABLE_set_string_native(interp, name, hll_lib);
     VTABLE_set_pmc_keyed_int(interp, entry, e_HLL_lib, name);

Modified: trunk/src/pmc/parrotinterpreter.pmc
==============================================================================
--- trunk/src/pmc/parrotinterpreter.pmc (original)
+++ trunk/src/pmc/parrotinterpreter.pmc Sat Feb 23 07:54:48 2008
@@ -633,7 +633,6 @@
             if (!PMC_IS_NULL(name_pmc)) {
                 STRING * const hll_name = VTABLE_get_string(INTERP, name_pmc);
 
-                PObj_constant_SET(hll_name);
                 hll_id           = Parrot_register_HLL(INTERP, hll_name);
             }
 
@@ -644,7 +643,6 @@
                 if (!STRING_IS_EMPTY(lib_name)) {
                     INTVAL id;
                     ignored      = Parrot_load_lib(INTERP, lib_name, NULL);
-                    PObj_constant_SET(lib_name);
                     id           = Parrot_register_HLL_lib(INTERP, lib_name);
                     UNUSED(id);
                 }

Modified: trunk/src/pmc/string.pmc
==============================================================================
--- trunk/src/pmc/string.pmc    (original)
+++ trunk/src/pmc/string.pmc    Sat Feb 23 07:54:48 2008
@@ -216,8 +216,8 @@
 */
 
     void set_string_native(STRING *value) {
-        /* COW doesn't work well with constant strings; work around this */
-        if (PObj_constant_TEST(SELF) && PObj_COW_TEST(value)) {
+        /* Only allow constant PMCs to embed constant strings */
+        if (PObj_constant_TEST(SELF) && !PObj_constant_TEST(value)) {
             const char *copy = string_to_cstring(INTERP, value);
             value            = const_string(INTERP, copy);
         }

Reply via email to