This is the mail archive of the gdb-patches@sourceware.org mailing list for the GDB 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: [RFC] Detect loops in the solib chain


On Thu, 17 Jul 2008 18:09:59 -0400
Daniel Jacobowitz <drow@false.org> wrote:

> On Thu, Jul 17, 2008 at 02:57:03PM -0700, Paul Pluzhnikov wrote:
> > On Thu, Jul 17, 2008 at 2:40 PM, Daniel Jacobowitz <drow@false.org> wrote:
> > 
> > > @@ -784,14 +792,21 @@ svr4_current_sos (void)
> > >
> > >       read_memory (lm, new->lm_info->lm, lmo->link_map_size);
> > >
> > > -      lm = LM_NEXT (new);
> > > +      next_lm = LM_NEXT (new);
> > > +
> > > +      if (prev_lm != 0 && LM_PREV (new) != prev_lm && ldsomap == 0)
> > 
> > I think you want just:
> > 
> > +      if (LM_PREV (new) != prev_lm)
> > 
> > First entry on the list should also be properly terminated, and
> > ldsomap has nothing to do with whether the list is corrupt or not.
> 
> You're right about prev_lm, thanks.  The ldsomap check is necessary,
> because that entry may not be on the list (see down below).

As written, I agree that the ldsomap check is necessary.  Of course,
having this check means that as soon as ldsomap gets set, this
integrity check is effectively disabled.  I think that this will only
matter if the ldsomap entry ends up having a non-zero LM_NEXT.

It seems to me that the ldsomap check could be avoided if you were to
set prev_lm to 0 just after ldsomap gets set.  (It's been a while
since I've checked, but I'm guessing that in the case of a unattached
dynamic linker entry, you'd expect both LM_NEXT and LM_PREV for that
entry to be zero.)

Kevin


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