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 27, 2024
1 parent 84ba94a commit b90127a
Show file tree
Hide file tree
Showing 2 changed files with 12 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 @@ -5269,15 +5269,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
8 changes: 8 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,8 @@
// |jit-test| skip-if: !('oomTest' in this)

x = [];
x.keepFailing = [];
oomTest(function () {
y = { z: [] };
makeSerializable().log;
}, x);

0 comments on commit b90127a

Please sign in to comment.