RESOLVED FIXED 201309
Assertions in JSArrayBufferView::byteOffset() are only valid for the mutator thread.
https://bugs.webkit.org/show_bug.cgi?id=201309
Summary Assertions in JSArrayBufferView::byteOffset() are only valid for the mutator ...
Mark Lam
Reported 2019-08-29 13:28:38 PDT
Attachments
proposed patch. (5.25 KB, patch)
2019-08-29 13:34 PDT, Mark Lam
no flags
proposed patch. (5.25 KB, patch)
2019-09-03 16:18 PDT, Mark Lam
no flags
proposed patch. (7.25 KB, patch)
2019-09-03 16:28 PDT, Mark Lam
no flags
proposed patch. (7.28 KB, patch)
2019-09-03 18:02 PDT, Mark Lam
no flags
proposed patch. (7.33 KB, patch)
2019-09-03 18:42 PDT, Mark Lam
ysuzuki: review+
Mark Lam
Comment 1 2019-08-29 13:34:15 PDT
Created attachment 377620 [details] proposed patch.
Yusuke Suzuki
Comment 2 2019-08-29 13:47:31 PDT
Comment on attachment 377620 [details] proposed patch. View in context: https://bugs.webkit.org/attachment.cgi?id=377620&action=review > Source/JavaScriptCore/runtime/JSArrayBufferView.h:177 > + enum ResultQuality { AccurateResult, RacyResult }; > + template<ResultQuality = AccurateResult> unsigned byteOffset(); This is OK for internal implementation. But I think usually we are using the name `xxxConcurrently()` for this type of function. So, I think `byteOffsetConcurrently()` would be better. > Source/JavaScriptCore/runtime/JSArrayBufferViewInlines.h:86 > ArrayBuffer* buffer = possiblySharedBuffer(); Is it safe to be called from DFG thread? If we go to JSArrayBufferView::slowDownAndWasteMemory, we allocate Butterfly in that function, and it is not allowed in concurrent compilers.
Mark Lam
Comment 3 2019-08-29 13:52:26 PDT
Comment on attachment 377620 [details] proposed patch. View in context: https://bugs.webkit.org/attachment.cgi?id=377620&action=review >> Source/JavaScriptCore/runtime/JSArrayBufferViewInlines.h:86 >> ArrayBuffer* buffer = possiblySharedBuffer(); > > Is it safe to be called from DFG thread? If we go to JSArrayBufferView::slowDownAndWasteMemory, we allocate Butterfly in that function, and it is not allowed in concurrent compilers. Thanks. I will investigate.
Mark Lam
Comment 4 2019-08-29 13:52:49 PDT
Comment on attachment 377620 [details] proposed patch. Take out of review while this is being investigated.
Mark Lam
Comment 5 2019-09-03 16:15:23 PDT
Comment on attachment 377620 [details] proposed patch. View in context: https://bugs.webkit.org/attachment.cgi?id=377620&action=review >>> Source/JavaScriptCore/runtime/JSArrayBufferViewInlines.h:86 >>> ArrayBuffer* buffer = possiblySharedBuffer(); >> >> Is it safe to be called from DFG thread? If we go to JSArrayBufferView::slowDownAndWasteMemory, we allocate Butterfly in that function, and it is not allowed in concurrent compilers. > > Thanks. I will investigate. Turns out, this is safe because the hasArrayBuffer() check above ensures that mode() is never FastTypedArray or OversizeTypedArray, and hence, we'll never call JSArrayBufferView::slowDownAndWasteMemory().
Mark Lam
Comment 6 2019-09-03 16:18:31 PDT
Created attachment 377929 [details] proposed patch.
Mark Lam
Comment 7 2019-09-03 16:28:18 PDT
Created attachment 377931 [details] proposed patch.
Mark Lam
Comment 8 2019-09-03 17:58:48 PDT
Comment on attachment 377931 [details] proposed patch. View in context: https://bugs.webkit.org/attachment.cgi?id=377931&action=review > Source/JavaScriptCore/runtime/JSArrayBufferViewInlines.h:91 > + ASSERT(isMainThread()); Looks like I can't assert this. Worker threads will not be happy.
Mark Lam
Comment 9 2019-09-03 18:02:33 PDT
Created attachment 377945 [details] proposed patch.
Yusuke Suzuki
Comment 10 2019-09-03 18:36:18 PDT
Comment on attachment 377931 [details] proposed patch. View in context: https://bugs.webkit.org/attachment.cgi?id=377931&action=review >> Source/JavaScriptCore/runtime/JSArrayBufferViewInlines.h:91 >> + ASSERT(isMainThread()); > > Looks like I can't assert this. Worker threads will not be happy. You can use `ASSERT(!isCompilationThread());` instead.
Mark Lam
Comment 11 2019-09-03 18:40:49 PDT
(In reply to Yusuke Suzuki from comment #10) > Comment on attachment 377931 [details] > proposed patch. > > View in context: > https://bugs.webkit.org/attachment.cgi?id=377931&action=review > > >> Source/JavaScriptCore/runtime/JSArrayBufferViewInlines.h:91 > >> + ASSERT(isMainThread()); > > > > Looks like I can't assert this. Worker threads will not be happy. > > You can use `ASSERT(!isCompilationThread());` instead. Sounds good. Fixing.
Mark Lam
Comment 12 2019-09-03 18:42:15 PDT
Created attachment 377947 [details] proposed patch.
Yusuke Suzuki
Comment 13 2019-09-03 18:52:01 PDT
Comment on attachment 377947 [details] proposed patch. r=me
Saam Barati
Comment 14 2019-09-03 22:45:08 PDT
(In reply to Mark Lam from comment #8) > Comment on attachment 377931 [details] > proposed patch. > > View in context: > https://bugs.webkit.org/attachment.cgi?id=377931&action=review > > > Source/JavaScriptCore/runtime/JSArrayBufferViewInlines.h:91 > > + ASSERT(isMainThread()); > > Looks like I can't assert this. Worker threads will not be happy. I think we made this mistake in another patch recently too, right?
Saam Barati
Comment 15 2019-09-03 22:46:32 PDT
(In reply to Saam Barati from comment #14) > (In reply to Mark Lam from comment #8) > > Comment on attachment 377931 [details] > > proposed patch. > > > > View in context: > > https://bugs.webkit.org/attachment.cgi?id=377931&action=review > > > > > Source/JavaScriptCore/runtime/JSArrayBufferViewInlines.h:91 > > > + ASSERT(isMainThread()); > > > > Looks like I can't assert this. Worker threads will not be happy. > > I think we made this mistake in another patch recently too, right? https://bugs.webkit.org/show_bug.cgi?id=201281
Mark Lam
Comment 16 2019-09-03 23:16:23 PDT
(In reply to Saam Barati from comment #15) > (In reply to Saam Barati from comment #14) > > (In reply to Mark Lam from comment #8) > > > Comment on attachment 377931 [details] > > > proposed patch. > > > > > > View in context: > > > https://bugs.webkit.org/attachment.cgi?id=377931&action=review > > > > > > > Source/JavaScriptCore/runtime/JSArrayBufferViewInlines.h:91 > > > > + ASSERT(isMainThread()); > > > > > > Looks like I can't assert this. Worker threads will not be happy. > > > > I think we made this mistake in another patch recently too, right? > > https://bugs.webkit.org/show_bug.cgi?id=201281 In 201281, the mistake reduces the strength of the assertion for worker threads instead of overly asserting it (which resulted in crashes) like this case. Regardless, I'll fix it.
Mark Lam
Comment 17 2019-09-03 23:16:34 PDT
Thanks for the review. Landed in r249458: <http://trac.webkit.org/r249458>.
Note You need to log in before you can comment on or make changes to this bug.