Ticket #105 (NULL checks)

Will Coleda will at coleda.com
Mon Jan 5 15:40:30 UTC 2009


On Sun, Jan 4, 2009 at 2:52 PM, Mark Glines <mark at glines.org> wrote:
> Nicholas Clark wrote:
>> Until gcc fixes that (has it?), nonnull can't be relied on to be truthful.
>
> As of gcc 4.3.2, it hasn't.
>
> We now have asserts for all the functions tracked by headerizer, which
> is a good portion of the Parrot codebase.  That exposed 15 cases where
> function arguments had been mistagged as nonnull.  Other than one or two
> cases of sequencing bugs or other weirdness, the majority were all
> obvious cases where the function was prepared to handle null pointers
> but the prototype was wrong.
>
> Here's the list of arguments I added _NULLOK to:
> src/atomic/gcc_x86.c: parrot_i386_cmpxchg()'s "expect" and "update", r34866
> src/list.c: list_set()'s "item", r34772
> src/list.c: list_push()'s "item", r34772
> src/list.c: list_assign()'s "item", r34772
> src/inter_call.c: set_context_sig_return()'s "ret_x", r34731
> src/inter_call.c: parrot_pass_args()'s "src_indexes" and "dest_indexes",
> r34731
> compilers/imcc/pcc.c: insert_tail_call()'s "meth", r34726
> src/string.c: string_make_direct()'s "charset", r34712
> src/pmc_freeze.c: do_thaw()'s "pmc", r34712
> src/pmc_freeze.c: visit_todo_list()'s "pmc", r34712
> src/pmc_freeze.c: visit_todo_list_thaw()'s "pmc", r34712
> compilers/imcc/main.c: imcc_run_pbc()'s "output_file", r34525
> compilers/imcc/main.c: compile_to_bytecode()'s "output_file", r34525
>
> If gcc were doing its job, the asserts wouldn't have caught any of those
> cases.  It seems like gcc's "contract enforcement" seems to consist of a
> compile-time check with a warning, and no runtime followup.

FYI, newer versions of gcc theoretically[0] have a way to promote
certain warning types into errors. Forcing this to be a compile time
error on gcc would help trap these issues much sooner.

[0] There's a re-opened RT[1] for this; looks like we could never get
it to work.
[1] http://rt.perl.org/rt3/Ticket/Display.html?id=50908

-- 
Will "Coke" Coleda


More information about the parrot-dev mailing list