Bug 220531

Summary: Calling Blob.stream() causes null pointer dereference and be reproduced on Safari Tech Preview
Product: WebKit Reporter: wz906234737
Component: DOMAssignee: Nobody <webkit-unassigned>
Status: NEW ---    
Severity: Normal CC: webkit-bug-importer, zyscoder
Priority: P2 Keywords: Gtk, InRadar
Version: WebKit Nightly Build   
Hardware: PC   
OS: Linux   
Attachments:
Description Flags
the script caused crash
none
or just using Blob none

Description wz906234737 2021-01-11 21:49:14 PST
Created attachment 417432 [details]
the script caused crash

1. Reproduce of the bug:

(1) open inspector window in `MiniBrowser`, running the following code (also attached as file) in console
(2) script:

// ===================================
(function () {
    const _1 = [new File(['content'], 'file1'),'a2']
    const _0 = new File(_1, 'file2');
    return _0.stream();	
})();
// ===================================

It will cause a `Segmentation fault` crash. Using gdb to analysis the core dump file, you can find a null pointer dereference.

Part of the backtrace:

#0  0x00007f32b1cb4322 in JSC::ArrayBufferContents::sizeInBytes() const (this=0x10) at DerivedSources/ForwardingHeaders/JavaScriptCore/ArrayBuffer.h:82                              
#1  0x00007f32b1cb4301 in JSC::ArrayBufferContents::data() const (this=0x10) at DerivedSources/ForwardingHeaders/JavaScriptCore/ArrayBuffer.h:81                                     
#2  0x00007f32b23804e8 in JSC::ArrayBuffer::data() (this=0x0) at DerivedSources/ForwardingHeaders/JavaScriptCore/ArrayBuffer.h:187
                                                --------^ null pointer here ---------

#3  0x00007f32b52745fa in WebCore::FileReaderLoader::didReceiveData(char const*, int) (this=0x7f3297ff9dc8, data=0x7f3297f2e040 "content", dataLength=7)
    at ../../../Source/WebCore/fileapi/FileReaderLoader.cpp:209
        __PRETTY_FUNCTION__ = "virtual void WebCore::FileReaderLoader::didReceiveData(const char*, int)"
        length = 7
        remainingBufferSpace = 9

p.s. If you remove the `_0.stream()`, it will be safe.

2. I also reproduce the bug on `Safari Technology Preview` version on macbook. But it cannot be reproduced on `Safari Stable` version.
Comment 1 wz906234737 2021-01-13 00:16:57 PST
Created attachment 417515 [details]
or just using Blob
Comment 2 Radar WebKit Bug Importer 2021-01-18 21:50:13 PST
<rdar://problem/73339799>