This is the mail archive of the mailing list for the GCC project.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [tree-ssa] Allow next field to point to the same field

> In message <>, Jan Hubicka writes:
>   >> Concerning this particular patch, while looking into the code I am
>  >> getting to believe that I've just worked around bug I fixed later.  Once
>  >> I am done with the other patches, I will give ggc_collect a try and
>  >> return to it if still fails.
>  >> For double linked lists the situation is somewhat different...
>  >OK, got it :)
>  >
>  >the problem is when linked chain ends up by node linking to itself.
> OK.
>  > In current scheme, the xlimit does not point to first element we don't
>  > point to first already visited element, but to the last element we
>  > should visit.
> Huh.  Sorry, but I simply can't parse that sentence.  
> Can you try to state it again?
> And just for clarity, can you state what the code is trying to do right
> now (it unfortunately isn't commented well) and how your patch changes
> the behavior.  It would help a lot in trying to understand what's going
> on and whether or not the behavior we're seeing is correct.

The code produces loop walking and marking all nodes up to first NULL or
already marked one.  The first "wrong" node is pointed to by xlimit.

Now the code makes another pass marking childrens of each visited node.
This is done by while (x!=xlimit).

Now suppose that chain ends up by node Y. Usually xlimit = Y->next, but
in the case Y->next == Y, the second loop never visits friends of Y and
we end up with memory corruption.

For SSA_NAMEs this happens in very rare cases. Self pointing SSA_NAMES
can happen easilly, but they are rarely pointed out by other chain
pointer, but even that can happen for instance when we don't remove
annotations before finishing SSA pass.
(doesn't seem to happen in current fixed tree), still I think it would
be safer to fix this side case assuming that we want to allow chain
pointers to be used arbitrarily.

> jeff

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]