WebKit Bugzilla
New
Browse
Log In
×
Sign in with GitHub
or
Remember my login
Create Account
·
Forgot Password
Forgotten password account recovery
RESOLVED FIXED
235880
WeakRef deref can return null instead of undefined
https://bugs.webkit.org/show_bug.cgi?id=235880
Summary
WeakRef deref can return null instead of undefined
Stef Busking
Reported
2022-01-31 01:51:25 PST
Seen in Safari 15.1, 15.2 (macOS) and Epiphany 41.3 (Linux) According to the ECMAScript specification (
https://tc39.es/ecma262/multipage/managing-memory.html#sec-weakrefderef
), a WeakRef's deref method should either return the referenced object or `undefined`. This behaves as expected in Chrome, Firefox and Edge, but it seems that in WebKit browsers this method may return `null` instead. I've confirmed this behavior using the following in the dev tools console: ``` a = new WeakRef(new ArrayBuffer(10000000)) // wait a while to allow GC to clean up the ArrayBuffer a.deref() ``` I'm not sure if Webkit browsers have a way to force garbage collection, but waiting a while or using other tabs seems to work for triggering this issue most of the time. Firefox allows forcing GC on about:memory, Chrome and Edge provide a button for this on the Memory tab of their dev tools. Expected behavior: a.deref() returns undefined (happens in Chrome, Firefox and Edge) Actual behavior: a.deref() returns null in Safari and Epiphany
Attachments
Patch
(2.69 KB, patch)
2022-02-04 17:04 PST
,
Yusuke Suzuki
no flags
Details
Formatted Diff
Diff
Patch
(6.19 KB, patch)
2022-02-04 17:14 PST
,
Yusuke Suzuki
ashvayka
: review+
Details
Formatted Diff
Diff
Show Obsolete
(1)
View All
Add attachment
proposed patch, testcase, etc.
Radar WebKit Bug Importer
Comment 1
2022-02-04 16:18:02 PST
<
rdar://problem/88513359
>
Yusuke Suzuki
Comment 2
2022-02-04 17:04:46 PST
Created
attachment 450955
[details]
Patch
Yusuke Suzuki
Comment 3
2022-02-04 17:14:24 PST
Created
attachment 450956
[details]
Patch
Alexey Shvayka
Comment 4
2022-02-04 17:26:52 PST
Comment on
attachment 450956
[details]
Patch View in context:
https://bugs.webkit.org/attachment.cgi?id=450956&action=review
> Source/JavaScriptCore/ChangeLog:8 > + WeakRef#deref should return undefined when a wrapped object is collected.
nit: a spec link perhaps?
https://tc39.es/ecma262/#sec-weakrefderef
Yusuke Suzuki
Comment 5
2022-02-04 17:27:18 PST
Thanks Sam and Alexey!
Yusuke Suzuki
Comment 6
2022-02-04 18:00:33 PST
Comment on
attachment 450956
[details]
Patch View in context:
https://bugs.webkit.org/attachment.cgi?id=450956&action=review
>> Source/JavaScriptCore/ChangeLog:8 >> + WeakRef#deref should return undefined when a wrapped object is collected. > > nit: a spec link perhaps?
https://tc39.es/ecma262/#sec-weakrefderef
Nice, done.
Yusuke Suzuki
Comment 7
2022-02-04 23:27:04 PST
Committed
r289152
(
246848@trunk
): <
https://commits.webkit.org/246848@trunk
>
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