Skip to content

MemoryPressureNotification got executed on the wrong platform #17859

Description

@levimm

I'm using the new MultiIsolatePlatform feature added in v9.3.0.
I have following code running in a new node isolate which has its own thread loop. But it have a check failure error when trying to find isolate on the platform.

static node::MultiIsolatePlatform* platform = node::CreatePlatform(4, nullptr);
node::IsolateData* isolateData = node::CreateIsolateData(thread_isolate, thread_loop, platform);
thread_isolate->MemoryPressureNotification(v8::MemoryPressureLevel::kCritical);

The thread isolate is registered to the newly create platform when creating isolate data in line 2.
However, line 3 leads to a CHECK failure when trying to find this thread isolate because the platform instance here is returned from V8::GetCurrentPlatform() and it's not the one I created. Here's the callstack:

 1: node::Abort
 2: node::Assert
 3: node::NodePlatform::ForIsolate
 4: node::NodePlatform::CallDelayedOnForegroundThread
 5: v8::internal::Heap::CheckMemoryPressure
 6: v8::internal::Heap::MemoryPressureNotification
 7: v8::Isolate::MemoryPressureNotification

I'm not sure if I'm using this feature correctly. Could somebody advise?

Metadata

Metadata

Assignees

No one assigned

    Labels

    embeddingIssues and PRs related to embedding Node.js in another project.

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions