dthuerck / mapmap_cpu

A high-performance general-purpose MRF MAP solver, heavily exploiting SIMD instructions.
BSD 3-Clause "New" or "Revised" License
102 stars 51 forks source link

Illegal instruction crashes on mac #19

Closed jlaxson closed 4 years ago

jlaxson commented 4 years ago

I was debugging the same issue as #13, but noticed the problem persisted if I used non-apple clang. As I was building, I noticed several warnings that look like:

delete called on 'mapmap::MultilevelCriterion<float, 8>' that is abstract but has non-virtual
      destructor

By making those destructors all virtual, the crash went away. The changes were:

diff --git a/mapmap/header/multilevel.h b/mapmap/header/multilevel.h
index 5914956..24db754 100755
--- a/mapmap/header/multilevel.h
+++ b/mapmap/header/multilevel.h
@@ -52,7 +52,7 @@ template<typename COSTTYPE, uint_t SIMDWIDTH>
 class MultilevelCriterion
 {
 public:
-    ~MultilevelCriterion() {}
+    virtual ~MultilevelCriterion() {}

     virtual void group_nodes(std::vector<luint_t>& node_in_group,
         const LevelSet<COSTTYPE, SIMDWIDTH> * current_level,
diff --git a/mapmap/header/optimizer_instances/dp_node_solver.h b/mapmap/header/optimizer_instances/dp_node_solver.h
index 1deb1cd..9d1c888 100644
--- a/mapmap/header/optimizer_instances/dp_node_solver.h
+++ b/mapmap/header/optimizer_instances/dp_node_solver.h
@@ -20,7 +20,7 @@ template<typename COSTTYPE, uint_t SIMDWIDTH>
 class DPNodeSolver
 {
 public:
-    ~DPNodeSolver() {};
+    virtual ~DPNodeSolver() {};

     virtual void optimize_node() = 0;
     virtual luint_t scratch_bytes_needed() = 0;
@@ -111,4 +111,4 @@ NS_MAPMAP_END
 /* include function implementations */
 #include "source/optimizer_instances/dp_node_solver.impl.h"

-#endif /* __MAPMAP_HEADER_DP_NODE_SOLVER_H_ */
\ No newline at end of file
+#endif /* __MAPMAP_HEADER_DP_NODE_SOLVER_H_ */
diff --git a/mapmap/header/termination_criterion.h b/mapmap/header/termination_criterion.h
index 840a244..de0a949 100755
--- a/mapmap/header/termination_criterion.h
+++ b/mapmap/header/termination_criterion.h
@@ -55,7 +55,7 @@ class TerminationCriterion
 {
 public:
     TerminationCriterion();
-    ~TerminationCriterion();
+    virtual ~TerminationCriterion();

     virtual bool check_termination(const SolverHistory<COSTTYPE,
         SIMDWIDTH> * history) = 0;
dthuerck commented 4 years ago

Hi,

thanks for your investigation and patch! I just pushed that code - thank you very much!