From 790a9981440424b6646a7f83f73cce7043ab2398 Mon Sep 17 00:00:00 2001 From: Dick Carter Date: Wed, 13 Feb 2019 19:32:12 -0800 Subject: [PATCH] Fix NaiveEngine shutdown segfault on CentOS7. --- src/engine/naive_engine.cc | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/engine/naive_engine.cc b/src/engine/naive_engine.cc index 61ead23cf526..db4491981bdd 100644 --- a/src/engine/naive_engine.cc +++ b/src/engine/naive_engine.cc @@ -62,6 +62,8 @@ class NaiveEngine final : public Engine { }; NaiveEngine() { + objpool_opr_ref_ = common::ObjectPool::_GetSharedRef(); + objpool_var_ref_ = common::ObjectPool::_GetSharedRef(); } // virtual destructor virtual ~NaiveEngine() { @@ -232,6 +234,13 @@ class NaiveEngine final : public Engine { // GPU auxiliary streams std::vector aux_streams_; #endif +/*! + * \brief Holding a shared_ptr to the object pool to prevent it from being destructed too early + * See also #309 (https://github.com/dmlc/mxnet/issues/309) and similar fix in threaded_engine.h. + * Without this, segfaults seen on CentOS7 in test_operator_gpu.py:test_convolution_multiple_streams + */ + std::shared_ptr > objpool_opr_ref_; + std::shared_ptr > objpool_var_ref_; }; // class NaiveEngine Engine *CreateNaiveEngine() {