RESOLVED FIXED 45358
DatasetDOMStringMap does not have the right memory model
https://bugs.webkit.org/show_bug.cgi?id=45358
Summary DatasetDOMStringMap does not have the right memory model
Erik Arvidsson
Reported 2010-09-07 19:25:04 PDT
This came up in irc today when we talked about classList DOMTokenList which has the same behavior/issue: The dataset needs to not fail when the element goes away. othermaciej: I think the following would work: [7:06pm] othermaciej: - DOMTokenList is a normal RefCounted [7:06pm] othermaciej: - Element keeps a ref to it via rare data struct [7:06pm] othermaciej: - Element destructor presumably already cleans up any rare data that may exist, so rare data can clear out DOMTokenList's backpointer to its element [7:07pm] othermaciej: - At JS/GC level, Element wrapper keeps DOMTokenList wrapper alive [7:15pm] arv: jamesr, othermaciej: DatasetDOMStringMap uses the same pattern. I assume that needs to be updated too? [7:15pm] othermaciej: arv: ask and/or yell at weinig
Attachments
Patch (5.38 KB, patch)
2010-09-07 22:46 PDT, Sam Weinig
mitz: review+
Sam Weinig
Comment 1 2010-09-07 22:46:03 PDT
Sam Weinig
Comment 2 2010-09-07 22:47:48 PDT
I disagree with Maciej that we need to completely alter the memory management of DOMStringMap. The model I used is idiomatic in WebCore. For instance, It is used by CanvasRenderingContext and ValidityState. That said, I was forgetting to mark the dataset, so I have attached a patch to fix it.
mitz
Comment 3 2010-09-07 22:52:18 PDT
Comment on attachment 66843 [details] Patch > + DOMStringMap* optionalDataset() const; That’s an awful use of “optional”. r+ only because it’s already being used like this.
Sam Weinig
Comment 4 2010-09-07 22:59:57 PDT
Fixed in r66954. Filed https://bugs.webkit.org/show_bug.cgi?id=45367 for a better name.
Erik Arvidsson
Comment 5 2010-09-08 11:32:05 PDT
Comment on attachment 66843 [details] Patch This test does not seem correct to me. Your test seems to test that we get back the same wrapper object? Don't you want to GC the element and ensure that the dataset does not blow up when the element goes away? (and that the element can be GC'd when there are only references to the dataset) Is there a reason why you use __proto__ here. Could you have used any property name?
Sam Weinig
Comment 6 2010-09-08 14:29:16 PDT
(In reply to comment #5) > (From update of attachment 66843 [details]) > This test does not seem correct to me. > Can you elaborate on what is incorrect about it? > Your test seems to test that we get back the same wrapper object? Yes. > > Don't you want to GC the element and ensure that the dataset does not blow up when the element goes away? (and that the element can be GC'd when there are only references to the dataset) I am not entirely sure what you are getting at. Can you provide a test case? > Is there a reason why you use __proto__ here. Could you have used any property name? Yeah, I was being sneaky due to the fact that dataset intercepts all property sets except for a few built in properties and puts them in the DOM as attributes, so it wouldn't be testing the right thing?
Erik Arvidsson
Comment 7 2010-09-17 15:42:49 PDT
Would it not be better to tie the lifetime of the dataset to the lifetime of the element it came from? Also see Bug 45426
Sam Weinig
Comment 8 2010-09-18 16:55:55 PDT
(In reply to comment #7) > Would it not be better to tie the lifetime of the dataset to the lifetime of the element it came from? > > Also see Bug 45426 That is what is done.
Erik Arvidsson
Comment 9 2010-09-20 10:29:49 PDT
Forgive my ignorance. I think what is confusing is that markDOMObjectWrapper takes an argument called globalData.
Eric Seidel (no email)
Comment 10 2010-12-14 01:58:52 PST
Looks like this was landed but just not closed.
Note You need to log in before you can comment on or make changes to this bug.