Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug]: uv__async_io crashed when we using napi_create_external_buffer on Mac M1 Pro #33400

Closed
3 tasks done
nopandcc opened this issue Mar 23, 2022 · 2 comments
Closed
3 tasks done

Comments

@nopandcc
Copy link

nopandcc commented Mar 23, 2022

Preflight Checklist

Electron Version

17.0.0

What operating system are you using?

macOS

Operating System Version

Mac OS 11 12

What arch are you using?

arm64 (including Apple Silicon)

Last Known Working Electron version

No response

Expected Behavior

Backgroud:

  • Electron Verison:17.0.0/17.1.1
  • This is our new feature, we don't to try the older version electron
  • we have a native node addon module to process the video data to YUV data, and pass the YUV data to JS layer for draw.
    For reduce one time memory alloc and copy, we used napi_create_external_buffer to create a node buffer for JS layer

Steps:

  1. node add on process the video data to YUV data, 23 frame per second
  2. using napi_create_external_buffer to create a node buffer and callback to JS layer
  3. everything is ok, and JS layer can using the node buffer to draw

Actual Behavior

on Mac M1 pro, our arm64 arch package crashed at
Electron Framework`uv__async_io(loop=0x00000001131e2c10, w=, events=) at async.c:154:5 [opt]

we can't reproduce this issue on windows 32/64 and mac intel platform.
and we try to debugging this via electron debug symbol,
we found,
Before crash, only node GC thread using the uv_async_send to fire the external Node Buffer free callback, so we think napi_create_external_buffer caused this issue, and we try to using napi_create_buffer_copy, the crash fixed, but this workaround lost some performance. Could you help with this? we can provide more information, if you need.

Go back to crash:
the crash callstack
* frame #0: 0x000000010bcdf3d4 Electron Frameworkuv__async_io(loop=0x00000001131e2c10, w=<unavailable>, events=<unavailable>) at async.c:154:5 [opt] frame #1: 0x000000010bcefac0 Electron Frameworkuv__io_poll(loop=0x00000001131e2c10, timeout=0) at kqueue.c:0 [opt]
frame #2: 0x000000010bcdf84c Electron Frameworkuv_run(loop=0x00000001131e2c10, mode=UV_RUN_NOWAIT) at core.c:389:5 [opt] frame #3: 0x000000010be2cf28 Electron Frameworkelectron::NodeBindings::UvRunOnce(this=0x0000007000420a00) at node_bindings.cc:632:11 [opt]
frame #4: 0x000000010e527bdc Electron Frameworkbase::TaskAnnotator::RunTaskImpl(base::PendingTask&) [inlined] base::OnceCallback<void ()>::Run(this=0x00000070009c5000) && at callback.h:142:12 [opt] frame #5: 0x000000010e527bc8 Electron Frameworkbase::TaskAnnotator::RunTaskImpl(this=, pending_task=0x00000070009c5000) at task_annotator.cc:135:32 [opt]
frame #6: 0x000000010e541ab8 Electron Frameworknon-virtual thunk to base::sequence_manager::internal::ThreadControllerWithMessagePumpImpl::DoWork() [inlined] void base::TaskAnnotator::RunTask<base::sequence_manager::internal::ThreadControllerWithMessagePumpImpl::DoWorkImpl(base::sequence_manager::LazyNow*)::$_0>(this=0x00000070002a0d88, pending_task=0x00000070009c5000)::$_0&&) at task_annotator.h:74:5 [opt] frame #7: 0x000000010e541a98 Electron Frameworknon-virtual thunk to base::sequence_manager::internal::ThreadControllerWithMessagePumpImpl::DoWork() at thread_controller_with_message_pump_impl.cc:356:21 [opt]
frame #8: 0x000000010e541974 Electron Frameworknon-virtual thunk to base::sequence_manager::internal::ThreadControllerWithMessagePumpImpl::DoWork() [inlined] base::sequence_manager::internal::ThreadControllerWithMessagePumpImpl::DoWork() at thread_controller_with_message_pump_impl.cc:261:30 [opt] frame #9: 0x000000010e54194c Electron Frameworknon-virtual thunk to base::sequence_manager::internal::ThreadControllerWithMessagePumpImpl::DoWork() at thread_controller_with_message_pump_impl.cc:0 [opt]
frame #10: 0x000000010e57b094 Electron Frameworkinvocation function for block in base::MessagePumpCFRunLoopBase::RunWorkSource(void*) [inlined] base::MessagePumpCFRunLoopBase::RunWork(this=0x00000070002c17c0) at message_pump_mac.mm:398:54 [opt] frame #11: 0x000000010e57b040 Electron Frameworkinvocation function for block in base::MessagePumpCFRunLoopBase::RunWorkSource(.block_descriptor=) at message_pump_mac.mm:375:11 [opt]
frame #12: 0x000000010e57a2dc Electron Frameworknode::GetEnvironmentIsolateData(node::Environment*) + 9348252 frame #13: 0x000000010e57a880 Electron Frameworkbase::MessagePumpCFRunLoopBase::RunWorkSource(info=) at message_pump_mac.mm:374:3 [opt]
frame #14: 0x0000000182ec4c5c CoreFoundation`CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION + 28
----skip some frames-----

the GC thread fire the external node buffer free:

thread #34, name = 'ThreadPoolForegroundWorker', stop reason = breakpoint 1.1
frame #0: 0x000000010888b06c Electron Frameworkuv_async_send(handle=0x0000007000581fa8) at async.c:63 [opt] frame #1: 0x000000010e413740 Electron Frameworknode::Buffer::(anonymous namespace)::CallbackInfo::OnBackingStoreFree() at env-inl.h:816:7 [opt]
frame #2: 0x000000010e4136d4 Electron Frameworknode::Buffer::(anonymous namespace)::CallbackInfo::OnBackingStoreFree(this=<unavailable>) at node_buffer.cc:195:9 [opt] frame #3: 0x00000001098f0dfc Electron Frameworkv8::internal::BackingStore::~BackingStore(this=0x0000007002081f00) at backing-store.cc:271:5 [opt]
frame #4: 0x000000010cdcd81c Electron Frameworkstd::__1::__shared_ptr_pointer<v8::BackingStore*, std::__1::default_delete<v8::BackingStore>, std::__1::allocator<v8::BackingStore> >::__on_zero_shared() [inlined] std::__1::default_delete<v8::BackingStore>::operator(__ptr=<unavailable>)(v8::BackingStore*) const at unique_ptr.h:54:5 [opt] frame #5: 0x000000010cdcd814 Electron Frameworkstd::__1::__shared_ptr_pointer<v8::BackingStore*, std::__1::default_deletev8::BackingStore, std::__1::allocatorv8::BackingStore >::__on_zero_shared(this=) at shared_ptr.h:262:5 [opt]
frame #6: 0x000000010970c2e4 Electron Frameworkv8::internal::ArrayBufferSweeper::SweepingJob::SweepYoung() [inlined] std::__1::__shared_count::__release_shared(this=0x0000007001ae0220) at shared_ptr.h:172:9 [opt] frame #7: 0x000000010970c2c4 Electron Frameworkv8::internal::ArrayBufferSweeper::SweepingJob::SweepYoung() [inlined] std::__1::__shared_weak_count::__release_shared(this=0x0000007001ae0220) at shared_ptr.h:214:27 [opt]
frame #8: 0x000000010970c2c4 Electron Frameworkv8::internal::ArrayBufferSweeper::SweepingJob::SweepYoung() [inlined] std::__1::shared_ptr<v8::internal::BackingStore>::~shared_ptr(this=0x0000007001b94938) at shared_ptr.h:954:19 [opt] frame #9: 0x000000010970c2bc Electron Frameworkv8::internal::ArrayBufferSweeper::SweepingJob::SweepYoung() [inlined] std::__1::shared_ptrv8::internal::BackingStore::~shared_ptr(this=0x0000007001b94938) at shared_ptr.h:952:1 [opt]
frame #10: 0x000000010970c2bc Electron Frameworkv8::internal::ArrayBufferSweeper::SweepingJob::SweepYoung() [inlined] v8::internal::ArrayBufferExtension::~ArrayBufferExtension(this=0x0000007001b94930) at js-array-buffer.h:170:7 [opt] frame #11: 0x000000010970c2bc Electron Frameworkv8::internal::ArrayBufferSweeper::SweepingJob::SweepYoung() [inlined] v8::internal::ArrayBufferExtension::~ArrayBufferExtension(this=0x0000007001b94930) at js-array-buffer.h:170:7 [opt]
frame #12: 0x000000010970c2bc Electron Frameworkv8::internal::ArrayBufferSweeper::SweepingJob::SweepYoung(this=0x0000007000317930) at array-buffer-sweeper.cc:330:7 [opt] frame #13: 0x000000010970c70c Electron Frameworkstd::__1::__function::__func<v8::internal::ArrayBufferSweeper::RequestSweep(v8::internal::ArrayBufferSweeper::SweepingType)::$_1, std::__1::allocatorv8::internal::ArrayBufferSweeper::RequestSweep(v8::internal::ArrayBufferSweeper::SweepingType)::$_1, void ()>::operator()() [inlined] v8::internal::ArrayBufferSweeper::SweepingJob::Sweep(this=0x0000007000317930) at array-buffer-sweeper.cc:276:7 [opt]
frame #14: 0x000000010970c6f0 Electron Frameworkstd::__1::__function::__func<v8::internal::ArrayBufferSweeper::RequestSweep(v8::internal::ArrayBufferSweeper::SweepingType)::$_1, std::__1::allocator<v8::internal::ArrayBufferSweeper::RequestSweep(v8::internal::ArrayBufferSweeper::SweepingType)::$_1>, void ()>::operator()() [inlined] v8::internal::ArrayBufferSweeper::RequestSweep(this=<unavailable>)::$_1::operator()() const at array-buffer-sweeper.cc:164:13 [opt] frame #15: 0x000000010970c5a8 Electron Frameworkstd::__1::__function::__func<v8::internal::ArrayBufferSweeper::RequestSweep(v8::internal::ArrayBufferSweeper::SweepingType)::$_1, std::__1::allocatorv8::internal::ArrayBufferSweeper::RequestSweep(v8::internal::ArrayBufferSweeper::SweepingType)::$_1, void ()>::operator()() [inlined] decltype(__f=)::$_1&>(fp)()) std::__1::__invokev8::internal::ArrayBufferSweeper::RequestSweep(v8::internal::ArrayBufferSweeper::SweepingType)::$_1&(v8::internal::ArrayBufferSweeper::RequestSweep(v8::internal::ArrayBufferSweeper::SweepingType)::$_1&) at type_traits:3956:1 [opt]
frame #16: 0x000000010970c5a8 Electron Frameworkstd::__1::__function::__func<v8::internal::ArrayBufferSweeper::RequestSweep(v8::internal::ArrayBufferSweeper::SweepingType)::$_1, std::__1::allocator<v8::internal::ArrayBufferSweeper::RequestSweep(v8::internal::ArrayBufferSweeper::SweepingType)::$_1>, void ()>::operator()() [inlined] void std::__1::__invoke_void_return_wrapper<void, true>::__call<v8::internal::ArrayBufferSweeper::RequestSweep(__args=<unavailable>)::$_1&>(v8::internal::ArrayBufferSweeper::RequestSweep(v8::internal::ArrayBufferSweeper::SweepingType)::$_1&) at __functional_base:348:9 [opt] frame #17: 0x000000010970c5a8 Electron Frameworkstd::__1::__function::__func<v8::internal::ArrayBufferSweeper::RequestSweep(v8::internal::ArrayBufferSweeper::SweepingType)::$_1, std::__1::allocatorv8::internal::ArrayBufferSweeper::RequestSweep(v8::internal::ArrayBufferSweeper::SweepingType)::$_1, void ()>::operator()() [inlined] std::__1::__function::__alloc_func<v8::internal::ArrayBufferSweeper::RequestSweep(v8::internal::ArrayBufferSweeper::SweepingType)::$_1, std::__1::allocatorv8::internal::ArrayBufferSweeper::RequestSweep(v8::internal::ArrayBufferSweeper::SweepingType)::$_1, void ()>::operator(this=)() at functional:1565:16 [opt]
frame #18: 0x000000010970c5a8 Electron Frameworkstd::__1::__function::__func<v8::internal::ArrayBufferSweeper::RequestSweep(v8::internal::ArrayBufferSweeper::SweepingType)::$_1, std::__1::allocator<v8::internal::ArrayBufferSweeper::RequestSweep(v8::internal::ArrayBufferSweeper::SweepingType)::$_1>, void ()>::operator(this=<unavailable>)() at functional:1739:12 [opt] frame #19: 0x000000010b0d3bdc Electron Frameworkbase::TaskAnnotator::RunTaskImpl(base::PendingTask&) [inlined] base::OnceCallback<void ()>::Run(this=0x0000000179362c08) && at callback.h:142:12 [opt]
frame #20: 0x000000010b0d3bc8 Electron Frameworkbase::TaskAnnotator::RunTaskImpl(this=<unavailable>, pending_task=0x0000000179362c08) at task_annotator.cc:135:32 [opt] frame #21: 0x000000010b0f4adc Electron Frameworkbase::internal::TaskTracker::RunSkipOnShutdown(base::internal::Task&, base::TaskTraits const&, base::internal::TaskSource*, base::SequenceToken const&) [inlined] void base::TaskAnnotator::RunTask<base::internal::TaskTracker::RunTaskImpl(base::internal::Task&, base::TaskTraits const&, base::internal::TaskSource*, base::SequenceToken const&)::$_0>(this=0x0000007000461988)::$_0&&) at task_annotator.h:74:5 [opt]
frame #22: 0x000000010b0f4ab8 Electron Frameworkbase::internal::TaskTracker::RunSkipOnShutdown(base::internal::Task&, base::TaskTraits const&, base::internal::TaskSource*, base::SequenceToken const&) [inlined] base::internal::TaskTracker::RunTaskImpl(this=<unavailable>) at task_tracker.cc:706:19 [opt] frame #23: 0x000000010b0f4ab4 Electron Frameworkbase::internal::TaskTracker::RunSkipOnShutdown(this=, task=0x0000000179362c08, traits=0x0000000179362dc8, task_source=0x00000070003ba500, token=0x0000000179362bb0) at task_tracker.cc:691:3 [opt]
frame #24: 0x000000010b0f4124 Electron Frameworkbase::internal::TaskTracker::RunTask(base::internal::Task, base::internal::TaskSource*, base::TaskTraits const&) [inlined] base::internal::TaskTracker::RunTaskWithShutdownBehavior(this=<unavailable>, task=<unavailable>, traits=<unavailable>, task_source=<unavailable>, token=<unavailable>) at task_tracker.cc:721:7 [opt] frame #25: 0x000000010b0f40dc Electron Frameworkbase::internal::TaskTracker::RunTask(this=0x0000007000461980, task=Task @ 0x0000000179362c08, task_source=0x00000070003ba500, traits=0x0000000179362dc8) at task_tracker.cc:548:5 [opt]
frame #26: 0x000000010b1217b4 Electron Frameworkbase::internal::TaskTrackerPosix::RunTask(this=0x0000007000461980, task=Task @ 0x0000000179362cc8, task_source=0x00000070003ba500, traits=0x0000000179362dc8) at task_tracker_posix.cc:22:16 [opt] frame #27: 0x000000010b0f3f08 Electron Frameworkbase::internal::TaskTracker::RunAndPopNextTask(this=, task_source=) at task_tracker.cc:466:5 [opt]
frame #28: 0x000000010b102674 Electron Frameworkbase::internal::WorkerThread::RunWorker(this=0x000000700209a3a0) at worker_thread.cc:379:34 [opt] frame #29: 0x000000010b1022b8 Electron Frameworkbase::internal::WorkerThread::RunPooledWorker(this=) at worker_thread.cc:266:3 [opt]
frame #30: 0x000000010b121c98 Electron Frameworkbase::(anonymous namespace)::ThreadFunc(params=<unavailable>) at platform_thread_posix.cc:99:13 [opt] frame #31: 0x0000000182df9240 libsystem_pthread.dylib_pthread_start + 148

Testcase Gist URL

No response

Additional Information

No response

@github-actions
Copy link
Contributor

github-actions bot commented Oct 5, 2022

This issue has been automatically marked as stale. If this issue is still affecting you, please leave any comment (for example, "bump"), and we'll keep it open. If you have any new additional information—in particular, if this is still reproducible in the latest version of Electron or in the beta—please include it with your comment!

@github-actions github-actions bot added the stale label Oct 5, 2022
@github-actions
Copy link
Contributor

github-actions bot commented Nov 5, 2022

This issue has been closed due to inactivity, and will not be monitored. If this is a bug and you can reproduce this issue on a supported version of Electron please open a new issue and include instructions for reproducing the issue.

@github-actions github-actions bot closed this as not planned Won't fix, can't repro, duplicate, stale Nov 5, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant