Would it be feasible to rewrite the recursive code to be iterative, and
keep state in an explicit data structure? That would make it much easier to
keep the behavior predictable and consistent across platforms.


On Mon, May 2, 2016 at 10:34 AM, L. David Baron <dba...@dbaron.org> wrote:

> On Monday 2016-05-02 10:07 -0700, Bobby Holley wrote:
> > This might be helpful:
> >
> http://mxr.mozilla.org/mozilla-central/source/js/xpconnect/src/XPCJSRuntime.cpp#3440
> >
> > I can't vouch 100% for its accuracy, but it's probably pretty close.
> >
> > In general, dynamic stack checks (measuring the top of the stack at XPCOM
> > startup, and comparing it with the stack at the point of interest) seem
> > preferable to hard-coding number-of-recursive-calls, since it doesn't
> > depend on the size of stack frames, which may drift over time. We can't
> do
> > this for JS (see the comments surrounding the MXR link above), but I bet
> we
> > could for layout.
>
> We already have some code that could be improved to do stuff like
> this (see nsFrame::IsFrameTreeTooDeep and
> NS_FRAME_TOO_DEEP_IN_FRAME_TREE), but we'd need to add checks in
> other places (particularly frame construction, which is also
> recursive), and we'd also need to make sure that hitting these
> conditions kept things in a safe state and didn't cause security
> bugs like https://bugzilla.mozilla.org/show_bug.cgi?id=619021 .
> This probably requires thorough testing of any such code.
>
> -David
>
>
> --
> 𝄞   L. David Baron                         http://dbaron.org/   𝄂
> 𝄢   Mozilla                          https://www.mozilla.org/   𝄂
>              Before I built a wall I'd ask to know
>              What I was walling in or walling out,
>              And to whom I was like to give offense.
>                - Robert Frost, Mending Wall (1914)
>
> _______________________________________________
> dev-platform mailing list
> dev-platform@lists.mozilla.org
> https://lists.mozilla.org/listinfo/dev-platform
>
>
_______________________________________________
dev-platform mailing list
dev-platform@lists.mozilla.org
https://lists.mozilla.org/listinfo/dev-platform

Reply via email to