node icon indicating copy to clipboard operation
node copied to clipboard

Check failed: result.second

Open Ram4GB opened this issue 1 year ago • 10 comments

Version

v16.15.1

Platform

Microsoft Windows NT 10.0.22000.0 x64

Subsystem

No response

What steps will reproduce the bug?

  • In my package.json
"test:unit": "vitest run --mode vitest --dir \"./src/\" --coverage"
  • I use vite config, so config in vite.config.js like this:
 test: {
   global: false,
   environment: 'happy-dom',
   exclude: ['**/node_modules/**', '**/dist/**',],
   coverage: {
     reporter: [
       'html',
       'text',
     ],
   },
   logHeapUsage: true,
   deps: {
     inline: ['element-plus'],
   },
 },
  • Run the lint
npm run test:unit

How often does it reproduce? Is there a required condition?

I run test 10 times, but It just fails 2 times and show up errors on my terminal.

What is the expected behavior?

The Vitest's test cases was passed

What do you see instead?

This is some images which contains the issue conducted by me and my teammate.

I can give some example errors here

Example 1: On mac image

Example 2: On mac image

Example 3:

# Fatal error in , line 0
# Check failed: result.second.
#
#
#
#FailureMessage Object: 00000067AD1FC320
 1: 00007FF6635279CF v8::internal::CodeObjectRegistry::~CodeObjectRegistry+114207
 2: 00007FF663443E9F std::basic_ostream<char,std::char_traits<char> >::operator<<+65103
 3: 00007FF6641226C2 V8_Fatal+162
 4: 00007FF663B8DA3D v8::internal::BackingStore::Reallocate+637
 5: 00007FF663DD71B9 v8::ArrayBuffer::GetBackingStore+137
 6: 00007FF6634D67EA node::Buffer::Data+58
 7: 00007FF6634AAC5C DSA_meth_get_flags+19404
 8: 00007FF663DA5BC6 v8::internal::Builtins::code_handle+172790
 9: 00007FF663DA57B9 v8::internal::Builtins::code_handle+171753
10: 00007FF663DA5A7C v8::internal::Builtins::code_handle+172460
11: 00007FF663DA58E0 v8::internal::Builtins::code_handle+172048
12: 00007FF663E78FE1 v8::internal::SetupIsolateDelegate::SetupHeap+494673
13: 00007FF663E0B48E v8::internal::SetupIsolateDelegate::SetupHeap+45310
14: 00007FF663E0B48E v8::internal::SetupIsolateDelegate::SetupHeap+45310
15: 000001AA200C55C8

Example 4:

1: 00007FF6635279CF v8::internal::CodeObjectRegistry::~CodeObjectRegistry+114207
 2: 00007FF663443E9F std::basic_ostream<char,std::char_traits<char> >::operator<<+65103
 3: 00007FF6641226C2 V8_Fatal+162
 4: 00007FF663B8DA3D v8::internal::BackingStore::Reallocate+637
 5: 00007FF663DD71B9 v8::ArrayBuffer::GetBackingStore+137
 6: 00007FF6634D67EA node::Buffer::Data+58
 7: 00007FF6634AAC5C DSA_meth_get_flags+19404
 8: 00007FF663DA5BC6 v8::internal::Builtins::code_handle+172790
 9: 00007FF663DA57B9 v8::internal::Builtins::code_handle+171753
10: 00007FF663DA5A7C v8::internal::Builtins::code_handle+172460
11: 00007FF663DA58E0 v8::internal::Builtins::code_handle+172048
12: 00007FF663E78FE1 v8::internal::SetupIsolateDelegate::SetupHeap+494673
13: 00007FF663E0B48E v8::internal::SetupIsolateDelegate::SetupHeap+45310
14: 00007FF663E0B48E v8::internal::SetupIsolateDelegate::SetupHeap+45310
15: 00007FF663E0B48E v8::internal::SetupIsolateDelegate::SetupHeap+45310
16: 00007FF663E0B48E v8::internal::SetupIsolateDelegate::SetupHeap+45310
17: 00007FF663E0B48E v8::internal::SetupIsolateDelegate::SetupHeap+45310
18: 00007FF663E0B48E v8::internal::SetupIsolateDelegate::SetupHeap+45310
19: 00007FF663E0B48E v8::internal::SetupIsolateDelegate::SetupHeap+45310
20: 00007FF663E0B48E v8::internal::SetupIsolateDelegate::SetupHeap+45310
21: 00007FF663E0B48E v8::internal::SetupIsolateDelegate::SetupHeap+45310
22: 00007FF663E0B48E v8::internal::SetupIsolateDelegate::SetupHeap+45310
23: 00007FF663E0B48E v8::internal::SetupIsolateDelegate::SetupHeap+45310
24: 00007FF663E0B48E v8::internal::SetupIsolateDelegate::SetupHeap+45310
25: 00007FF663E0B48E v8::internal::SetupIsolateDelegate::SetupHeap+45310
26: 00007FF663E0B48E v8::internal::SetupIsolateDelegate::SetupHeap+45310
27: 00007FF663E0B48E v8::internal::SetupIsolateDelegate::SetupHeap+45310
28: 00007FF663E0B48E v8::internal::SetupIsolateDelegate::SetupHeap+45310
29: 00007FF663E0B48E v8::internal::SetupIsolateDelegate::SetupHeap+45310
30: 00007FF663E0B48E v8::internal::SetupIsolateDelegate::SetupHeap+45310
31: 00007FF663E0B48E v8::internal::SetupIsolateDelegate::SetupHeap+45310
32: 00007FF663E0B48E v8::internal::SetupIsolateDelegate::SetupHeap+45310
33: 00007FF663E0B48E v8::internal::SetupIsolateDelegate::SetupHeap+45310
34: 00007FF663E0969C v8::internal::SetupIsolateDelegate::SetupHeap+37644
35: 00007FF663E0929B v8::internal::SetupIsolateDelegate::SetupHeap+36619
36: 00007FF663CE9DB1 v8::internal::Execution::CallWasm+1521
37: 00007FF663CE969F v8::internal::Execution::Call+191
38: 00007FF663DCC6BC v8::Function::Call+508
39: 00007FF6634F006A node::Stop+19450
40: 00007FF663A82F81 v8::internal::Object::ShortPrint+193
41: 00007FF663AD0E2C v8::internal::JSPromise::status+3388
42: 00007FF663AD0B3C v8::internal::JSPromise::status+2636
43: 00007FF663DD4DCE v8::Module::Evaluate+526
44: 00007FF6634ED548 node::Stop+8408
45: 00007FF663DA5BC6 v8::internal::Builtins::code_handle+172790
46: 00007FF663DA57B9 v8::internal::Builtins::code_handle+171753
47: 00007FF663DA5A7C v8::internal::Builtins::code_handle+172460
48: 00007FF663DA58E0 v8::internal::Builtins::code_handle+172048
49: 00007FF663E78FE1 v8::internal::SetupIsolateDelegate::SetupHeap+494673
50: 00007FF663E0B48E v8::internal::SetupIsolateDelegate::SetupHeap+45310
51: 00007FF663E3B163 v8::internal::SetupIsolateDelegate::SetupHeap+241107
52: 00007FF663EC1772 v8::internal::SetupIsolateDelegate::SetupHeap+791522
53: 00007FF663E2D39A v8::internal::SetupIsolateDelegate::SetupHeap+184330
54: 00007FF663E0959B v8::internal::SetupIsolateDelegate::SetupHeap+37387
55: 00007FF663CE9DDB v8::internal::Execution::CallWasm+1563
56: 00007FF663CE9EFB v8::internal::Execution::CallWasm+1851
57: 00007FF663CEA9AA v8::internal::Execution::TryCall+378
58: 00007FF663CC6D3A v8::internal::MicrotaskQueue::RunMicrotasks+410
59: 00007FF663CC6ADA v8::internal::MicrotaskQueue::PerformCheckpointInternal+74
60: 00007FF663556092 node::CallbackScope::~CallbackScope+978
61: 00007FF663555D2E node::CallbackScope::~CallbackScope+110
62: 00007FF66349F090 v8::base::CPU::has_sse+31520
63: 00007FF66358A947 uv_timer_stop+1207
64: 00007FF663586EDB uv_async_send+331
65: 00007FF66358666C uv_loop_init+1292
66: 00007FF66358680A uv_run+202
67: 00007FF663555675 node::SpinEventLoop+309
68: 00007FF6633EE6F0 v8::internal::interpreter::BytecodeLabel::bind+35712
69: 00007FF6633E9D48 v8::internal::interpreter::BytecodeLabel::bind+16856
70: 00007FF663576EDD uv_poll_stop+557
71: 00007FF664390120 v8::internal::compiler::RepresentationChanger::Uint32OverflowOperatorFor+146416
72: 00007FFECD5254E0 BaseThreadInitThunk+16
73: 00007FFECE28485B RtlUserThreadStart+43

Example 5:

#
# Fatal error in , line 0
# Check failed: result.second.
#
#
#
#FailureMessage Object: 00000021734FDF90
 1: 00007FF6635279CF v8::internal::CodeObjectRegistry::~CodeObjectRegistry+114207
 2: 00007FF663443E9F std::basic_ostream<char,std::char_traits<char> >::operator<<+65103
 3: 00007FF6641226C2 V8_Fatal+162
 4: 00007FF663B8DA3D v8::internal::BackingStore::Reallocate+637
 5: 00007FF663DD71B9 v8::ArrayBuffer::GetBackingStore+137
 6: 00007FF66337432D std::vector<v8::internal::compiler::MoveOperands * __ptr64,v8::internal::ZoneAllocator<v8::internal::compiler::MoveOperands * __ptr64> >::empty+92829
 7: 00007FF6634D1B27 v8::internal::Malloced::operator delete+4535
 8: 00007FF663DA5BC6 v8::internal::Builtins::code_handle+172790
 9: 00007FF663DA57B9 v8::internal::Builtins::code_handle+171753
10: 00007FF663DA5A7C v8::internal::Builtins::code_handle+172460
11: 00007FF663DA58E0 v8::internal::Builtins::code_handle+172048
12: 00007FF663E78FE1 v8::internal::SetupIsolateDelegate::SetupHeap+494673
13: 000001F8F7EF882B

Example 6:

#
# Fatal error in , line 0
# Check failed: result.second.
#
#
#
#FailureMessage Object: 0000007E23BFE5A0
 1: 00007FF6635279CF v8::internal::CodeObjectRegistry::~CodeObjectRegistry+114207
 2: 00007FF663443E9F std::basic_ostream<char,std::char_traits<char> >::operator<<+65103
 3: 00007FF6641226C2 V8_Fatal+162
 4: 00007FF663B8DA3D v8::internal::BackingStore::Reallocate+637
 5: 00007FF663DD71B9 v8::ArrayBuffer::GetBackingStore+137
 6: 00007FF66337432D std::vector<v8::internal::compiler::MoveOperands * __ptr64,v8::internal::ZoneAllocator<v8::internal::compiler::MoveOperands * __ptr64> >::empty+92829
 7: 00007FF6634D1B27 v8::internal::Malloced::operator delete+4535
 8: 00007FF663DA5BC6 v8::internal::Builtins::code_handle+172790
 9: 00007FF663DA57B9 v8::internal::Builtins::code_handle+171753
10: 00007FF663DA5A7C v8::internal::Builtins::code_handle+172460
11: 00007FF663DA58E0 v8::internal::Builtins::code_handle+172048
12: 00007FF663E78FE1 v8::internal::SetupIsolateDelegate::SetupHeap+494673
13: 00007FF663E0B48E v8::internal::SetupIsolateDelegate::SetupHeap+45310
14: 000001E615F92936

Additional information

  • In a few days, some people faced with this issue in Node v16.15.0, v16.14.0. And those error look like me. #32463
  • In vitest issue, A lot of people also stuck in this issue, Running tests crashes node w/ JSDOM and vue 2 vite plugin #1171
  • I confirm that It does not throw this error in node 16.8.0 [#40030](Check failed: !holder_map.has_named_interceptor(). when running jest)
  • I can not give full build of reproduce because of restriction of company. But I am happy to share any useful information to solve this problem.

Ram4GB avatar Jun 29 '22 11:06 Ram4GB

Thanks for the bug report. This is indeed different from #32463.

I'm fairly sure it's a bug in the version of V8 that ships with node v16.x. v18.x should be unaffected because it ships with a newer version of V8 where it's fixed.

For reference: the fix is v8/v8@fcdf35e6d70d51699ece063e25dc705e80673308 but that commit can't be back-ported because it sits on top of a bigger, backwards incompatible change, v8/v8@578f6be77fc5d8af975005c2baf918e7225abb62.

That second commit isn't a problem for node (it doesn't use those APIs) but it has the potential to break native modules.

Out of curiosity, does find node_modules -name \*.node print anything?

bnoordhuis avatar Jun 29 '22 22:06 bnoordhuis

Thanks for replying @bnoordhuis. I give you result that prints out of this command find node_modules -name \*.node in here:

$ find node_modules -name \*.node
node_modules/canvas/build/Release/canvas.node
node_modules/node-sass/vendor/darwin-x64-102/darwin-x64-102_binding.node
node_modules/node-sass/vendor/win32-x64-93/binding.node

Even though It was fixed in v8/v8@fcdf35e, but we still got these errors.

Hope see to see your new reply.

Thanks.

Ram4GB avatar Jun 30 '22 01:06 Ram4GB

Even though It was fixed in v8/v8@fcdf35e, but we still got these errors.

You're using v16.x, right? The fix isn't in any v16.x release.

Try removing those two modules (canvas and node-sass) if possible. Although it's a V8 bug, they may be making it worse.

bnoordhuis avatar Jun 30 '22 20:06 bnoordhuis

Yes, I am using v16, I will try to use your solution and give you feedback.

Thanks @bnoordhuis

Ram4GB avatar Jul 01 '22 01:07 Ram4GB

Hi @bnoordhuis .

  • I removed canvas and node-sass then type. Nothing shows up. $ find node_modules -name \*.node

  • Finally, I type npm run test:unit and still get the errors.

#
# Fatal error in , line 0
# Check failed: result.second.
#
#
#
#FailureMessage Object: 000000BC81CFBFA0
 1: 00007FF7045679CF v8::internal::CodeObjectRegistry::~CodeObjectRegistry+114207
 2: 00007FF704483E9F std::basic_ostream<char,std::char_traits<char> >::operator<<+65103
 3: 00007FF7051626C2 V8_Fatal+162
 4: 00007FF704BCDA3D v8::internal::BackingStore::Reallocate+637
 5: 00007FF704E171B9 v8::ArrayBuffer::GetBackingStore+137
 6: 00007FF7045167EA node::Buffer::Data+58
 7: 00007FF7044EAC5C DSA_meth_get_flags+19404
 8: 00007FF704DE5BC6 v8::internal::Builtins::code_handle+172790
 9: 00007FF704DE57B9 v8::internal::Builtins::code_handle+171753
10: 00007FF704DE5A7C v8::internal::Builtins::code_handle+172460
11: 00007FF704DE58E0 v8::internal::Builtins::code_handle+172048
12: 00007FF704EB8FE1 v8::internal::SetupIsolateDelegate::SetupHeap+494673
13: 00007FF704E4B48E v8::internal::SetupIsolateDelegate::SetupHeap+45310
14: 00007FF704E4B48E v8::internal::SetupIsolateDelegate::SetupHeap+45310
15: 00007FF704E4B48E v8::internal::SetupIsolateDelegate::SetupHeap+45310
16: 00007FF704E4B48E v8::internal::SetupIsolateDelegate::SetupHeap+45310
17: 00007FF704E4B48E v8::internal::SetupIsolateDelegate::SetupHeap+45310
18: 00007FF704E4B48E v8::internal::SetupIsolateDelegate::SetupHeap+45310
19: 00007FF704E4B48E v8::internal::SetupIsolateDelegate::SetupHeap+45310
20: 00007FF704E4B48E v8::internal::SetupIsolateDelegate::SetupHeap+45310
21: 00007FF704E4B48E v8::internal::SetupIsolateDelegate::SetupHeap+45310
22: 00007FF704E4B48E v8::internal::SetupIsolateDelegate::SetupHeap+45310
23: 00007FF704E4B48E v8::internal::SetupIsolateDelegate::SetupHeap+45310
24: 00007FF704E4B48E v8::internal::SetupIsolateDelegate::SetupHeap+45310
25: 00007FF704E4B48E v8::internal::SetupIsolateDelegate::SetupHeap+45310
26: 00007FF704E4B48E v8::internal::SetupIsolateDelegate::SetupHeap+45310
27: 00007FF704E4B48E v8::internal::SetupIsolateDelegate::SetupHeap+45310
28: 00007FF704E4B48E v8::internal::SetupIsolateDelegate::SetupHeap+45310
29: 00007FF704E4B48E v8::internal::SetupIsolateDelegate::SetupHeap+45310
30: 00007FF704E4B48E v8::internal::SetupIsolateDelegate::SetupHeap+45310
31: 00007FF704E4B48E v8::internal::SetupIsolateDelegate::SetupHeap+45310
32: 00007FF704E4B48E v8::internal::SetupIsolateDelegate::SetupHeap+45310
33: 00007FF704E4B48E v8::internal::SetupIsolateDelegate::SetupHeap+45310
34: 00007FF704E4B48E v8::internal::SetupIsolateDelegate::SetupHeap+45310
35: 00007FF704E4B48E v8::internal::SetupIsolateDelegate::SetupHeap+45310
36: 00007FF704E4B48E v8::internal::SetupIsolateDelegate::SetupHeap+45310
37: 00007FF704E4B48E v8::internal::SetupIsolateDelegate::SetupHeap+45310
38: 00007FF704E4B48E v8::internal::SetupIsolateDelegate::SetupHeap+45310
39: 00007FF704E4B48E v8::internal::SetupIsolateDelegate::SetupHeap+45310
40: 00007FF704E4B48E v8::internal::SetupIsolateDelegate::SetupHeap+45310
41: 00007FF704E4969C v8::internal::SetupIsolateDelegate::SetupHeap+37644
42: 00007FF704E4929B v8::internal::SetupIsolateDelegate::SetupHeap+36619
43: 00007FF704D29DB1 v8::internal::Execution::CallWasm+1521
44: 00007FF704D2969F v8::internal::Execution::Call+191
45: 00007FF704E0C6BC v8::Function::Call+508
46: 00007FF70453006A node::Stop+19450
47: 00007FF704AC2F81 v8::internal::Object::ShortPrint+193
48: 00007FF704B10E2C v8::internal::JSPromise::status+3388
49: 00007FF704B10B3C v8::internal::JSPromise::status+2636
50: 00007FF704AD749E v8::internal::SourceTextModule::GetImportMeta+2590
51: 00007FF704AD4AE9 v8::internal::SerializeStackFrameInfo+8617
52: 00007FF704B10E17 v8::internal::JSPromise::status+3367
53: 00007FF704B10B3C v8::internal::JSPromise::status+2636
54: 00007FF704E14DCE v8::Module::Evaluate+526
55: 00007FF70452D548 node::Stop+8408
56: 00007FF704DE5BC6 v8::internal::Builtins::code_handle+172790
57: 00007FF704DE57B9 v8::internal::Builtins::code_handle+171753
58: 00007FF704DE5A7C v8::internal::Builtins::code_handle+172460
59: 00007FF704DE58E0 v8::internal::Builtins::code_handle+172048
60: 00007FF704EB8FE1 v8::internal::SetupIsolateDelegate::SetupHeap+494673
61: 00007FF704E4B48E v8::internal::SetupIsolateDelegate::SetupHeap+45310
62: 00007FF704E7B163 v8::internal::SetupIsolateDelegate::SetupHeap+241107
63: 00007FF704F01772 v8::internal::SetupIsolateDelegate::SetupHeap+791522
64: 00007FF704E6D39A v8::internal::SetupIsolateDelegate::SetupHeap+184330
65: 00007FF704E4959B v8::internal::SetupIsolateDelegate::SetupHeap+37387
66: 00007FF704D29DDB v8::internal::Execution::CallWasm+1563
67: 00007FF704D29EFB v8::internal::Execution::CallWasm+1851
68: 00007FF704D2A9AA v8::internal::Execution::TryCall+378
69: 00007FF704D06D3A v8::internal::MicrotaskQueue::RunMicrotasks+410
70: 00007FF704D06ADA v8::internal::MicrotaskQueue::PerformCheckpointInternal+74
71: 00007FF704596092 node::CallbackScope::~CallbackScope+978
72: 00007FF704595D2E node::CallbackScope::~CallbackScope+110
73: 00007FF7044DF090 v8::base::CPU::has_sse+31520
74: 00007FF7045CA947 uv_timer_stop+1207
75: 00007FF7045C6EDB uv_async_send+331
76: 00007FF7045C666C uv_loop_init+1292
77: 00007FF7045C680A uv_run+202
78: 00007FF704595675 node::SpinEventLoop+309
79: 00007FF70442E6F0 v8::internal::interpreter::BytecodeLabel::bind+35712
80: 00007FF704429D48 v8::internal::interpreter::BytecodeLabel::bind+16856
81: 00007FF7045B6EDD uv_poll_stop+557
82: 00007FF7053D0120 v8::internal::compiler::RepresentationChanger::Uint32OverflowOperatorFor+146416
83: 00007FF98A8D54E0 BaseThreadInitThunk+16
84: 00007FF98B24485B RtlUserThreadStart+43

Ram4GB avatar Jul 01 '22 06:07 Ram4GB

Hi @bnoordhuis . Is there anything that I can give you?

Thanks @bnoordhuis

Ram4GB avatar Jul 05 '22 09:07 Ram4GB

As expectation management: I don't know if this can be fixed in v16. I can't reproduce the bug myself, there is nothing that stands out when reading the relevant code in in node and V8, and there isn't a simple fix that can be back-ported from newer versions.

bnoordhuis avatar Jul 06 '22 20:07 bnoordhuis

I believe this is fixed in https://github.com/nodejs/node/pull/42874, which should be available in the next Node 16 release.

tony19 avatar Aug 09 '22 16:08 tony19

Hi @tony19

We have two kinds of errors

Error 1:

FATAL ERROR: v8::FromJust Maybe value is Nothing.

Error 2:

#
# Fatal error in , line 0
# Check failed: result.second.
#
#
#
#FailureMessage Object: 00000021734FDF90

Which one was fixed? or both of them ?

Ram4GB avatar Aug 10 '22 01:08 Ram4GB

@Ram4GB I think the fix addresses the root problem that caused both of those errors. We'll have to test that once it gets released.

tony19 avatar Aug 10 '22 01:08 tony19

Hi @tony19 Did you test your code with the latest Node version (v16.17.0)?

For me, I tested and cannot reproduce this bug for running code 20 times.

I hope you will get a great result like me.

Cheer 🎉

Ram4GB avatar Aug 17 '22 03:08 Ram4GB

Testing now...

FYI, Vitest 0.22.0 (released yesterday) now has a retry mechanism that checks for this specific segfault (and a couple others).

tony19 avatar Aug 17 '22 03:08 tony19

Oh I have seen it, it's really great config. Thank for your ideas and supporting 😄. @tony19

Ram4GB avatar Aug 17 '22 03:08 Ram4GB

Hi @tony19 I checked your ci, does it pass or cancel?

Ram4GB avatar Aug 17 '22 05:08 Ram4GB

It timed out on the 20th test run in Windows, but it effectively passed, as no segfaults occurred in any Node 16 jobs. Looks like the fix works!

tony19 avatar Aug 17 '22 05:08 tony19

Ok now we will close this issue. Upgrade to the latest version (v16.17.0) to fixed

Thanks everyone.🎉 🎉 🎉.

Ram4GB avatar Aug 17 '22 05:08 Ram4GB