<div dir="ltr"><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Fri, 14 Feb 2020 at 11:49, Ömer Sinan Ağacan <<a href="mailto:omeragacan@gmail.com">omeragacan@gmail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">Hi Simon,<br>
<br>
In this code: (slightly simplified)<br>
<br>
    StgPtr<br>
    scavenge_PAP (StgPAP *pap)<br>
    {<br>
        evacuate(&pap->fun);<br>
        return scavenge_PAP_payload (pap->fun, pap->payload, pap->n_args);<br>
    }<br>
<br>
    StgPtr<br>
    scavenge_PAP_payload (StgClosure *fun, StgClosure **payload, StgWord size)<br>
    {<br>
        const StgFunInfoTable *fun_info =<br>
get_fun_itbl(UNTAG_CONST_CLOSURE(fun));<br>
        StgPtr p = (StgPtr)payload;<br>
<br>
        switch (fun_info->f.fun_type) {<br>
        case ARG_GEN_BIG:<br>
            scavenge_large_bitmap(p, GET_FUN_LARGE_BITMAP(fun_info), size);<br>
            p += size;<br>
            break;<br>
        ...<br>
        }<br>
        return p;<br>
    }<br>
<br>
Here the `size` argument in `scavenge_PAP_payload` is the number of arguments<br>
applied to the function in `pap->fun`. But when scavenging the function's bitmap<br>
we're using this number as the size of the bitmap which doesn't make sense to<br>
me, because I think size of the function's bitmap and size of the PAP's payload<br>
may be different.<br></blockquote><div><br></div><div>"size" is an argument to scavenge_PAP_payload(), and when we call it we pass pap->n_args as the value, not the bitmap's size.</div><div><br></div><div>Does that help?</div><div><br></div><div>Cheers</div><div>Simon</div><div><br></div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
<br>
Or in other words I may have the same function used in many PAPs with different<br>
n_args, but that'd be buggy if this code is correct.<br>
<br>
I haven't checked every single place where we build a PAP but for example the<br>
`NEW_PAP` macro uses the argument's (another PAP) function directly, without<br>
making any bitmap-related changes, but bumps n_args by one. If the code above is<br>
right, then this new PAP will be scavenged incorrectly.<br>
<br>
Am I missing anything?<br>
<br>
Thanks,<br>
<br>
Ömer<br>
</blockquote></div></div>