diff --git a/src/libpaje/PajeEntity.h b/src/libpaje/PajeEntity.h index 7e37c60..333b0df 100644 --- a/src/libpaje/PajeEntity.h +++ b/src/libpaje/PajeEntity.h @@ -77,7 +77,8 @@ class PajeEntity : public PajeVirtualEntity public: PajeEntity (PajeContainer *container, PajeType *type, PajeTraceEvent *event); - ~PajeEntity (void); + // Add virtual destructor to prevent undefined behavior when deleting derived objects via base pointer + virtual ~PajeEntity (void); void addPajeTraceEvent (PajeTraceEvent *event); PajeContainer *container (void) const; PajeType *type (void) const; diff --git a/src/libpaje/PajeSimulator+Queries.cc b/src/libpaje/PajeSimulator+Queries.cc index 3b1f9cb..6bd2d8b 100644 --- a/src/libpaje/PajeSimulator+Queries.cc +++ b/src/libpaje/PajeSimulator+Queries.cc @@ -165,7 +165,9 @@ std::vector PajeSimulator::valuesForEntityType (PajeType *type) PajeCategorizedType *catType = dynamic_cast(type); if (catType){ std::pair val; - for (auto it = catType->values().begin(); it != catType->values().end(); ++it) + // Store the returned container to avoid dangling iterators from temporary + auto vals = catType->values(); + for (auto it = vals.begin(); it != vals.end(); ++it) ret.push_back((std::pair(*it)).second); } return ret; diff --git a/src/tools/CMakeLists.txt b/src/tools/CMakeLists.txt index 5b2278a..4965aad 100644 --- a/src/tools/CMakeLists.txt +++ b/src/tools/CMakeLists.txt @@ -42,7 +42,12 @@ INCLUDE_DIRECTORIES (pj_equals ${PROJECT_SOURCE_DIR}/src/libpaje/) INCLUDE_DIRECTORIES(${pajeng_SOURCE_DIR}/src/fb/) include_directories(${CMAKE_BINARY_DIR}) # FIXME check for libgomp / OpenMP support -set_target_properties(pj_equals PROPERTIES COMPILE_FLAGS "-fopenmp") +IF(APPLE) + set_target_properties(pj_equals PROPERTIES COMPILE_FLAGS "-Xpreprocessor -fopenmp") + TARGET_LINK_LIBRARIES(pj_equals omp) +ELSE() + set_target_properties(pj_equals PROPERTIES COMPILE_FLAGS "-fopenmp") +ENDIF() IF(STATIC_LINKING) TARGET_LINK_LIBRARIES(pj_equals paje_library_static)