Bug 45681 - Assertion failure: m_isValid == validity()->valid() after manipulating a detached element
Summary: Assertion failure: m_isValid == validity()->valid() after manipulating a deta...
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: Forms (show other bugs)
Version: 528+ (Nightly build)
Hardware: All All
: P2 Major
Assignee: Kent Tamura
URL:
Keywords:
Depends on:
Blocks: 42959
  Show dependency treegraph
 
Reported: 2010-09-13 10:10 PDT by Alexey Proskuryakov
Modified: 2010-09-28 00:11 PDT (History)
4 users (show)

See Also:


Attachments
test case (may crash) (182 bytes, text/html)
2010-09-13 10:10 PDT, Alexey Proskuryakov
no flags Details
Patch (3.92 KB, patch)
2010-09-13 17:37 PDT, Kent Tamura
no flags Details | Formatted Diff | Diff
Patch 2 (resolve redundant setNeedsValidityCheck()) (5.05 KB, patch)
2010-09-15 18:24 PDT, Kent Tamura
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Alexey Proskuryakov 2010-09-13 10:10:16 PDT
Created attachment 67422 [details]
test case (may crash)

See attached test case.
Comment 1 Kent Tamura 2010-09-13 17:37:13 PDT
Created attachment 67493 [details]
Patch
Comment 2 Alexey Proskuryakov 2010-09-15 17:13:00 PDT
Comment on attachment 67493 [details]
Patch

Why do we need to call setNeedsValidityCheck() in both functions? One of these always calls another.

If we do need that, it may be worth a comment in code, or at the very least, in ChangeLog.
Comment 3 Kent Tamura 2010-09-15 18:20:24 PDT
Thank you for the feedback.

(In reply to comment #2)
> (From update of attachment 67493 [details])
> Why do we need to call setNeedsValidityCheck() in both functions? One of these always calls another.
> 
> If we do need that, it may be worth a comment in code, or at the very least, in ChangeLog.

setNonDirtyValue() is called by other functions. We need to call setNeedsValidityCheck() in that case.
I'll improve the code to reduce redundant calls of setNeedsValidityCheck().
Comment 4 Kent Tamura 2010-09-15 18:24:25 PDT
Created attachment 67754 [details]
Patch 2 (resolve redundant setNeedsValidityCheck())
Comment 5 Alexey Proskuryakov 2010-09-16 10:52:19 PDT
> setNonDirtyValue() is called by other functions.

OK, but why wouldn't it be sufficient to only have setNeedsValidityCheck() in setNonDirtyValue()? Since setValue() calls it, it doesn't seem to also call the same function.

Talking about the new patch - this is probably a related question, but why can't setNeedsValidityCheck() be in setValueCommon()? Does its behavior depend on m_isDirty value? It doesn't use it explicitly, and if an indirect use is the reason not to put this call in setValueCommon(), then a comment should explain that (and setNeedsValidityCheck() probably needs a better name, since it does something different than setting a "needsValidityCheck" boolean).

Both these patches confuse me, but it seems that a larger refactoring may be needed. If so, the first one might actually be better as a targeted fix, as it's simpler and doesn't add a new method.
Comment 6 Kent Tamura 2010-09-20 20:38:54 PDT
(In reply to comment #5)
> > setNonDirtyValue() is called by other functions.
> 
> OK, but why wouldn't it be sufficient to only have setNeedsValidityCheck() in setNonDirtyValue()? Since setValue() calls it, it doesn't seem to also call the same function.
> 
> but why can't setNeedsValidityCheck() be in setValueCommon()? Does its behavior depend on m_isDirty value?

Right.  setNeedsValidityCheck() result depends on m_isDirty value.

The name "setNeedsValidityCheck" doesn't represent the current behavior.  The role of setNeedsValdityCheck was to set "needs to recalculate element validity", and the name followed "setNeedsStyleRecalc".  But we need to calculate validity in setNeedsValidityCheck for some reasons.

I don't think we'll have a large refactor for needsValidityCheck, but we should rename it.
Comment 7 Alexey Proskuryakov 2010-09-22 10:46:31 PDT
Comment on attachment 67754 [details]
Patch 2 (resolve redundant setNeedsValidityCheck())

OK. So, do you prefer the old or the new patch yourself? Given that you kept the new one for review, I guess that's it, so I'll mark it r+.

> ta.checkValidity(); // This made an assertion failure.

"This made an assertion fail".
Comment 8 Kent Tamura 2010-09-27 23:51:17 PDT
(In reply to comment #7)
> (From update of attachment 67754 [details])
> OK. So, do you prefer the old or the new patch yourself? Given that you kept the new one for review, I guess that's it, so I'll mark it r+.

Yeah, I prefer the second patch. Thanks for r+.

> > ta.checkValidity(); // This made an assertion failure.
> 
> "This made an assertion fail".

I'll fix it before landing.
Comment 9 Kent Tamura 2010-09-28 00:10:54 PDT
Landed as r68494.