No public v8::PageAllocator implementation?

62 views
Skip to first unread message

ClearScript Developers

unread,
Oct 15, 2022, 9:54:08 AM10/15/22
to v8-dev
We got no response to this on the v8-users group, so we thought we'd try here.

"Our embedder has a custom v8::Platform implementation. In V8 10.6+, v8::Platform::GetPageAllocator is abstract, and no information is provided about how to implement it.

We're currently delegating GetPageAllocator to an instance of the default platform (created via v8::platform::NewDefaultPlatform). That seems to work but feels hacky. Before this we never had any reason to instantiate the default platform.

Is this an oversight? Most v8::Platform methods are relatively mundane – task scheduling, raw memory allocation, etc. – whereas v8::PageAllocator is quite esoteric, and many embedders would probably not know how to implement it."

Since that original post, we've run into a problem with the default platform (a deadlock at process shutdown on Windows 7 if the default platform is owned by a static object), so we're now patching V8 to expose v8::base::PageAllocator instead.

Any comments or recommendations from the V8 team?

Adam Klein

unread,
Oct 18, 2022, 6:36:13 PM10/18/22
to v8-...@googlegroups.com, clem...@chromium.org, Michael Lippautz
From git blame, it looks like this change was simply meant as a cleanup in https://chromium-review.googlesource.com/c/v8/v8/+/3780538, where the previous default implementation simply returned nullptr. So at first glance it looks like having your platform return nullptr ought to work. Adding the CL author & reviewer to this thread for confirmation.

--
--
v8-dev mailing list
v8-...@googlegroups.com
http://groups.google.com/group/v8-dev
---
You received this message because you are subscribed to the Google Groups "v8-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to v8-dev+un...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/v8-dev/b5bf5bce-37ca-4cbf-bc1c-81d0f259e74en%40googlegroups.com.

ClearScript Developers

unread,
Oct 19, 2022, 12:28:28 AM10/19/22
to v8-dev
Hmm, we implemented your suggestion and so far have NOT encountered any issues on 10.7. We had definitely tried the same thing on 10.6 and encountered crashes, but we may have misinterpreted our results.

Interestingly, there does appear to be code that dereferences the return value without checking for nullptr, but it could be a red herring.

In any case, since we can't repro any crashes at the moment, please feel free to ignore this question. Sorry about that!

BTW, the change you linked reads "All embedders override this method now, so it can be abstract." Question: To whom does "all embedders" refer? :)

Adam Klein

unread,
Oct 19, 2022, 5:54:43 PM10/19/22
to v8-...@googlegroups.com
On Tue, Oct 18, 2022 at 9:28 PM ClearScript Developers <clearsc...@gmail.com> wrote:
Hmm, we implemented your suggestion and so far have NOT encountered any issues on 10.7. We had definitely tried the same thing on 10.6 and encountered crashes, but we may have misinterpreted our results.

Interestingly, there does appear to be code that dereferences the return value without checking for nullptr, but it could be a red herring.

That's in cppgc code, which in my understanding isn't directly used by V8 (in Chromium it implements the garbage collector used for objects on the Oilpan heap).
 
In any case, since we can't repro any crashes at the moment, please feel free to ignore this question. Sorry about that!

BTW, the change you linked reads "All embedders override this method now, so it can be abstract." Question: To whom does "all embedders" refer? :)

I suspect this was shorthand for "chromium, node, and d8" which are the ones tested in our CI. Please don't take any offense, we know there are many more embedders than those :)

But thanks for raising this thread, some documentation on that method is a good idea. 
 

Michael Lippautz

unread,
Oct 20, 2022, 5:47:00 AM10/20/22
to v8-...@googlegroups.com
On Wed, Oct 19, 2022 at 11:55 PM Adam Klein <ad...@chromium.org> wrote:
On Tue, Oct 18, 2022 at 9:28 PM ClearScript Developers <clearsc...@gmail.com> wrote:
Hmm, we implemented your suggestion and so far have NOT encountered any issues on 10.7. We had definitely tried the same thing on 10.6 and encountered crashes, but we may have misinterpreted our results.

Interestingly, there does appear to be code that dereferences the return value without checking for nullptr, but it could be a red herring.

That's in cppgc code, which in my understanding isn't directly used by V8 (in Chromium it implements the garbage collector used for objects on the Oilpan heap).

It's used from V8 as well but in that case it relies on V8's platform and would get the default allocator in case none is provided.

If it's used stand-alone (PDFium) then the requirement is that the page allocator is always provided through the platform. What's missing is a fallback path for this case, feel free to file a bug. 
 

Daryl Haresign

unread,
Nov 1, 2022, 4:51:47 PM11/1/22
to v8-...@googlegroups.com
I hit this too, so I created:


On Oct 20, 2022, at 05:47, Michael Lippautz <mlip...@chromium.org> wrote:


Reply all
Reply to author
Forward
0 new messages