Browse Source

fix(win7): workaround for hang when progress exit on win7+32bit

GitOrigin-RevId: b49b0b230e
HuaHua404-patch-4
Megvii Engine Team 2 years ago
parent
commit
6dfd5a4cd4
2 changed files with 20 additions and 0 deletions
  1. +10
    -0
      src/core/impl/comp_node/cpu/comp_node.cpp
  2. +10
    -0
      src/core/impl/utils/thread.cpp

+ 10
- 0
src/core/impl/comp_node/cpu/comp_node.cpp View File

@@ -620,6 +620,16 @@ class CpuCompNode::CompNodeRecorderImpl final : public CompNodeBaseImpl {


public: public:
static void static_free_device(ImplBase* self, void* ptr) { static void static_free_device(ImplBase* self, void* ptr) {
//! FIXME: Windows 7 + 32bit have shared_ptr dtor issue when progress exit
//! as a workaround, skip any task at atexit stage.
#if MGB_HAVE_THREAD
#if defined(WIN32) && defined(__i386__)
if (SCQueueSynchronizer::is_into_atexit) {
mgb_log_warn("windows 32bit issue happened!!, resource recovery by OS!!");
return;
}
#endif
#endif
static_cast<CompNodeRecorderImpl*>(self)->free_device(ptr); static_cast<CompNodeRecorderImpl*>(self)->free_device(ptr);
} }




+ 10
- 0
src/core/impl/utils/thread.cpp View File

@@ -112,6 +112,16 @@ SCQueueSynchronizer::SCQueueSynchronizer(size_t max_spin) {
} }


SCQueueSynchronizer::~SCQueueSynchronizer() noexcept { SCQueueSynchronizer::~SCQueueSynchronizer() noexcept {
#if defined(WIN32) && defined(__i386__)
if (SCQueueSynchronizer::is_into_atexit) {
mgb_log_warn("windows 32bit issue happened!!, resource recovery by OS!!");
m_wait_finish_called = true;
//! need detach, if not, thread dtor will crash, OS will recovery thread
//! resource by call std::terminate.
m_worker_thread.detach();
return;
}
#endif
if (!m_worker_started) if (!m_worker_started)
return; return;
if (!m_wait_finish_called) { if (!m_wait_finish_called) {


Loading…
Cancel
Save