develooper Front page | perl.perl6.internals | Postings from May 2008

Re: [perl #53714] [PATCH] parrot segfaults when dyna-loading main program

From:
NotFound
Date:
May 5, 2008 13:51
Subject:
Re: [perl #53714] [PATCH] parrot segfaults when dyna-loading main program
On Mon, May 5, 2008 at 2:52 AM, via RT Tom Erdevig
<parrotbug-followup@parrotcode.org> 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




Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About