On Mon, May 5, 2008 at 2:52 AM, via RT Tom Erdevig <[EMAIL PROTECTED]> wrote:
> Parrot segfaults running this: > .sub _ :main > null S0 > loadlib P0, S0 > .end > The segfault is caused by src/dynext.c:Parrot_load_lib setting > its local lib_name variable to NULL and then passing it along > to run_init_lib, and thence to store_lib_pmc, who tries to set > the new library PMC's '_lib_name' property using this NULL, > leading to the crash. > > The attached patch fixes this in Parrot_load_lib by setting lib_name > to the empty string instead of NULL when there is no library name. I tried another way. The segfault is at pmc/string.pmc:set_string_native. If I insert an assertion od non-nullness of the 'value' parameter of this function parrot does not build, then I suppose the function must accept a NULL value. All intermediate functions have also his corresponding parameter not declared as nonnull, so I assume that the NULL argument must be allowed. The failed line is: if (PObj_constant_TEST(SELF) && !PObj_constant_TEST(value)) { If I change it to: if (PObj_constant_TEST(SELF) && (value && !PObj_constant_TEST(value))) { The segfault disappear and all tests pass. The attached patch contains this change. -- Salu2
Index: src/pmc/string.pmc =================================================================== --- src/pmc/string.pmc (revisión: 27325) +++ src/pmc/string.pmc (copia de trabajo) @@ -217,7 +217,7 @@ VTABLE void set_string_native(STRING *value) { /* Only allow constant PMCs to embed constant strings */ - if (PObj_constant_TEST(SELF) && !PObj_constant_TEST(value)) { + if (PObj_constant_TEST(SELF) && (value && !PObj_constant_TEST(value))) { const char *copy = string_to_cstring(INTERP, value); value = const_string(INTERP, copy); }