WebKit Bugzilla
New
Browse
Search+
Log In
×
Sign in with GitHub
or
Remember my login
Create Account
·
Forgot Password
Forgotten password account recovery
RESOLVED FIXED
228096
REGRESSION (
r278702
): Cannot login to appaloosa-store.com/users/sign_in
https://bugs.webkit.org/show_bug.cgi?id=228096
Summary
REGRESSION (r278702): Cannot login to appaloosa-store.com/users/sign_in
Chris Dumez
Reported
2021-07-19 18:59:34 PDT
r278702
broke the login page on appaloosa-store.com.
Attachments
Patch
(5.05 KB, patch)
2021-07-19 19:04 PDT
,
Chris Dumez
no flags
Details
Formatted Diff
Diff
Patch
(6.38 KB, patch)
2021-07-20 09:37 PDT
,
Chris Dumez
no flags
Details
Formatted Diff
Diff
Show Obsolete
(1)
View All
Add attachment
proposed patch, testcase, etc.
Chris Dumez
Comment 1
2021-07-19 18:59:46 PDT
<
rdar://80596391
>
Chris Dumez
Comment 2
2021-07-19 19:04:35 PDT
Created
attachment 433843
[details]
Patch
Alex Christensen
Comment 3
2021-07-20 08:59:27 PDT
Comment on
attachment 433843
[details]
Patch View in context:
https://bugs.webkit.org/attachment.cgi?id=433843&action=review
> Source/WebCore/Modules/fetch/FetchBodyConsumer.cpp:358 > + data.append(m_buffer->data(), m_buffer->size());
This could also call forEachSegment to have fewer copies.
Chris Dumez
Comment 4
2021-07-20 09:01:02 PDT
Comment on
attachment 433843
[details]
Patch View in context:
https://bugs.webkit.org/attachment.cgi?id=433843&action=review
>> Source/WebCore/Modules/fetch/FetchBodyConsumer.cpp:358 >> + data.append(m_buffer->data(), m_buffer->size()); > > This could also call forEachSegment to have fewer copies.
Good idea. Will update.
Chris Dumez
Comment 5
2021-07-20 09:37:24 PDT
Created
attachment 433878
[details]
Patch
EWS
Comment 6
2021-07-20 10:33:03 PDT
Committed
r280085
(
239810@main
): <
https://commits.webkit.org/239810@main
> All reviewed patches have been landed. Closing bug and clearing flags on
attachment 433878
[details]
.
Darin Adler
Comment 7
2021-07-21 12:03:27 PDT
Comment on
attachment 433878
[details]
Patch View in context:
https://bugs.webkit.org/attachment.cgi?id=433878&action=review
> Source/WebCore/Modules/fetch/FetchBodyConsumer.cpp:362 > + if (buffer->hasOneRef()) > + data = buffer->takeData(); // Avoid copying the data in the case where the buffer isn't shared. > + else { > + buffer->forEachSegment([&data](auto& span) { > + data.append(span); > + }); > + }
If this pattern comes up again, perhaps we should consider a function with this logic? A safer "takeData" that will only do so when it’s singly owned, and would instead copy the data into a vector when it’s shared. The trick would be how to abstract the two different approaches, but I think it might be relevant. Here’s one possible implementation: Vector<uint8_t> extractData(Ref<SharedBuffer>&& buffer) { return buffer->hasOneRef() ? buffer->takeData() : buffer->copyData(); } And, since the forEachSegment/append optimization is important, we would move that optimization into SharedBuffer::copyData, unless there are some contexts where the current implementation of SharedBuffer::copyData is superior for some reason.
Chris Dumez
Comment 8
2021-07-21 12:05:35 PDT
(In reply to Darin Adler from
comment #7
)
> Comment on
attachment 433878
[details]
> Patch > > View in context: >
https://bugs.webkit.org/attachment.cgi?id=433878&action=review
> > > Source/WebCore/Modules/fetch/FetchBodyConsumer.cpp:362 > > + if (buffer->hasOneRef()) > > + data = buffer->takeData(); // Avoid copying the data in the case where the buffer isn't shared. > > + else { > > + buffer->forEachSegment([&data](auto& span) { > > + data.append(span); > > + }); > > + } > > If this pattern comes up again, perhaps we should consider a function with > this logic? A safer "takeData" that will only do so when it’s singly owned, > and would instead copy the data into a vector when it’s shared. The trick > would be how to abstract the two different approaches, but I think it might > be relevant. Here’s one possible implementation: > > Vector<uint8_t> extractData(Ref<SharedBuffer>&& buffer) > { > return buffer->hasOneRef() ? buffer->takeData() : buffer->copyData(); > } > > And, since the forEachSegment/append optimization is important, we would > move that optimization into SharedBuffer::copyData, unless there are some > contexts where the current implementation of SharedBuffer::copyData is > superior for some reason.
Yes, I think this is a good idea. Now that I have experienced this bug, I actually think takeData() is too dangerous and we should just replace it with the safer alternative that copies when refCount is > 1.
Note
You need to
log in
before you can comment on or make changes to this bug.
Top of Page
Format For Printing
XML
Clone This Bug