Bug 91981

Summary: Ref-count AtomicHTMLToken
Product: WebKit Reporter: Kwang Yul Seo <skyul>
Component: DOMAssignee: Kwang Yul Seo <skyul>
Status: RESOLVED FIXED    
Severity: Normal CC: abarth, eric
Priority: P2    
Version: 528+ (Nightly build)   
Hardware: Unspecified   
OS: Unspecified   
Bug Depends on:    
Bug Blocks: 91703    
Attachments:
Description Flags
Patch abarth: review+

Kwang Yul Seo
Reported 2012-07-23 04:22:30 PDT
To avoid copying AtomicHTMLToken in Bug 91703, AtomicHTMLToken needs to be ref-counted.
Attachments
Patch (108.27 KB, patch)
2012-07-23 04:30 PDT, Kwang Yul Seo
abarth: review+
Kwang Yul Seo
Comment 1 2012-07-23 04:30:30 PDT
Adam Barth
Comment 2 2012-07-23 09:20:22 PDT
Comment on attachment 153772 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=153772&action=review Thanks for splitting this out into a separate patch. The only concern I have with this patch is that AtomicHTMLToken has an external character buffer. If we retain the atomic token too long, then that will point to garbage memory. > Source/WebCore/html/parser/HTMLToken.h:105 > + AtomicHTMLToken(HTMLToken& token) : AtomicMarkupTokenBase<HTMLToken>(&token) { } This should be split onto four lines like the other constructor. > Source/WebCore/html/parser/HTMLTreeBuilder.cpp:436 > - AtomicHTMLToken token(rawToken); > + RefPtr<AtomicHTMLToken> token = AtomicHTMLToken::create(rawToken); I wonder if we should clear the external character buffer pointers at the end of this function... That way we won't risk having any dangling pointers. Would you be willing to post a follow up patch that tries that?
Kwang Yul Seo
Comment 3 2012-07-23 14:59:20 PDT
(In reply to comment #2) > > Source/WebCore/html/parser/HTMLToken.h:105 > > + AtomicHTMLToken(HTMLToken& token) : AtomicMarkupTokenBase<HTMLToken>(&token) { } > > This should be split onto four lines like the other constructor. Okay. I will change it when I land the patch. > > Source/WebCore/html/parser/HTMLTreeBuilder.cpp:436 > > - AtomicHTMLToken token(rawToken); > > + RefPtr<AtomicHTMLToken> token = AtomicHTMLToken::create(rawToken); > > I wonder if we should clear the external character buffer pointers at the end of this function... That way we won't risk having any dangling pointers. Would you be willing to post a follow up patch that tries that? Sure, I will file a bug. We keep only the start tag tokens in the element stack and the list of active formatting elements , so there is no dangling pointer in the current code paths. But I agree that we need to make sure this, so we won't accidentally have dangling pointers later.
Kwang Yul Seo
Comment 4 2012-07-23 15:02:29 PDT
Note You need to log in before you can comment on or make changes to this bug.