Skip to content

FATAL ERROR: v8::HandleScope::CreateHandle() Cannot create a handle without a HandleScope #170

Description

@mlrv

Environment

  • OS: Ubuntu 20.04
  • Node version: 20.15.1 (running inside a Docker container)
  • "@u4/opencv4nodejs": "7.1.2"
  • opencv installed without automatic build (setting OPENCV4NODEJS_DISABLE_AUTOBUILD=1), my understanding is that opencv4nodejs detects libopencv on the container and uses that
    • dpkg -l | grep libopencv -> 4.2.0+dfsg-5

Code
The offending piece of code is very simple, quite literally creating a new Mat instance from a node buffer, i.e.

import cv from '@u4/opencv4nodejs';

async function decode(buffer: Buffer) {
    const mat = await cv.imdecodeAsync(buffer);

   // ... do something with the Mat
}

What's bizarre is that things work as intended maybe once every four times. Otherwise, as soon as I hit that code path I get the following error, which crashes the whole container.

studio-1                    | FATAL ERROR: v8::HandleScope::CreateHandle() Cannot create a handle without a HandleScope
studio-1                    | ----- Native stack trace -----
studio-1                    |
studio-1                    |  1: 0xb7d164 node::OnFatalError(char const*, char const*) [node]
studio-1                    |  2: 0xeb2358 v8::Utils::ReportApiFailure(char const*, char const*) [node]
studio-1                    |  3: 0x1053a2c v8::internal::HandleScope::Extend(v8::internal::Isolate*) [node]
studio-1                    |  4: 0x1031d3c v8::internal::SaveContext::SaveContext(v8::internal::Isolate*) [node]
studio-1                    |  5: 0xeaeb40 v8::internal::ApiNatives::InstantiateFunction(v8::internal::Handle<v8::internal::FunctionTemplateInfo>, v8::internal::MaybeHandle<v8::internal::Name>) [node]
studio-1                    |  6: 0xedcb70 v8::FunctionTemplate::GetFunction(v8::Local<v8::Context>) [node]
studio-1                    |  7: 0xffffa22823b0 IoBindings::ImreadWorker::getReturnValue() [/home/node/studio/node_modules/@u4/opencv4nodejs/build/Release/opencv4nodejs.node]
studio-1                    |  8: 0xffffa2280170  [/home/node/studio/node_modules/@u4/opencv4nodejs/build/Release/opencv4nodejs.node]
studio-1                    |  9: 0xffffa2280464 Io::Imread(Nan::FunctionCallbackInfo<v8::Value> const&) [/home/node/studio/node_modules/@u4/opencv4nodejs/build/Release/opencv4nodejs.node]
studio-1                    | 10: 0xffffa214107c  [/home/node/studio/node_modules/@u4/opencv4nodejs/build/Release/opencv4nodejs.node]
studio-1                    | 11: 0xf1e378 v8::internal::FunctionCallbackArguments::Call(v8::internal::CallHandlerInfo) [node]
studio-1                    | 12: 0xf1eb38  [node]
studio-1                    | 13: 0xf1ef50 v8::internal::Builtin_HandleApiCall(int, unsigned long*, v8::internal::Isolate*) [node]
studio-1                    | 14: 0x189c964  [node]

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions