Node 插件在 Electron 中崩溃,但在 vanilla Node 中工作正常

发布于 2025-01-11 11:23:59 字数 26204 浏览 0 评论 0原文

我正在 macOS 上构建一个 Node 插件来与 Apple 的照片框架进行通信,它将查询照片库中的照片并将其导出到文件夹中。

该插件在 vanilla Node (v16.14.0) 中运行良好,但在 Electron 中崩溃。我使用的是 Electron 版本 17.0,并且使用以下命令重建了插件:

node-gyp rebuild --target=17.0.0 --arch=x64 --dist-url=https://electronjs.org/headers

崩溃发生在 [PHAsset fetchAssetsWithLocalIdentifiers:options] 内,如果我添加一些日志,这是对 Photos 框架的第一次调用在此调用之前,将打印日志。

这是完整的崩溃报告:

-------------------------------------
Translated Report (Full Report Below)
-------------------------------------

Process:               Electron [34152]
Path:                  /Users/USER/*/Electron.app/Contents/MacOS/Electron
Identifier:            com.github.Electron
Version:               17.0.0 (17.0.0)
Code Type:             X86-64 (Native)
Parent Process:        node [33869]
Responsible:           Terminal [1129]
User ID:               501

Date/Time:             2022-03-03 16:33:30.4984 -0500
OS Version:            macOS 12.2.1 (21D62)
Report Version:        12
Bridge OS Version:     6.2 (19P744)
Anonymous UUID:        28E2F822-6FAD-09FC-E935-ECD9E9089417

Sleep/Wake UUID:       1E7186D6-E1F4-46B5-A327-C99D4697F0BD

Time Awake Since Boot: 190000 seconds
Time Since Wake:       825 seconds

System Integrity Protection: enabled

Crashed Thread:        29

Exception Type:        EXC_BAD_ACCESS (SIGSEGV)
Exception Codes:       KERN_INVALID_ADDRESS at 0x0000000000000000
Exception Codes:       0x0000000000000001, 0x0000000000000000
Exception Note:        EXC_CORPSE_NOTIFY

Termination Reason:    Namespace SIGNAL, Code 11 Segmentation fault: 11
Terminating Process:   exc handler [34152]

VM Region Info: 0 is not in any region.  Bytes before following region: 4377473024
      REGION TYPE                    START - END         [ VSIZE] PRT/MAX SHRMOD  REGION DETAIL
      UNUSED SPACE AT START
--->  
      __TEXT                      104eaf000-104eb1000    [    8K] r-x/r-x SM=COW  ...acOS/Electron

Thread 0:: CrBrowserMain Dispatch queue: com.apple.main-thread
0   libsystem_kernel.dylib              0x7ff8040f4aba mach_msg_trap + 10
1   libsystem_kernel.dylib              0x7ff8040f4e2b mach_msg + 59
2   CoreFoundation                      0x7ff8041f8af2 __CFRunLoopServiceMachPort + 319
3   CoreFoundation                      0x7ff8041f71cb __CFRunLoopRun + 1325
4   CoreFoundation                      0x7ff8041f65dd CFRunLoopRunSpecific + 563
5   HIToolbox                           0x7ff80ce334f1 RunCurrentEventLoopInMode + 292
6   HIToolbox                           0x7ff80ce33247 ReceiveNextEventCommon + 587
7   HIToolbox                           0x7ff80ce32fe5 _BlockUntilNextEventMatchingListInModeWithFilter + 70
8   AppKit                              0x7ff806c25d88 _DPSNextEvent + 886
9   AppKit                              0x7ff806c243f4 -[NSApplication(NSEvent) _nextEventMatchingEventMask:untilDate:inMode:dequeue:] + 1411
10  AppKit                              0x7ff806c16919 -[NSApplication run] + 586
11  Electron Framework                     0x110aea116 node::AsyncResource::get_async_id() const + 8894342
12  Electron Framework                     0x110ae89e2 node::AsyncResource::get_async_id() const + 8888402
13  Electron Framework                     0x110aab96a node::AsyncResource::get_async_id() const + 8638426
14  Electron Framework                     0x110a75871 node::AsyncResource::get_async_id() const + 8416993
15  Electron Framework                     0x10fd7b424 v8::internal::SetupIsolateDelegate::SetupHeap(v8::internal::Heap*) + 5186084
16  Electron Framework                     0x10fd7cd62 v8::internal::SetupIsolateDelegate::SetupHeap(v8::internal::Heap*) + 5192546
17  Electron Framework                     0x10fd78b30 v8::internal::SetupIsolateDelegate::SetupHeap(v8::internal::Heap*) + 5175600
18  Electron Framework                     0x10df2e255 v8::internal::ExternalReference::fast_c_call_caller_pc_address(v8::internal::Isolate*) + 1957
19  Electron Framework                     0x10df2f423 v8::internal::ExternalReference::fast_c_call_caller_pc_address(v8::internal::Isolate*) + 6515
20  Electron Framework                     0x10df2eea1 v8::internal::ExternalReference::fast_c_call_caller_pc_address(v8::internal::Isolate*) + 5105
21  Electron Framework                     0x10df2d45d v8::internal::compiler::BasicBlock::set_loop_header(v8::internal::compiler::BasicBlock*) + 12189
22  Electron Framework                     0x10df2dd93 v8::internal::ExternalReference::fast_c_call_caller_pc_address(v8::internal::Isolate*) + 739
23  Electron Framework                     0x10dc60be8 ElectronMain + 152
24  dyld                                   0x10db944fe start + 462

Thread 1:
0   libsystem_pthread.dylib             0x7ff80412cfec start_wqthread + 0

Thread 2:
0   libsystem_pthread.dylib             0x7ff80412cfec start_wqthread + 0

Thread 3:
0   libsystem_pthread.dylib             0x7ff80412cfec start_wqthread + 0

Thread 4:: ThreadPoolServiceThread
0   libsystem_kernel.dylib              0x7ff8040fd9c6 kevent64 + 10
1   Electron Framework                     0x110b14970 operator delete[](void*) + 138448
2   Electron Framework                     0x110aab96a node::AsyncResource::get_async_id() const + 8638426
3   Electron Framework                     0x110a75871 node::AsyncResource::get_async_id() const + 8416993
4   Electron Framework                     0x110ac78a8 node::AsyncResource::get_async_id() const + 8752920
5   Electron Framework                     0x110ab4fed node::AsyncResource::get_async_id() const + 8676957
6   Electron Framework                     0x110ac7a3d node::AsyncResource::get_async_id() const + 8753325
7   Electron Framework                     0x110ae40b5 node::AsyncResource::get_async_id() const + 8869669
8   libsystem_pthread.dylib             0x7ff8041314f4 _pthread_start + 125
9   libsystem_pthread.dylib             0x7ff80412d00f thread_start + 15

Thread 5:: ThreadPoolForegroundWorker
0   libsystem_kernel.dylib              0x7ff8040f4aba mach_msg_trap + 10
1   libsystem_kernel.dylib              0x7ff8040f4e2b mach_msg + 59
2   Electron Framework                     0x110af06af node::AsyncResource::get_async_id() const + 8920351
3   Electron Framework                     0x110ac0f20 node::AsyncResource::get_async_id() const + 8725904
4   Electron Framework                     0x110ac1ab4 node::AsyncResource::get_async_id() const + 8728868
5   Electron Framework                     0x110ac153d node::AsyncResource::get_async_id() const + 8727469
6   Electron Framework                     0x110ae40b5 node::AsyncResource::get_async_id() const + 8869669
7   libsystem_pthread.dylib             0x7ff8041314f4 _pthread_start + 125
8   libsystem_pthread.dylib             0x7ff80412d00f thread_start + 15

Thread 6:: ThreadPoolBackgroundWorker
0   libsystem_kernel.dylib              0x7ff8040f4aba mach_msg_trap + 10
1   libsystem_kernel.dylib              0x7ff8040f4e2b mach_msg + 59
2   Electron Framework                     0x110af06af node::AsyncResource::get_async_id() const + 8920351
3   Electron Framework                     0x110ac0f20 node::AsyncResource::get_async_id() const + 8725904
4   Electron Framework                     0x110ac1ab4 node::AsyncResource::get_async_id() const + 8728868
5   Electron Framework                     0x110ac14ad node::AsyncResource::get_async_id() const + 8727325
6   Electron Framework                     0x110ae40b5 node::AsyncResource::get_async_id() const + 8869669
7   libsystem_pthread.dylib             0x7ff8041314f4 _pthread_start + 125
8   libsystem_pthread.dylib             0x7ff80412d00f thread_start + 15

Thread 7:: ThreadPoolForegroundWorker
0   libsystem_kernel.dylib              0x7ff8040f4aba mach_msg_trap + 10
1   libsystem_kernel.dylib              0x7ff8040f4e2b mach_msg + 59
2   Electron Framework                     0x110af06af node::AsyncResource::get_async_id() const + 8920351
3   Electron Framework                     0x110ac0f20 node::AsyncResource::get_async_id() const + 8725904
4   Electron Framework                     0x110ac1ab4 node::AsyncResource::get_async_id() const + 8728868
5   Electron Framework                     0x110ac153d node::AsyncResource::get_async_id() const + 8727469
6   Electron Framework                     0x110ae40b5 node::AsyncResource::get_async_id() const + 8869669
7   libsystem_pthread.dylib             0x7ff8041314f4 _pthread_start + 125
8   libsystem_pthread.dylib             0x7ff80412d00f thread_start + 15

Thread 8:: Chrome_IOThread
0   libsystem_kernel.dylib              0x7ff8040fd9c6 kevent64 + 10
1   Electron Framework                     0x110b14970 operator delete[](void*) + 138448
2   Electron Framework                     0x110aab96a node::AsyncResource::get_async_id() const + 8638426
3   Electron Framework                     0x110a75871 node::AsyncResource::get_async_id() const + 8416993
4   Electron Framework                     0x110ac78a8 node::AsyncResource::get_async_id() const + 8752920
5   Electron Framework                     0x10fd7e0bf v8::internal::SetupIsolateDelegate::SetupHeap(v8::internal::Heap*) + 5197503
6   Electron Framework                     0x110ac7a3d node::AsyncResource::get_async_id() const + 8753325
7   Electron Framework                     0x110ae40b5 node::AsyncResource::get_async_id() const + 8869669
8   libsystem_pthread.dylib             0x7ff8041314f4 _pthread_start + 125
9   libsystem_pthread.dylib             0x7ff80412d00f thread_start + 15

Thread 9:: MemoryInfra
0   libsystem_kernel.dylib              0x7ff8040f4aba mach_msg_trap + 10
1   libsystem_kernel.dylib              0x7ff8040f4e2b mach_msg + 59
2   Electron Framework                     0x110af06af node::AsyncResource::get_async_id() const + 8920351
3   Electron Framework                     0x110af053e node::AsyncResource::get_async_id() const + 8919982
4   Electron Framework                     0x110a5650c node::AsyncResource::get_async_id() const + 8289148
5   Electron Framework                     0x110aab96a node::AsyncResource::get_async_id() const + 8638426
6   Electron Framework                     0x110a75871 node::AsyncResource::get_async_id() const + 8416993
7   Electron Framework                     0x110ac78a8 node::AsyncResource::get_async_id() const + 8752920
8   Electron Framework                     0x110ac7a3d node::AsyncResource::get_async_id() const + 8753325
9   Electron Framework                     0x110ae40b5 node::AsyncResource::get_async_id() const + 8869669
10  libsystem_pthread.dylib             0x7ff8041314f4 _pthread_start + 125
11  libsystem_pthread.dylib             0x7ff80412d00f thread_start + 15

Thread 10:
0   libsystem_kernel.dylib              0x7ff8040f945e kevent + 10
1   Electron Framework                     0x10dc6021e uv_free_interface_addresses + 1310
2   Electron Framework                     0x10dc4eff0 uv_run + 320
3   Electron Framework                     0x114399ecf node::CommonEnvironmentSetup::context() const + 164335
4   libsystem_pthread.dylib             0x7ff8041314f4 _pthread_start + 125
5   libsystem_pthread.dylib             0x7ff80412d00f thread_start + 15

Thread 11:
0   libsystem_kernel.dylib              0x7ff8040f7506 __psynch_cvwait + 10
1   libsystem_pthread.dylib             0x7ff804131a69 _pthread_cond_wait + 1224
2   Electron Framework                     0x10dc5add9 uv_cond_wait + 9
3   Electron Framework                     0x11439a0a2 node::CommonEnvironmentSetup::context() const + 164802
4   Electron Framework                     0x114397a77 node::CommonEnvironmentSetup::context() const + 155031
5   libsystem_pthread.dylib             0x7ff8041314f4 _pthread_start + 125
6   libsystem_pthread.dylib             0x7ff80412d00f thread_start + 15

Thread 12:
0   libsystem_kernel.dylib              0x7ff8040f7506 __psynch_cvwait + 10
1   libsystem_pthread.dylib             0x7ff804131a69 _pthread_cond_wait + 1224
2   Electron Framework                     0x10dc5add9 uv_cond_wait + 9
3   Electron Framework                     0x11439a0a2 node::CommonEnvironmentSetup::context() const + 164802
4   Electron Framework                     0x114397a77 node::CommonEnvironmentSetup::context() const + 155031
5   libsystem_pthread.dylib             0x7ff8041314f4 _pthread_start + 125
6   libsystem_pthread.dylib             0x7ff80412d00f thread_start + 15

Thread 13:
0   libsystem_kernel.dylib              0x7ff8040f7506 __psynch_cvwait + 10
1   libsystem_pthread.dylib             0x7ff804131a69 _pthread_cond_wait + 1224
2   Electron Framework                     0x10dc5add9 uv_cond_wait + 9
3   Electron Framework                     0x11439a0a2 node::CommonEnvironmentSetup::context() const + 164802
4   Electron Framework                     0x114397a77 node::CommonEnvironmentSetup::context() const + 155031
5   libsystem_pthread.dylib             0x7ff8041314f4 _pthread_start + 125
6   libsystem_pthread.dylib             0x7ff80412d00f thread_start + 15

Thread 14:
0   libsystem_kernel.dylib              0x7ff8040f4af6 semaphore_wait_trap + 10
1   Electron Framework                     0x10dc5b3d0 uv_sem_wait + 16
2   Electron Framework                     0x11440bc83 node::SetTracingController(v8::TracingController*) + 52211
3   libsystem_pthread.dylib             0x7ff8041314f4 _pthread_start + 125
4   libsystem_pthread.dylib             0x7ff80412d00f thread_start + 15

Thread 15:: NetworkConfigWatcher
0   libsystem_kernel.dylib              0x7ff8040f4aba mach_msg_trap + 10
1   libsystem_kernel.dylib              0x7ff8040f4e2b mach_msg + 59
2   CoreFoundation                      0x7ff8041f8af2 __CFRunLoopServiceMachPort + 319
3   CoreFoundation                      0x7ff8041f71cb __CFRunLoopRun + 1325
4   CoreFoundation                      0x7ff8041f65dd CFRunLoopRunSpecific + 563
5   Foundation                          0x7ff80505d66e -[NSRunLoop(NSRunLoop) runMode:beforeDate:] + 216
6   Electron Framework                     0x110ae9fa9 node::AsyncResource::get_async_id() const + 8893977
7   Electron Framework                     0x110ae89e2 node::AsyncResource::get_async_id() const + 8888402
8   Electron Framework                     0x110aab96a node::AsyncResource::get_async_id() const + 8638426
9   Electron Framework                     0x110a75871 node::AsyncResource::get_async_id() const + 8416993
10  Electron Framework                     0x110ac78a8 node::AsyncResource::get_async_id() const + 8752920
11  Electron Framework                     0x110ac7a3d node::AsyncResource::get_async_id() const + 8753325
12  Electron Framework                     0x110ae40b5 node::AsyncResource::get_async_id() const + 8869669
13  libsystem_pthread.dylib             0x7ff8041314f4 _pthread_start + 125
14  libsystem_pthread.dylib             0x7ff80412d00f thread_start + 15

Thread 16:: CrShutdownDetector
0   libsystem_kernel.dylib              0x7ff8040f54e6 read + 10
1   Electron Framework                     0x10de0b496 v8::CodeEvent::GetFunctionName() + 20854
2   Electron Framework                     0x110ae40b5 node::AsyncResource::get_async_id() const + 8869669
3   libsystem_pthread.dylib             0x7ff8041314f4 _pthread_start + 125
4   libsystem_pthread.dylib             0x7ff80412d00f thread_start + 15

Thread 17:: NetworkConfigWatcher
0   libsystem_kernel.dylib              0x7ff8040f4aba mach_msg_trap + 10
1   libsystem_kernel.dylib              0x7ff8040f4e2b mach_msg + 59
2   CoreFoundation                      0x7ff8041f8af2 __CFRunLoopServiceMachPort + 319
3   CoreFoundation                      0x7ff8041f71cb __CFRunLoopRun + 1325
4   CoreFoundation                      0x7ff8041f65dd CFRunLoopRunSpecific + 563
5   Foundation                          0x7ff80505d66e -[NSRunLoop(NSRunLoop) runMode:beforeDate:] + 216
6   Electron Framework                     0x110ae9fa9 node::AsyncResource::get_async_id() const + 8893977
7   Electron Framework                     0x110ae89e2 node::AsyncResource::get_async_id() const + 8888402
8   Electron Framework                     0x110aab96a node::AsyncResource::get_async_id() const + 8638426
9   Electron Framework                     0x110a75871 node::AsyncResource::get_async_id() const + 8416993
10  Electron Framework                     0x110ac78a8 node::AsyncResource::get_async_id() const + 8752920
11  Electron Framework                     0x110ac7a3d node::AsyncResource::get_async_id() const + 8753325
12  Electron Framework                     0x110ae40b5 node::AsyncResource::get_async_id() const + 8869669
13  libsystem_pthread.dylib             0x7ff8041314f4 _pthread_start + 125
14  libsystem_pthread.dylib             0x7ff80412d00f thread_start + 15

Thread 23:: NetworkConfigWatcher
0   libsystem_kernel.dylib              0x7ff8040f4aba mach_msg_trap + 10
1   libsystem_kernel.dylib              0x7ff8040f4e2b mach_msg + 59
2   CoreFoundation                      0x7ff8041f8af2 __CFRunLoopServiceMachPort + 319
3   CoreFoundation                      0x7ff8041f71cb __CFRunLoopRun + 1325
4   CoreFoundation                      0x7ff8041f65dd CFRunLoopRunSpecific + 563
5   Foundation                          0x7ff80505d66e -[NSRunLoop(NSRunLoop) runMode:beforeDate:] + 216
6   Electron Framework                     0x110ae9fa9 node::AsyncResource::get_async_id() const + 8893977
7   Electron Framework                     0x110ae89e2 node::AsyncResource::get_async_id() const + 8888402
8   Electron Framework                     0x110aab96a node::AsyncResource::get_async_id() const + 8638426
9   Electron Framework                     0x110a75871 node::AsyncResource::get_async_id() const + 8416993
10  Electron Framework                     0x110ac78a8 node::AsyncResource::get_async_id() const + 8752920
11  Electron Framework                     0x110ac7a3d node::AsyncResource::get_async_id() const + 8753325
12  Electron Framework                     0x110ae40b5 node::AsyncResource::get_async_id() const + 8869669
13  libsystem_pthread.dylib             0x7ff8041314f4 _pthread_start + 125
14  libsystem_pthread.dylib             0x7ff80412d00f thread_start + 15

Thread 24:: ThreadPoolSingleThreadSharedForeground1
0   libsystem_kernel.dylib              0x7ff8040f4aba mach_msg_trap + 10
1   libsystem_kernel.dylib              0x7ff8040f4e2b mach_msg + 59
2   Electron Framework                     0x110af06af node::AsyncResource::get_async_id() const + 8920351
3   Electron Framework                     0x110ac0f20 node::AsyncResource::get_async_id() const + 8725904
4   Electron Framework                     0x110ac1ab4 node::AsyncResource::get_async_id() const + 8728868
5   Electron Framework                     0x110ac156d node::AsyncResource::get_async_id() const + 8727517
6   Electron Framework                     0x110ae40b5 node::AsyncResource::get_async_id() const + 8869669
7   libsystem_pthread.dylib             0x7ff8041314f4 _pthread_start + 125
8   libsystem_pthread.dylib             0x7ff80412d00f thread_start + 15

Thread 25:: CacheThread_BlockFile
0   libsystem_kernel.dylib              0x7ff8040fd9c6 kevent64 + 10
1   Electron Framework                     0x110b14970 operator delete[](void*) + 138448
2   Electron Framework                     0x110aab96a node::AsyncResource::get_async_id() const + 8638426
3   Electron Framework                     0x110a75871 node::AsyncResource::get_async_id() const + 8416993
4   Electron Framework                     0x110ac78a8 node::AsyncResource::get_async_id() const + 8752920
5   Electron Framework                     0x110ac7a3d node::AsyncResource::get_async_id() const + 8753325
6   Electron Framework                     0x110ae40b5 node::AsyncResource::get_async_id() const + 8869669
7   libsystem_pthread.dylib             0x7ff8041314f4 _pthread_start + 125
8   libsystem_pthread.dylib             0x7ff80412d00f thread_start + 15

Thread 29 Crashed:
0   ???                                            0x0 ???
1   libsystem_malloc.dylib              0x7ff803f5797f malloc_zone_batch_malloc + 64
2   CoreData                            0x7ff80a136151 _PFAllocateObjects + 145
3   CoreData                            0x7ff80a25b14c +[NSManagedObjectModel _newModelFromOptimizedEncoding:error:] + 4684
4   CoreData                            0x7ff80a1355d4 -[NSManagedObjectModel(_NSInternalMethods) initWithContentsOfOptimizedURL:] + 260
5   CoreData                            0x7ff80a0e473c -[NSManagedObjectModel(_NSInternalMethods) _initWithContentsOfURL:options:] + 476
6   PhotoLibraryServices                0x7ff90c955c88 __43+[PLPersistentContainer managedObjectModel]_block_invoke + 81
7   PhotoLibraryServicesCore            0x7ffb0c42663b __pl_dispatch_once_block_invoke + 25
8   libdispatch.dylib                   0x7ff803f7acc9 _dispatch_client_callout + 8
9   libdispatch.dylib                   0x7ff803f7bec1 _dispatch_once_callout + 20
10  PhotoLibraryServicesCore            0x7ffb0c42661c pl_dispatch_once + 144
11  PhotoLibraryServices                0x7ff90c955c20 +[PLPersistentContainer managedObjectModel] + 69
12  Photos                              0x7ff90a43c413 +[PHQuery _relationshipForFetchType:predicate:] + 247
13  Photos                              0x7ff90a43c2ee -[PHQuery collectionFetchType] + 50
14  Photos                              0x7ff90a43c1d2 -[PHQuery copyWithZone:] + 204
15  Photos                              0x7ff90a43bdbd -[PHFetchResult initWithQuery:oids:registerIfNeeded:usingManagedObjectContext:] + 144
16  Photos                              0x7ff90a43bcee -[PHFetchResult initWithQuery:] + 88
17  Photos                              0x7ff90a43bc32 -[PHQuery executeQuery] + 121
18  Photos                              0x7ff90a56d6fe __51+[PHAsset fetchAssetsWithLocalIdentifiers:options:]_block_invoke + 65
19  Photos                              0x7ff90a43a7eb +[PHObject authorizationAwareFetchResultWithOptions:fetchBlock:] + 83
20  Photos                              0x7ff90a56ab06 +[PHAsset fetchAssetsWithLocalIdentifiers:options:] + 123
21  native.node                            0x10bdd54d9 -[PhotosExport exportVideoAsset:withError:] + 249 (PhotosExport.m:138)
22  native.node                            0x10bdd4ce5 -[PhotosExport exportAsset:withError:] + 101
23  native.node                            0x10bddb1e8 Napi_PhotosExport_AsyncWorker::Execute() + 120 (Napi_PhotosExport.mm:70)
24  native.node                            0x10bddb63a Napi::AsyncWorker::OnExecute(Napi::Env) + 26 (napi-inl.h:4890)
25  Electron Framework                     0x10dc4b334 uv_cancel + 740
26  libsystem_pthread.dylib             0x7ff8041314f4 _pthread_start + 125
27  libsystem_pthread.dylib             0x7ff80412d00f thread_start + 15


Thread 29 crashed with X86 Thread State (64-bit):
  rax: 0x0000000000000000  rbx: 0x0000000000000305  rcx: 0x0000000000000305  rdx: 0x0000002e01034000
  rdi: 0x0000000115e1bc40  rsi: 0x0000000000000078  rbp: 0x0000700016564de0  rsp: 0x0000700016564da8
   r8: 0x0000002e010011a0   r9: 0x0000000000000000  r10: 0x00007ff845bc3c42  r11: 0x00007ff803fc865f
  r12: 0x0000000000000078  r13: 0x00007ff845976000  r14: 0x0000002e01034000  r15: 0x0000000000000078
  rip: 0x0000000000000000  rfl: 0x0000000000010246  cr2: 0x0000000000000000
  
Logical CPU:     2
Error Code:      0x00000014 (no mapping for user instruction read)
Trap Number:     14


Binary Images:
    0x7ff8040f4000 -     0x7ff80412afff libsystem_kernel.dylib (*) <c1d58a50-5a4d-3bcb-a1fc-ec0902ce34d3> /usr/lib/system/libsystem_kernel.dylib
    0x7ff804178000 -     0x7ff80467afff com.apple.CoreFoundation (6.9) <9b112884-be6c-3c7f-9a2a-a47c491105db> /System/Library/Frameworks/CoreFoundation.framework/Versions/A/CoreFoundation
    0x7ff80ce01000 -     0x7ff80d0f8fff com.apple.HIToolbox (2.1.1) <c538aa78-7afd-3f8a-8fdb-1fc2acde6b3f> /System/Library/Frameworks/Carbon.framework/Versions/A/Frameworks/HIToolbox.framework/Versions/A/HIToolbox
    0x7ff806be7000 -     0x7ff807a78fff com.apple.AppKit (6.9) <9d3ab204-4858-3120-b002-5c38b02edec4> /System/Library/Frameworks/AppKit.framework/Versions/C/AppKit
       0x10dc47000 -        0x1157e8fff com.github.Electron.framework (*) <4c4c4453-5555-3144-a1b9-be04e254285a> /Users/USER/*/Electron.app/Contents/Frameworks/Electron Framework.framework/Versions/A/Electron Framework
       0x10db8f000 -        0x10dbfafff dyld (*) <7de33963-bbc5-3996-ba6e-f1d562c17c95> /usr/lib/dyld
    0x7ff80412b000 -     0x7ff804136fff libsystem_pthread.dylib (*) <ee564342-d8f2-396d-b642-40092cf34d82> /usr/lib/system/libsystem_pthread.dylib
    0x7ff804ffe000 -     0x7ff8053b8fff com.apple.Foundation (6.9) <bf00b016-c645-3574-b74f-4386750fb009> /System/Library/Frameworks/Foundation.framework/Versions/C/Foundation
               0x0 - 0xffffffffffffffff ??? (*) <00000000-0000-0000-0000-000000000000> ???
    0x7ff803f4c000 -     0x7ff803f77fff libsystem_malloc.dylib (*) <db7b390b-09ca-3e17-a367-5ff55dc92262> /usr/lib/system/libsystem_malloc.dylib
    0x7ff80a0e3000 -     0x7ff80a4fdfff com.apple.CoreData (120) <71b53cb4-c37f-31ff-a569-35d3c415a335> /System/Library/Frameworks/CoreData.framework/Versions/A/CoreData
    0x7ff90c947000 -     0x7ff90d0bdfff com.apple.PhotoLibraryServices (1.0) <f5a10a94-a6c6-3585-a764-87654cf58aad> /System/Library/PrivateFrameworks/PhotoLibraryServices.framework/Versions/A/PhotoLibraryServices
    0x7ffb0c3e7000 -     0x7ffb0c4c9fff com.apple.PhotoLibraryServicesCore (1.0) <cea2ad49-ab1e-3c5b-98f6-d1dd03632803> /System/Library/PrivateFrameworks/PhotoLibraryServicesCore.framework/Versions/A/PhotoLibraryServicesCore
    0x7ff803f78000 -     0x7ff803fbefff libdispatch.dylib (*) <67d92c93-aa68-34c2-964b-23e8a8d32098> /usr/lib/system/libdispatch.dylib
    0x7ff90a436000 -     0x7ff90a6effff com.apple.Photos (1.0) <bdb65359-c7da-3c43-9df7-c582914dc645> /System/Library/Frameworks/Photos.framework/Versions/A/Photos
       0x10bdd0000 -        0x10bde3fff native.node (*) <757866cd-ed17-3a56-86f3-1bb253ecc27f> /Users/USER/*/native.node

I am building a Node addon on macOS to communicate with Apple's Photos framework, it will query photos from the Photos library and export them to a folder.

The addon works well in vanilla Node (v16.14.0), but it crashes in Electron. I am using Electron version 17.0, and I have rebuilt the addon with the following command:

node-gyp rebuild --target=17.0.0 --arch=x64 --dist-url=https://electronjs.org/headers

The crash happened inside [PHAsset fetchAssetsWithLocalIdentifiers:options], this is the 1st call to Photos framework, if I add some logs before this call, the log will be printed.

Here is the full crash report:

-------------------------------------
Translated Report (Full Report Below)
-------------------------------------

Process:               Electron [34152]
Path:                  /Users/USER/*/Electron.app/Contents/MacOS/Electron
Identifier:            com.github.Electron
Version:               17.0.0 (17.0.0)
Code Type:             X86-64 (Native)
Parent Process:        node [33869]
Responsible:           Terminal [1129]
User ID:               501

Date/Time:             2022-03-03 16:33:30.4984 -0500
OS Version:            macOS 12.2.1 (21D62)
Report Version:        12
Bridge OS Version:     6.2 (19P744)
Anonymous UUID:        28E2F822-6FAD-09FC-E935-ECD9E9089417

Sleep/Wake UUID:       1E7186D6-E1F4-46B5-A327-C99D4697F0BD

Time Awake Since Boot: 190000 seconds
Time Since Wake:       825 seconds

System Integrity Protection: enabled

Crashed Thread:        29

Exception Type:        EXC_BAD_ACCESS (SIGSEGV)
Exception Codes:       KERN_INVALID_ADDRESS at 0x0000000000000000
Exception Codes:       0x0000000000000001, 0x0000000000000000
Exception Note:        EXC_CORPSE_NOTIFY

Termination Reason:    Namespace SIGNAL, Code 11 Segmentation fault: 11
Terminating Process:   exc handler [34152]

VM Region Info: 0 is not in any region.  Bytes before following region: 4377473024
      REGION TYPE                    START - END         [ VSIZE] PRT/MAX SHRMOD  REGION DETAIL
      UNUSED SPACE AT START
--->  
      __TEXT                      104eaf000-104eb1000    [    8K] r-x/r-x SM=COW  ...acOS/Electron

Thread 0:: CrBrowserMain Dispatch queue: com.apple.main-thread
0   libsystem_kernel.dylib              0x7ff8040f4aba mach_msg_trap + 10
1   libsystem_kernel.dylib              0x7ff8040f4e2b mach_msg + 59
2   CoreFoundation                      0x7ff8041f8af2 __CFRunLoopServiceMachPort + 319
3   CoreFoundation                      0x7ff8041f71cb __CFRunLoopRun + 1325
4   CoreFoundation                      0x7ff8041f65dd CFRunLoopRunSpecific + 563
5   HIToolbox                           0x7ff80ce334f1 RunCurrentEventLoopInMode + 292
6   HIToolbox                           0x7ff80ce33247 ReceiveNextEventCommon + 587
7   HIToolbox                           0x7ff80ce32fe5 _BlockUntilNextEventMatchingListInModeWithFilter + 70
8   AppKit                              0x7ff806c25d88 _DPSNextEvent + 886
9   AppKit                              0x7ff806c243f4 -[NSApplication(NSEvent) _nextEventMatchingEventMask:untilDate:inMode:dequeue:] + 1411
10  AppKit                              0x7ff806c16919 -[NSApplication run] + 586
11  Electron Framework                     0x110aea116 node::AsyncResource::get_async_id() const + 8894342
12  Electron Framework                     0x110ae89e2 node::AsyncResource::get_async_id() const + 8888402
13  Electron Framework                     0x110aab96a node::AsyncResource::get_async_id() const + 8638426
14  Electron Framework                     0x110a75871 node::AsyncResource::get_async_id() const + 8416993
15  Electron Framework                     0x10fd7b424 v8::internal::SetupIsolateDelegate::SetupHeap(v8::internal::Heap*) + 5186084
16  Electron Framework                     0x10fd7cd62 v8::internal::SetupIsolateDelegate::SetupHeap(v8::internal::Heap*) + 5192546
17  Electron Framework                     0x10fd78b30 v8::internal::SetupIsolateDelegate::SetupHeap(v8::internal::Heap*) + 5175600
18  Electron Framework                     0x10df2e255 v8::internal::ExternalReference::fast_c_call_caller_pc_address(v8::internal::Isolate*) + 1957
19  Electron Framework                     0x10df2f423 v8::internal::ExternalReference::fast_c_call_caller_pc_address(v8::internal::Isolate*) + 6515
20  Electron Framework                     0x10df2eea1 v8::internal::ExternalReference::fast_c_call_caller_pc_address(v8::internal::Isolate*) + 5105
21  Electron Framework                     0x10df2d45d v8::internal::compiler::BasicBlock::set_loop_header(v8::internal::compiler::BasicBlock*) + 12189
22  Electron Framework                     0x10df2dd93 v8::internal::ExternalReference::fast_c_call_caller_pc_address(v8::internal::Isolate*) + 739
23  Electron Framework                     0x10dc60be8 ElectronMain + 152
24  dyld                                   0x10db944fe start + 462

Thread 1:
0   libsystem_pthread.dylib             0x7ff80412cfec start_wqthread + 0

Thread 2:
0   libsystem_pthread.dylib             0x7ff80412cfec start_wqthread + 0

Thread 3:
0   libsystem_pthread.dylib             0x7ff80412cfec start_wqthread + 0

Thread 4:: ThreadPoolServiceThread
0   libsystem_kernel.dylib              0x7ff8040fd9c6 kevent64 + 10
1   Electron Framework                     0x110b14970 operator delete[](void*) + 138448
2   Electron Framework                     0x110aab96a node::AsyncResource::get_async_id() const + 8638426
3   Electron Framework                     0x110a75871 node::AsyncResource::get_async_id() const + 8416993
4   Electron Framework                     0x110ac78a8 node::AsyncResource::get_async_id() const + 8752920
5   Electron Framework                     0x110ab4fed node::AsyncResource::get_async_id() const + 8676957
6   Electron Framework                     0x110ac7a3d node::AsyncResource::get_async_id() const + 8753325
7   Electron Framework                     0x110ae40b5 node::AsyncResource::get_async_id() const + 8869669
8   libsystem_pthread.dylib             0x7ff8041314f4 _pthread_start + 125
9   libsystem_pthread.dylib             0x7ff80412d00f thread_start + 15

Thread 5:: ThreadPoolForegroundWorker
0   libsystem_kernel.dylib              0x7ff8040f4aba mach_msg_trap + 10
1   libsystem_kernel.dylib              0x7ff8040f4e2b mach_msg + 59
2   Electron Framework                     0x110af06af node::AsyncResource::get_async_id() const + 8920351
3   Electron Framework                     0x110ac0f20 node::AsyncResource::get_async_id() const + 8725904
4   Electron Framework                     0x110ac1ab4 node::AsyncResource::get_async_id() const + 8728868
5   Electron Framework                     0x110ac153d node::AsyncResource::get_async_id() const + 8727469
6   Electron Framework                     0x110ae40b5 node::AsyncResource::get_async_id() const + 8869669
7   libsystem_pthread.dylib             0x7ff8041314f4 _pthread_start + 125
8   libsystem_pthread.dylib             0x7ff80412d00f thread_start + 15

Thread 6:: ThreadPoolBackgroundWorker
0   libsystem_kernel.dylib              0x7ff8040f4aba mach_msg_trap + 10
1   libsystem_kernel.dylib              0x7ff8040f4e2b mach_msg + 59
2   Electron Framework                     0x110af06af node::AsyncResource::get_async_id() const + 8920351
3   Electron Framework                     0x110ac0f20 node::AsyncResource::get_async_id() const + 8725904
4   Electron Framework                     0x110ac1ab4 node::AsyncResource::get_async_id() const + 8728868
5   Electron Framework                     0x110ac14ad node::AsyncResource::get_async_id() const + 8727325
6   Electron Framework                     0x110ae40b5 node::AsyncResource::get_async_id() const + 8869669
7   libsystem_pthread.dylib             0x7ff8041314f4 _pthread_start + 125
8   libsystem_pthread.dylib             0x7ff80412d00f thread_start + 15

Thread 7:: ThreadPoolForegroundWorker
0   libsystem_kernel.dylib              0x7ff8040f4aba mach_msg_trap + 10
1   libsystem_kernel.dylib              0x7ff8040f4e2b mach_msg + 59
2   Electron Framework                     0x110af06af node::AsyncResource::get_async_id() const + 8920351
3   Electron Framework                     0x110ac0f20 node::AsyncResource::get_async_id() const + 8725904
4   Electron Framework                     0x110ac1ab4 node::AsyncResource::get_async_id() const + 8728868
5   Electron Framework                     0x110ac153d node::AsyncResource::get_async_id() const + 8727469
6   Electron Framework                     0x110ae40b5 node::AsyncResource::get_async_id() const + 8869669
7   libsystem_pthread.dylib             0x7ff8041314f4 _pthread_start + 125
8   libsystem_pthread.dylib             0x7ff80412d00f thread_start + 15

Thread 8:: Chrome_IOThread
0   libsystem_kernel.dylib              0x7ff8040fd9c6 kevent64 + 10
1   Electron Framework                     0x110b14970 operator delete[](void*) + 138448
2   Electron Framework                     0x110aab96a node::AsyncResource::get_async_id() const + 8638426
3   Electron Framework                     0x110a75871 node::AsyncResource::get_async_id() const + 8416993
4   Electron Framework                     0x110ac78a8 node::AsyncResource::get_async_id() const + 8752920
5   Electron Framework                     0x10fd7e0bf v8::internal::SetupIsolateDelegate::SetupHeap(v8::internal::Heap*) + 5197503
6   Electron Framework                     0x110ac7a3d node::AsyncResource::get_async_id() const + 8753325
7   Electron Framework                     0x110ae40b5 node::AsyncResource::get_async_id() const + 8869669
8   libsystem_pthread.dylib             0x7ff8041314f4 _pthread_start + 125
9   libsystem_pthread.dylib             0x7ff80412d00f thread_start + 15

Thread 9:: MemoryInfra
0   libsystem_kernel.dylib              0x7ff8040f4aba mach_msg_trap + 10
1   libsystem_kernel.dylib              0x7ff8040f4e2b mach_msg + 59
2   Electron Framework                     0x110af06af node::AsyncResource::get_async_id() const + 8920351
3   Electron Framework                     0x110af053e node::AsyncResource::get_async_id() const + 8919982
4   Electron Framework                     0x110a5650c node::AsyncResource::get_async_id() const + 8289148
5   Electron Framework                     0x110aab96a node::AsyncResource::get_async_id() const + 8638426
6   Electron Framework                     0x110a75871 node::AsyncResource::get_async_id() const + 8416993
7   Electron Framework                     0x110ac78a8 node::AsyncResource::get_async_id() const + 8752920
8   Electron Framework                     0x110ac7a3d node::AsyncResource::get_async_id() const + 8753325
9   Electron Framework                     0x110ae40b5 node::AsyncResource::get_async_id() const + 8869669
10  libsystem_pthread.dylib             0x7ff8041314f4 _pthread_start + 125
11  libsystem_pthread.dylib             0x7ff80412d00f thread_start + 15

Thread 10:
0   libsystem_kernel.dylib              0x7ff8040f945e kevent + 10
1   Electron Framework                     0x10dc6021e uv_free_interface_addresses + 1310
2   Electron Framework                     0x10dc4eff0 uv_run + 320
3   Electron Framework                     0x114399ecf node::CommonEnvironmentSetup::context() const + 164335
4   libsystem_pthread.dylib             0x7ff8041314f4 _pthread_start + 125
5   libsystem_pthread.dylib             0x7ff80412d00f thread_start + 15

Thread 11:
0   libsystem_kernel.dylib              0x7ff8040f7506 __psynch_cvwait + 10
1   libsystem_pthread.dylib             0x7ff804131a69 _pthread_cond_wait + 1224
2   Electron Framework                     0x10dc5add9 uv_cond_wait + 9
3   Electron Framework                     0x11439a0a2 node::CommonEnvironmentSetup::context() const + 164802
4   Electron Framework                     0x114397a77 node::CommonEnvironmentSetup::context() const + 155031
5   libsystem_pthread.dylib             0x7ff8041314f4 _pthread_start + 125
6   libsystem_pthread.dylib             0x7ff80412d00f thread_start + 15

Thread 12:
0   libsystem_kernel.dylib              0x7ff8040f7506 __psynch_cvwait + 10
1   libsystem_pthread.dylib             0x7ff804131a69 _pthread_cond_wait + 1224
2   Electron Framework                     0x10dc5add9 uv_cond_wait + 9
3   Electron Framework                     0x11439a0a2 node::CommonEnvironmentSetup::context() const + 164802
4   Electron Framework                     0x114397a77 node::CommonEnvironmentSetup::context() const + 155031
5   libsystem_pthread.dylib             0x7ff8041314f4 _pthread_start + 125
6   libsystem_pthread.dylib             0x7ff80412d00f thread_start + 15

Thread 13:
0   libsystem_kernel.dylib              0x7ff8040f7506 __psynch_cvwait + 10
1   libsystem_pthread.dylib             0x7ff804131a69 _pthread_cond_wait + 1224
2   Electron Framework                     0x10dc5add9 uv_cond_wait + 9
3   Electron Framework                     0x11439a0a2 node::CommonEnvironmentSetup::context() const + 164802
4   Electron Framework                     0x114397a77 node::CommonEnvironmentSetup::context() const + 155031
5   libsystem_pthread.dylib             0x7ff8041314f4 _pthread_start + 125
6   libsystem_pthread.dylib             0x7ff80412d00f thread_start + 15

Thread 14:
0   libsystem_kernel.dylib              0x7ff8040f4af6 semaphore_wait_trap + 10
1   Electron Framework                     0x10dc5b3d0 uv_sem_wait + 16
2   Electron Framework                     0x11440bc83 node::SetTracingController(v8::TracingController*) + 52211
3   libsystem_pthread.dylib             0x7ff8041314f4 _pthread_start + 125
4   libsystem_pthread.dylib             0x7ff80412d00f thread_start + 15

Thread 15:: NetworkConfigWatcher
0   libsystem_kernel.dylib              0x7ff8040f4aba mach_msg_trap + 10
1   libsystem_kernel.dylib              0x7ff8040f4e2b mach_msg + 59
2   CoreFoundation                      0x7ff8041f8af2 __CFRunLoopServiceMachPort + 319
3   CoreFoundation                      0x7ff8041f71cb __CFRunLoopRun + 1325
4   CoreFoundation                      0x7ff8041f65dd CFRunLoopRunSpecific + 563
5   Foundation                          0x7ff80505d66e -[NSRunLoop(NSRunLoop) runMode:beforeDate:] + 216
6   Electron Framework                     0x110ae9fa9 node::AsyncResource::get_async_id() const + 8893977
7   Electron Framework                     0x110ae89e2 node::AsyncResource::get_async_id() const + 8888402
8   Electron Framework                     0x110aab96a node::AsyncResource::get_async_id() const + 8638426
9   Electron Framework                     0x110a75871 node::AsyncResource::get_async_id() const + 8416993
10  Electron Framework                     0x110ac78a8 node::AsyncResource::get_async_id() const + 8752920
11  Electron Framework                     0x110ac7a3d node::AsyncResource::get_async_id() const + 8753325
12  Electron Framework                     0x110ae40b5 node::AsyncResource::get_async_id() const + 8869669
13  libsystem_pthread.dylib             0x7ff8041314f4 _pthread_start + 125
14  libsystem_pthread.dylib             0x7ff80412d00f thread_start + 15

Thread 16:: CrShutdownDetector
0   libsystem_kernel.dylib              0x7ff8040f54e6 read + 10
1   Electron Framework                     0x10de0b496 v8::CodeEvent::GetFunctionName() + 20854
2   Electron Framework                     0x110ae40b5 node::AsyncResource::get_async_id() const + 8869669
3   libsystem_pthread.dylib             0x7ff8041314f4 _pthread_start + 125
4   libsystem_pthread.dylib             0x7ff80412d00f thread_start + 15

Thread 17:: NetworkConfigWatcher
0   libsystem_kernel.dylib              0x7ff8040f4aba mach_msg_trap + 10
1   libsystem_kernel.dylib              0x7ff8040f4e2b mach_msg + 59
2   CoreFoundation                      0x7ff8041f8af2 __CFRunLoopServiceMachPort + 319
3   CoreFoundation                      0x7ff8041f71cb __CFRunLoopRun + 1325
4   CoreFoundation                      0x7ff8041f65dd CFRunLoopRunSpecific + 563
5   Foundation                          0x7ff80505d66e -[NSRunLoop(NSRunLoop) runMode:beforeDate:] + 216
6   Electron Framework                     0x110ae9fa9 node::AsyncResource::get_async_id() const + 8893977
7   Electron Framework                     0x110ae89e2 node::AsyncResource::get_async_id() const + 8888402
8   Electron Framework                     0x110aab96a node::AsyncResource::get_async_id() const + 8638426
9   Electron Framework                     0x110a75871 node::AsyncResource::get_async_id() const + 8416993
10  Electron Framework                     0x110ac78a8 node::AsyncResource::get_async_id() const + 8752920
11  Electron Framework                     0x110ac7a3d node::AsyncResource::get_async_id() const + 8753325
12  Electron Framework                     0x110ae40b5 node::AsyncResource::get_async_id() const + 8869669
13  libsystem_pthread.dylib             0x7ff8041314f4 _pthread_start + 125
14  libsystem_pthread.dylib             0x7ff80412d00f thread_start + 15

Thread 23:: NetworkConfigWatcher
0   libsystem_kernel.dylib              0x7ff8040f4aba mach_msg_trap + 10
1   libsystem_kernel.dylib              0x7ff8040f4e2b mach_msg + 59
2   CoreFoundation                      0x7ff8041f8af2 __CFRunLoopServiceMachPort + 319
3   CoreFoundation                      0x7ff8041f71cb __CFRunLoopRun + 1325
4   CoreFoundation                      0x7ff8041f65dd CFRunLoopRunSpecific + 563
5   Foundation                          0x7ff80505d66e -[NSRunLoop(NSRunLoop) runMode:beforeDate:] + 216
6   Electron Framework                     0x110ae9fa9 node::AsyncResource::get_async_id() const + 8893977
7   Electron Framework                     0x110ae89e2 node::AsyncResource::get_async_id() const + 8888402
8   Electron Framework                     0x110aab96a node::AsyncResource::get_async_id() const + 8638426
9   Electron Framework                     0x110a75871 node::AsyncResource::get_async_id() const + 8416993
10  Electron Framework                     0x110ac78a8 node::AsyncResource::get_async_id() const + 8752920
11  Electron Framework                     0x110ac7a3d node::AsyncResource::get_async_id() const + 8753325
12  Electron Framework                     0x110ae40b5 node::AsyncResource::get_async_id() const + 8869669
13  libsystem_pthread.dylib             0x7ff8041314f4 _pthread_start + 125
14  libsystem_pthread.dylib             0x7ff80412d00f thread_start + 15

Thread 24:: ThreadPoolSingleThreadSharedForeground1
0   libsystem_kernel.dylib              0x7ff8040f4aba mach_msg_trap + 10
1   libsystem_kernel.dylib              0x7ff8040f4e2b mach_msg + 59
2   Electron Framework                     0x110af06af node::AsyncResource::get_async_id() const + 8920351
3   Electron Framework                     0x110ac0f20 node::AsyncResource::get_async_id() const + 8725904
4   Electron Framework                     0x110ac1ab4 node::AsyncResource::get_async_id() const + 8728868
5   Electron Framework                     0x110ac156d node::AsyncResource::get_async_id() const + 8727517
6   Electron Framework                     0x110ae40b5 node::AsyncResource::get_async_id() const + 8869669
7   libsystem_pthread.dylib             0x7ff8041314f4 _pthread_start + 125
8   libsystem_pthread.dylib             0x7ff80412d00f thread_start + 15

Thread 25:: CacheThread_BlockFile
0   libsystem_kernel.dylib              0x7ff8040fd9c6 kevent64 + 10
1   Electron Framework                     0x110b14970 operator delete[](void*) + 138448
2   Electron Framework                     0x110aab96a node::AsyncResource::get_async_id() const + 8638426
3   Electron Framework                     0x110a75871 node::AsyncResource::get_async_id() const + 8416993
4   Electron Framework                     0x110ac78a8 node::AsyncResource::get_async_id() const + 8752920
5   Electron Framework                     0x110ac7a3d node::AsyncResource::get_async_id() const + 8753325
6   Electron Framework                     0x110ae40b5 node::AsyncResource::get_async_id() const + 8869669
7   libsystem_pthread.dylib             0x7ff8041314f4 _pthread_start + 125
8   libsystem_pthread.dylib             0x7ff80412d00f thread_start + 15

Thread 29 Crashed:
0   ???                                            0x0 ???
1   libsystem_malloc.dylib              0x7ff803f5797f malloc_zone_batch_malloc + 64
2   CoreData                            0x7ff80a136151 _PFAllocateObjects + 145
3   CoreData                            0x7ff80a25b14c +[NSManagedObjectModel _newModelFromOptimizedEncoding:error:] + 4684
4   CoreData                            0x7ff80a1355d4 -[NSManagedObjectModel(_NSInternalMethods) initWithContentsOfOptimizedURL:] + 260
5   CoreData                            0x7ff80a0e473c -[NSManagedObjectModel(_NSInternalMethods) _initWithContentsOfURL:options:] + 476
6   PhotoLibraryServices                0x7ff90c955c88 __43+[PLPersistentContainer managedObjectModel]_block_invoke + 81
7   PhotoLibraryServicesCore            0x7ffb0c42663b __pl_dispatch_once_block_invoke + 25
8   libdispatch.dylib                   0x7ff803f7acc9 _dispatch_client_callout + 8
9   libdispatch.dylib                   0x7ff803f7bec1 _dispatch_once_callout + 20
10  PhotoLibraryServicesCore            0x7ffb0c42661c pl_dispatch_once + 144
11  PhotoLibraryServices                0x7ff90c955c20 +[PLPersistentContainer managedObjectModel] + 69
12  Photos                              0x7ff90a43c413 +[PHQuery _relationshipForFetchType:predicate:] + 247
13  Photos                              0x7ff90a43c2ee -[PHQuery collectionFetchType] + 50
14  Photos                              0x7ff90a43c1d2 -[PHQuery copyWithZone:] + 204
15  Photos                              0x7ff90a43bdbd -[PHFetchResult initWithQuery:oids:registerIfNeeded:usingManagedObjectContext:] + 144
16  Photos                              0x7ff90a43bcee -[PHFetchResult initWithQuery:] + 88
17  Photos                              0x7ff90a43bc32 -[PHQuery executeQuery] + 121
18  Photos                              0x7ff90a56d6fe __51+[PHAsset fetchAssetsWithLocalIdentifiers:options:]_block_invoke + 65
19  Photos                              0x7ff90a43a7eb +[PHObject authorizationAwareFetchResultWithOptions:fetchBlock:] + 83
20  Photos                              0x7ff90a56ab06 +[PHAsset fetchAssetsWithLocalIdentifiers:options:] + 123
21  native.node                            0x10bdd54d9 -[PhotosExport exportVideoAsset:withError:] + 249 (PhotosExport.m:138)
22  native.node                            0x10bdd4ce5 -[PhotosExport exportAsset:withError:] + 101
23  native.node                            0x10bddb1e8 Napi_PhotosExport_AsyncWorker::Execute() + 120 (Napi_PhotosExport.mm:70)
24  native.node                            0x10bddb63a Napi::AsyncWorker::OnExecute(Napi::Env) + 26 (napi-inl.h:4890)
25  Electron Framework                     0x10dc4b334 uv_cancel + 740
26  libsystem_pthread.dylib             0x7ff8041314f4 _pthread_start + 125
27  libsystem_pthread.dylib             0x7ff80412d00f thread_start + 15


Thread 29 crashed with X86 Thread State (64-bit):
  rax: 0x0000000000000000  rbx: 0x0000000000000305  rcx: 0x0000000000000305  rdx: 0x0000002e01034000
  rdi: 0x0000000115e1bc40  rsi: 0x0000000000000078  rbp: 0x0000700016564de0  rsp: 0x0000700016564da8
   r8: 0x0000002e010011a0   r9: 0x0000000000000000  r10: 0x00007ff845bc3c42  r11: 0x00007ff803fc865f
  r12: 0x0000000000000078  r13: 0x00007ff845976000  r14: 0x0000002e01034000  r15: 0x0000000000000078
  rip: 0x0000000000000000  rfl: 0x0000000000010246  cr2: 0x0000000000000000
  
Logical CPU:     2
Error Code:      0x00000014 (no mapping for user instruction read)
Trap Number:     14


Binary Images:
    0x7ff8040f4000 -     0x7ff80412afff libsystem_kernel.dylib (*) <c1d58a50-5a4d-3bcb-a1fc-ec0902ce34d3> /usr/lib/system/libsystem_kernel.dylib
    0x7ff804178000 -     0x7ff80467afff com.apple.CoreFoundation (6.9) <9b112884-be6c-3c7f-9a2a-a47c491105db> /System/Library/Frameworks/CoreFoundation.framework/Versions/A/CoreFoundation
    0x7ff80ce01000 -     0x7ff80d0f8fff com.apple.HIToolbox (2.1.1) <c538aa78-7afd-3f8a-8fdb-1fc2acde6b3f> /System/Library/Frameworks/Carbon.framework/Versions/A/Frameworks/HIToolbox.framework/Versions/A/HIToolbox
    0x7ff806be7000 -     0x7ff807a78fff com.apple.AppKit (6.9) <9d3ab204-4858-3120-b002-5c38b02edec4> /System/Library/Frameworks/AppKit.framework/Versions/C/AppKit
       0x10dc47000 -        0x1157e8fff com.github.Electron.framework (*) <4c4c4453-5555-3144-a1b9-be04e254285a> /Users/USER/*/Electron.app/Contents/Frameworks/Electron Framework.framework/Versions/A/Electron Framework
       0x10db8f000 -        0x10dbfafff dyld (*) <7de33963-bbc5-3996-ba6e-f1d562c17c95> /usr/lib/dyld
    0x7ff80412b000 -     0x7ff804136fff libsystem_pthread.dylib (*) <ee564342-d8f2-396d-b642-40092cf34d82> /usr/lib/system/libsystem_pthread.dylib
    0x7ff804ffe000 -     0x7ff8053b8fff com.apple.Foundation (6.9) <bf00b016-c645-3574-b74f-4386750fb009> /System/Library/Frameworks/Foundation.framework/Versions/C/Foundation
               0x0 - 0xffffffffffffffff ??? (*) <00000000-0000-0000-0000-000000000000> ???
    0x7ff803f4c000 -     0x7ff803f77fff libsystem_malloc.dylib (*) <db7b390b-09ca-3e17-a367-5ff55dc92262> /usr/lib/system/libsystem_malloc.dylib
    0x7ff80a0e3000 -     0x7ff80a4fdfff com.apple.CoreData (120) <71b53cb4-c37f-31ff-a569-35d3c415a335> /System/Library/Frameworks/CoreData.framework/Versions/A/CoreData
    0x7ff90c947000 -     0x7ff90d0bdfff com.apple.PhotoLibraryServices (1.0) <f5a10a94-a6c6-3585-a764-87654cf58aad> /System/Library/PrivateFrameworks/PhotoLibraryServices.framework/Versions/A/PhotoLibraryServices
    0x7ffb0c3e7000 -     0x7ffb0c4c9fff com.apple.PhotoLibraryServicesCore (1.0) <cea2ad49-ab1e-3c5b-98f6-d1dd03632803> /System/Library/PrivateFrameworks/PhotoLibraryServicesCore.framework/Versions/A/PhotoLibraryServicesCore
    0x7ff803f78000 -     0x7ff803fbefff libdispatch.dylib (*) <67d92c93-aa68-34c2-964b-23e8a8d32098> /usr/lib/system/libdispatch.dylib
    0x7ff90a436000 -     0x7ff90a6effff com.apple.Photos (1.0) <bdb65359-c7da-3c43-9df7-c582914dc645> /System/Library/Frameworks/Photos.framework/Versions/A/Photos
       0x10bdd0000 -        0x10bde3fff native.node (*) <757866cd-ed17-3a56-86f3-1bb253ecc27f> /Users/USER/*/native.node

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

一片旧的回忆 2025-01-18 11:24:00

尝试使用较长形式的 AsyncWorker - 允许您设置 resource_name 甚至 async_resource 的形式。资源名称必须是调试异步堆栈跟踪时和 async_hooks API 中将出现的字符串。该资源可以是一个空的 V8 对象(通过调用 Napi::Object::New(env) 获得)。我认为这不是正常行为,也许这是 Electron 17 和 node-addon-api 之间的一个错误。如果您可以找到导致该问题的 AsyncWorker,您可以尝试在他们的 Github 上提出问题。

还要仔细检查您是否使用正确的 ABI 进行构建 - 因为 Electron 决定使用 Node.js 版本 16 ABI 发布版本 17,这也可能是原因。不要使用 CLI 选项,而是使用以下命令:

export npm_config_target=17.0.0
export npm_config_arch=x64
export npm_config_target_arch=x64
export npm_config_disturl=https://electronjs.org/headers
export npm_config_runtime=electron
export npm_config_build_from_source=true
HOME=~/.electron-gyp npm install

Try using the longer form of the AsyncWorker - the one that allows you to set a resource_name or even an async_resource. The resource name must be a string that will appear when debugging async stack traces and in the async_hooks API. The resource can be an empty V8 object (obtained by calling Napi::Object::New(env)). I don't think this is a normal behavior, maybe it is a bug somewhere between Electron 17 and node-addon-api. If you can find the AsyncWorker that is causing it, you can try opening an issue on their Github.

Also double-check that you are building with the right ABI - because Electron has decided to publish a version 17 using the Node.js version 16 ABI and this can also be the reason. Instead of using the CLI options, use this:

export npm_config_target=17.0.0
export npm_config_arch=x64
export npm_config_target_arch=x64
export npm_config_disturl=https://electronjs.org/headers
export npm_config_runtime=electron
export npm_config_build_from_source=true
HOME=~/.electron-gyp npm install
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文