On Saturday 19 April 2008 09:31:12 Mark Glines wrote:

> Gcc emits the following warnings:
>
> ./lua.pmc: In function 'Parrot_Lua_nci_caller':
> ./lua.pmc:127: warning: passing argument 2 of 'strncmp' from incompatible
> pointer type ./lua.pmc:128: warning: passing argument 1 of
> 'string_cstring_free' from incompatible pointer type
>
> Looking at the code in question, I'd have to agree.
>
> 120                Parrot_Context_info info;
> 121                Parrot_block_DOD(INTERP);
> 122
> 123                if (Parrot_Context_get_info(INTERP, sub_ctx, &info)) {
> 124                    STRING *retval = info.subname;
> 125
> 126                    /* free the non-constant string, but not the
> constant one */ 127                    if (strncmp("(unknown file)",
> info.file, 14) < 0) 128                       
> string_cstring_free(info.file);
> 129
> 130                    Parrot_unblock_DOD(INTERP);
> 131                    RETURN(STRING *retval);
>
>
> The problem is, info.file isn't a char*, its a STRING*.  This means 2
> things: you can't call strncmp on it directly, and you can't free it
> like a char* string.
>
> Actually, this isn't just a warning.  This bug causes crashes,
> resulting in almost ALL of the lua test failures on my list:
>
> Failed Test    Stat Wstat Total Fail  List of Failed
> ---------------------------------------------------------------------------
>---- lua/t/alarm.t     2   512     6    2  4 6
> lua/t/basic.t    12  3072    54   12  7 13-14 28-29 35 40-42 51 53-54
> lua/t/io.t        2   512    41    2  28 35
> lua/t/lfs.t       1   256    18    1  15
> lua/t/math.t      1   256    32    1  18
> lua/t/os.t        2   512    25    2  20 23
> lua/t/string.t    3   768    34    3  10-11 25
> lua/t/table.t     2   512    18    2  3-4
>
> os.t test 23 is something unrelated.  The rest of them are caused by
> this bug.  Glibc aborts with an error that looks like:
>
> *** glibc detected *** ./parrot: double free or corruption (out):
> 0x00002b4aed18ef00 ***
>
> I propose just removing this code entirely.  The attached patch does
> so.  The GC will clean it up, right?  I'm hoping someone familiar with
> the internals can review this, to make sure I haven't just created a
> memory leak.

The patch is correct.

This is my fault; I changed Parrot_Context_get_info() in r26495 to avoid 
this "should I free?  should I not?" guessing, but somehow failed to update 
the Lua PMCs with the results.

-- c

Reply via email to