get-windows: Crashes when running with Node v14.x or Electron v12.x

Windows 10
Electron v12.0.1 active-win v6.3.0 (same behavior with active-win v6.2.0)

While running with Electron v11.x everything works fine. But with v12 have next errors:

  # Fatal error in , line 0
  # ignored
  #
  #
  #
  #FailureMessage Object: 0000007D3B1FA9E0
1: 00007FF78B8F49FF node::OnFatalError+70575
  2: 00007FF78C7769CA v8::FunctionTemplate::RemovePrototype+598138
   3: 00007FF78A6BD37A v8::ArrayBuffer::GetBackingStore+922
   4: 00007FF78A6BD03F v8::ArrayBuffer::GetBackingStore+95
   5: 00007FF78BBAC499 napi_get_typedarray_info+425
6: 00007FFFA35FBF15 FFI::WrapPointer<_ffi_type>+213 [c:\abc\node_modules\ffi-napi\src\ffi.h]:L37
7: 00007FFFA3600576 FFI::FFI::InitializeBindings+4486 [c:\abc\node_modules\ffi-napi\src\ffi.cc]:L117
   8: 00007FFFA35FF062 Init+82 [c:\abc\node_modules\ffi-napi\src\ffi.cc]:L304
  9: 00007FFFA35FBE1F Napi::details::WrapCallback<<lambda_8c7377a71108815b2eee34f099f4cb99> >+63 [c:\abc\node_modules\ffi-napi\node_modules\node-addon-api\napi-inl.h]:L104
  10: 00007FFFA35FA1A1 __napi_Init+81 [c:\abc\node_modules\ffi-napi\src\ffi.cc]:L309
  11: 00007FF78B9DA793 node::PromiseRejectCallback+3843
  12: 00007FF78B8D6825 node::binding::get_linked_module+2725
  13: 00007FF78B8D582C node_module_register+2652
  14: 00007FF78C224D31 v8::Object::SetLazyDataProperty+479777
  15: 00007FF78C22477C v8::Object::SetLazyDataProperty+478316
  16: 00007FF78C2244EB v8::Object::SetLazyDataProperty+477659
  17: 00007FF78C2243A7 v8::Object::SetLazyDataProperty+477335
  18: 00007FF78B5A589C v8_inspector::protocol::Binary::operator=+455164

### etc etc etc upt to 100 lines...

Possible because of Electron v12 started to use node v14.x. In Electron v11 it was node.js v12.x

About this issue

  • Original URL
  • State: closed
  • Created 3 years ago
  • Comments: 19 (4 by maintainers)

Most upvoted comments

Just tried. On the Windows 10 with Electron 12 and active-win 7. The whole app crashes when I try to get activeWindow for the same window more than one time.

It shows me the next error

#
# Fatal error in , line 0
# ignored
#
#
#
#FailureMessage Object: 00000045769FC720
 1: 00007FF66F365FDF node::OnFatalError+70575
 2: 00007FF6701E8DAA v8::FunctionTemplate::RemovePrototype+591962
 3: 00007FF66E131C9A v8::ArrayBuffer::GetBackingStore+922
 4: 00007FF66E13195F v8::ArrayBuffer::GetBackingStore+95
 5: 00007FF66F61E139 napi_get_typedarray_info+425
 6: 00007FF9C9372B7C `anonymous namespace'::WrapPointer+204 [c:\abc\node_modules\ref-struct-napi\node_modules\ref-napi\src\binding.cc]:L106
 7: 00007FF9C9372FBB `anonymous namespace'::ReadPointer+171 [c:\abc\node_modules\ref-struct-napi\node_modules\ref-napi\src\binding.cc]:L177
 8: 00007FF9C93779A9 Napi::details::WrapCallback<<lambda_4b130013be4a466940e6fe08d32cda83> >+73 [c:\abc\node_modules\ref-struct-napi\node_modules\node-addon-api\napi-
inl.h]:L76
 9: 00007FF9C93778B3 Napi::details::CallbackData<Napi::Value (__cdecl*)(Napi::CallbackInfo const &),Napi::Value>::Wrapper+51 [c:\abc\node_modules\ref-struct-napi\node
_modules\node-addon-api\napi-inl.h]:L99
10: 00007FF66F61FC5A napi_is_detached_arraybuffer+330
11: 00007FF66FC975B1 v8::Object::SetLazyDataProperty+479777
12: 00007FF66FC96FFC v8::Object::SetLazyDataProperty+478316
13: 00007FF66FC96D6B v8::Object::SetLazyDataProperty+477659
14: 00007FF66FC96C27 v8::Object::SetLazyDataProperty+477335
15: 00007FF66F01653C v8_inspector::protocol::Binary::operator=+455148
16: 00007FF66EFAFA2F v8_inspector::protocol::Binary::operator=+34527
17: 00007FF66EFAFA2F v8_inspector::protocol::Binary::operator=+34527
18: 00007FF66EFAFA2F v8_inspector::protocol::Binary::operator=+34527
19: 00007FF66EFAFA2F v8_inspector::protocol::Binary::operator=+34527
20: 00007FF66EFAFA2F v8_inspector::protocol::Binary::operator=+34527
21: 00007FF66EFAFA2F v8_inspector::protocol::Binary::operator=+34527
22: 00007FF66EFAFA2F v8_inspector::protocol::Binary::operator=+34527
23: 00007FF66EFAFA2F v8_inspector::protocol::Binary::operator=+34527
24: 00007FF66EFAFA2F v8_inspector::protocol::Binary::operator=+34527
25: 00007FF66EFAFA2F v8_inspector::protocol::Binary::operator=+34527
26: 00007FF66EFAD67B v8_inspector::protocol::Binary::operator=+25387
27: 00007FF66EFAD2CC v8_inspector::protocol::Binary::operator=+24444
28: 00007FF66F9DC2B4 Cr_z_deflate+100052
29: 00007FF66F9DA442 Cr_z_deflate+92258
30: 00007FF66FA9CD5D v8::Function::Call+365
31: 00007FF66F33D9BD node::EmitAsyncDestroy+202365
32: 00007FF66F36CA14 uv_timer_get_due_in+180
33: 00007FF66F36FAE6 uv_run+150
34: 00007FF66EEC889E node::AsyncResource::CallbackScope::~CallbackScope+1254542
35: 00007FF66F9BA159 v8::MicrotasksScope::PerformCheckpoint+35209
36: 00007FF66F9B8095 v8::MicrotasksScope::PerformCheckpoint+26821
37: 00007FF66F9B7ABD v8::MicrotasksScope::PerformCheckpoint+25325
38: 00007FF66FBE0DE6 v8::Isolate::AdjustAmountOfExternalAllocatedMemory+178470
39: 00007FF66D1F56F1 uv_os_getpid+106177
40: 00007FF66DB3360C std::__1::vector<v8::CpuProfileDeoptInfo,std::__1::allocator<v8::CpuProfileDeoptInfo> >::vector<v8::CpuProfileDeoptInfo,std::__1::allocator<v8::CpuProfileDeoptInfo> >+120268
41: 00007FF66D8B47E6 v8::FunctionTemplate::SetLength+113062
42: 00007FF6710F9AA6 v8::CodeEvent::GetScriptName+1348598
43: 00007FF66E0D0E61 v8::Isolate::LowMemoryNotification+8529
44: 00007FF66DD462E3 v8::Isolate::IsolateInBackgroundNotification+58115
45: 00007FF66DD42702 v8::Isolate::IsolateInBackgroundNotification+42786
46: 00007FF66EFA13BC uv_fs_get_type+264252
47: 00007FF66DFDB9A9 std::__1::__vector_base<v8::CpuProfileDeoptFrame,std::__1::allocator<v8::CpuProfileDeoptFrame> >::~__vector_base<v8::CpuProfileDeoptFrame,std::__1::allocator<v8::CpuProfileDeoptFrame> >+12
4681
48: 00007FF66DFDB55D std::__1::__vector_base<v8::CpuProfileDeoptFrame,std::__1::allocator<v8::CpuProfileDeoptFrame> >::~__vector_base<v8::CpuProfileDeoptFrame,std::__1::allocator<v8::CpuProfileDeoptFrame> >+12
3581
49: 00007FF66ED93DC6 GetHandleVerifier+4239318
50: 00007FF6701AA082 v8::FunctionTemplate::RemovePrototype+334642
51: 00007FF9DD997034 BaseThreadInitThunk+20
52: 00007FF9DEC22651 RtlUserThreadStart+33

@liuzhengdong2
We are talking here about the crash when you try to get window info of the same window more than one time. Try to update your code to the:

let activeWindow = require('./index.js')
console.log(activeWindow.sync())
console.log(activeWindow.sync())

Experiencing the same issue! If the current active window is the same as the previous active window, the script crashes. active-win@7.1.0, node v14.16.1, Windows 10 20H2 19042.870 (Did not use Electron or other npm dependencies. It’s a “fresh” project.)

#
# Fatal error in , line 0
# Check failed: result.second.
#
#
#
#FailureMessage Object: 0000001E5E6FDF40
 1: 00007FF65B19046F napi_wrap+109311
 2: 00007FF65B0C4C4F std::basic_ostream<char,std::char_traits<char> >::operator<<+57167
 3: 00007FF65BCFFAA2 V8_Fatal+162
 4: 00007FF65B7A339D v8::internal::BackingStore::Reallocate+653
 5: 00007FF65B9E9689 v8::ArrayBuffer::GetBackingStore+137
 6: 00007FF65B172349 napi_get_typedarray_info+393
 7: 00007FF875817AC1
 8: 00007FF8758174DC
 9: 00007FF87581C220
10: 00007FF87581846E
11: 00007FF875817827
12: 00007FF87581CCF3
13: 00007FF65B16CC66 node::Stop+35078
14: 00007FF65B9AFC2F v8::internal::Builtins::builtin_handle+321439
15: 00007FF65B9AF1C4 v8::internal::Builtins::builtin_handle+318772
16: 00007FF65B9AF4B7 v8::internal::Builtins::builtin_handle+319527
17: 00007FF65B9AF303 v8::internal::Builtins::builtin_handle+319091
18: 00007FF65BA8B5ED v8::internal::SetupIsolateDelegate::SetupHeap+464173
19: 00007FF65BA23EF2 v8::internal::SetupIsolateDelegate::SetupHeap+40498
20: 00007FF65BA23EF2 v8::internal::SetupIsolateDelegate::SetupHeap+40498
21: 00007FF65BA23EF2 v8::internal::SetupIsolateDelegate::SetupHeap+40498
22: 00007FF65BA23EF2 v8::internal::SetupIsolateDelegate::SetupHeap+40498
23: 00007FF65BA23EF2 v8::internal::SetupIsolateDelegate::SetupHeap+40498
24: 00007FF65BA23EF2 v8::internal::SetupIsolateDelegate::SetupHeap+40498
25: 00007FF65BA23EF2 v8::internal::SetupIsolateDelegate::SetupHeap+40498
26: 00007FF65BA23EF2 v8::internal::SetupIsolateDelegate::SetupHeap+40498
27: 00007FF65BA23EF2 v8::internal::SetupIsolateDelegate::SetupHeap+40498
28: 00007FF65BA23EF2 v8::internal::SetupIsolateDelegate::SetupHeap+40498
29: 00007FF65BA23EF2 v8::internal::SetupIsolateDelegate::SetupHeap+40498
30: 00007FF65BA21BAE v8::internal::SetupIsolateDelegate::SetupHeap+31470
31: 00007FF65BA2179C v8::internal::SetupIsolateDelegate::SetupHeap+30428
32: 00007FF65B8F1C41 v8::internal::Execution::CallWasm+1649
33: 00007FF65B8F14AF v8::internal::Execution::Call+191
34: 00007FF65B9DCD07 v8::Function::Call+615
35: 00007FF65B18F41B napi_wrap+105131
36: 00007FF65B1E7874 uv_req_type_name+996
37: 00007FF65B1E4032 uv_run+194
38: 00007FF65B0F0125 v8::internal::OrderedHashTable<v8::internal::OrderedHashMap,2>::NumberOfBucketsOffset+9365
39: 00007FF65B1638D7 node::Start+311
40: 00007FF65AFC676C RC4_options+339564
41: 00007FF65BF6740C v8::internal::compiler::RepresentationChanger::Uint32OverflowOperatorFor+152316
42: 00007FF8ABE37034 BaseThreadInitThunk+20
43: 00007FF8ACE82651 RtlUserThreadStart+33

Can confirm using ref-struct-di fixed it on node 14.7. @sindresorhus can I send a PR with this fix?

Package ref-napi is incompatible with ref-struct-napi https://github.com/node-ffi-napi/ref-napi#incompatible-packages. I try to use ref-struct-di and seems it fixed crash on Electron 12 (win32)

Experiencing the same here with Node 14.x and Electron 12.x. Did some local tests and the error happens when calling user32.GetForegroundWindow(); a second time. Did another test without running active-win but ffi-napi directly and had the same issue. This makes me believe that the problem is not related to this package but related to https://github.com/node-ffi-napi/node-ffi-napi

@liuzhengdong2 We are talking here about the crash when you try to get window info of the same window more than one time. Try to update your code to the:

let activeWindow = require('./index.js')
console.log(activeWindow.sync())
console.log(activeWindow.sync())

well, i encouter this problem too in this situation, sorry.