[ic] Leaky Globals in RPC mode

Peter peter at pajamian.dhs.org
Mon Dec 1 03:28:36 UTC 2014


Ran across an issue today with globals leaking from one page load to the
next in RPC mode, it was in a missing specialsub that has code that
looks like this (simplified):

    our $missing_called;
    return if ($missing_called);
    $missing_called = 1;

    my $name = shift;
    my ($page, $rawpage);
    if ($name =~ s:/(.*)::) {
        $page = $1;
    }

    # additional code here to check $name against a db and do stuff with it.

    return (1, $page);


Basically the above code is supposed to pull the first directory segment
from a URL do stuff with it and try to re-fetch with that segment
removed.  Since stuff is only supposed to be done with the *first*
segment it bails if it's been called before.  The issue is that in RPC
mode $missing_called gets leaked and so sometimes it bails right away
without checking the first segment at all.

My best workaround solution was to create an init_session specialsub
which initializes $missing_called with:

    our $missing_called = 0;

This works, but what I want to know is if the above behavior is expected
or is it some obscure bug and how does it affect other globals and code
in IC when running in RPC mode?


Peter



More information about the interchange-users mailing list