Skip to content

Commit

Permalink
Bug 1878098 - Properly oom check test serialization log allocation r=…
Browse files Browse the repository at this point in the history
…spidermonkey-reviewers,mgaudet

Differential Revision: https://phabricator.services.mozilla.com/D202269
  • Loading branch information
hotsphink committed Feb 21, 2024
1 parent 70b547d commit 9b01a71
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
6 changes: 4 additions & 2 deletions js/src/builtin/TestingFunctions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5264,15 +5264,17 @@ class CustomSerializableObject : public NativeObject {
static ActivityLog* getThreadLog() {
if (!self.initialized() || !self.get()) {
self.infallibleInit();
AutoEnterOOMUnsafeRegion oomUnsafe;
self.set(js_new<ActivityLog>());
MOZ_RELEASE_ASSERT(self.get());
if (!self.get()) {
oomUnsafe.crash("allocating activity log");
}
if (!TlsContext.get()->runtime()->atExit(
[](void* vpData) {
auto* log = static_cast<ActivityLog*>(vpData);
js_delete(log);
},
self.get())) {
AutoEnterOOMUnsafeRegion oomUnsafe;
oomUnsafe.crash("atExit");
}
}
Expand Down
6 changes: 6 additions & 0 deletions js/src/jit-test/tests/bug1878098-serialization-log-oom.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
x = [];
x.keepFailing = [];
oomTest(function () {
y = { z: [] };
makeSerializable().log;
}, x);

0 comments on commit 9b01a71

Please sign in to comment.