Bug 220531 - Calling Blob.stream() causes null pointer dereference and be reproduced on Safari Tech Preview
Summary: Calling Blob.stream() causes null pointer dereference and be reproduced on Sa...
Status: NEW
Alias: None
Product: WebKit
Classification: Unclassified
Component: DOM (show other bugs)
Version: WebKit Nightly Build
Hardware: PC Linux
: P2 Normal
Assignee: Nobody
URL:
Keywords: Gtk, InRadar
Depends on:
Blocks:
 
Reported: 2021-01-11 21:49 PST by wz906234737
Modified: 2021-04-22 07:26 PDT (History)
2 users (show)

See Also:


Attachments
the script caused crash (140 bytes, text/javascript)
2021-01-11 21:49 PST, wz906234737
no flags Details
or just using Blob (123 bytes, text/plain)
2021-01-13 00:16 PST, wz906234737
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
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>