Skip to content

Crash when using imencode on windows #68

@Hexer10

Description

@Hexer10

Hi there, thanks for the nice project.

I'm experiencing a crash when using the imencode function. I've tried running the code on windows both in plain Dart and on flutter and result is the same, the full code of the crash is the following:

void main()  {
  final img = File('img.jpg').readAsBytesSync(); // img.jpg is a standard jpeg image
  final mat = imdecode(img, IMREAD_COLOR);
  final data = imencode('jpg', mat); // <-- crash
}

The log printed in the console is:

===== CRASH =====
ExceptionCode=-1073741819, ExceptionFlags=0, ExceptionAddress=00007FFC977AE081
version=3.5.0-155.0.dev (dev) (Tue May 14 17:03:03 2024 -0700) on "windows_x64"
pid=13264, thread=33940, isolate_group=main(0000000002E46B60), isolate=main(0000000002E5C6F0)
os=windows, arch=x64, comp=no, sim=no
isolate_instructions=7ff618f89f70, vm_instructions=7ff618f89f80
fp=1eadef80, sp=1eadee90, pc=7ffc977ae081
  pc 0x00007ffc977ae081 fp 0x000000001eadef80 Unknown symbol
  // ...
  pc 0x0000000002782f9f fp 0x000000001eadf560 Unknown symbol
  pc 0x00007ff6190b9c1a fp 0x000000001eadfd01 Dart_DetectNullSafety+0x128d9a
-- End of DumpStackTrace
  pc 0x0000000000000000 fp 0x000000001eadef80 sp 0x0000000000000000 Cannot find code object
  pc 0x00000000041ccdb2 fp 0x000000001eadefc8 sp 0x000000001eadef90 [Optimized] CvNative.init:_VecUChar_NewFromVec@66300349.#ffiClosure794
  pc 0x00000000041cc8e8 fp 0x000000001eadf030 sp 0x000000001eadefd8 [Unoptimized] CvNative.VecUChar_NewFromVec
  pc 0x00000000041cc794 fp 0x000000001eadf070 sp 0x000000001eadf040 [Unoptimized] new VecUChar.fromVec.<anonymous closure>
  pc 0x00000000041ba596 fp 0x000000001eadf0b0 sp 0x000000001eadf080 [Unoptimized] cvRun
  pc 0x00000000041cc66f fp 0x000000001eadf0f0 sp 0x000000001eadf0c0 [Unoptimized] new VecUChar.fromVec
  pc 0x00000000041ca085 fp 0x000000001eadf140 sp 0x000000001eadf100 [Unoptimized] imencode.<anonymous closure>
  pc 0x00000000041c96b1 fp 0x000000001eadf1e0 sp 0x000000001eadf150 [Unoptimized] using
  pc 0x00000000041c943d fp 0x000000001eadf260 sp 0x000000001eadf1f0 [Unoptimized] imencode
  pc 0x00000000041ae21c fp 0x000000001eadf2b0 sp 0x000000001eadf270 [Unoptimized] main
  pc 0x00000000041ae126 fp 0x000000001eadf2d8 sp 0x000000001eadf2c0 [Unoptimized] main
  pc 0x00000000041ae05a fp 0x000000001eadf338 sp 0x000000001eadf2e8 [Unoptimized] [email protected]:call
  pc 0x00000000041acf13 fp 0x000000001eadf378 sp 0x000000001eadf348 [Unoptimized] _delayEntrypointInvocation@1026248.<anonymous closure>
  pc 0x00000000041acc5d fp 0x000000001eadf3e0 sp 0x000000001eadf388 [Unoptimized] [email protected]:call
  pc 0x00000000041abd0c fp 0x000000001eadf438 sp 0x000000001eadf3f0 [Unoptimized] _RawReceivePort@1026248._handleMessage@1026248
  pc 0x0000000002782f9f fp 0x000000001eadf560 sp 0x000000001eadf448 [Stub] InvokeDartCode

The specific code running before the program crashes it's the following:

factory VecUChar.fromVec(cvg.VecUChar ptr) {
final p = calloc<cvg.VecUChar>();
cvRun(() => CFFI.VecUChar_NewFromVec(ptr, p));
final vec = VecUChar._(p);
return vec;
}

specifically CFFI.VecUChar_NewFromVec(ptr, p) -> _VecUChar_NewFromVec(vec, rval);

Desktop (please complete the following information):

  • OS: Windows 11
  • Dart: 3.4.1 and 3.5.0-155.0.dev
  • opencv_dart: 1.0.4

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions