From 1dda3feca0674d1cf122c5f822633b090a97560c Mon Sep 17 00:00:00 2001 From: DarthArgus Date: Tue, 18 Oct 2016 07:20:39 +0000 Subject: [PATCH 1/7] this is more proper --- external/3rd/library/webAPI/webAPIHeartbeat.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/external/3rd/library/webAPI/webAPIHeartbeat.cpp b/external/3rd/library/webAPI/webAPIHeartbeat.cpp index 7b12cd94..8ecf5ddc 100644 --- a/external/3rd/library/webAPI/webAPIHeartbeat.cpp +++ b/external/3rd/library/webAPI/webAPIHeartbeat.cpp @@ -9,8 +9,7 @@ using namespace StellaBellum; webAPIHeartbeat::webAPIHeartbeat() { std::string filePath = this->get_selfpath().c_str(); - webAPI api = webAPI::webAPI( - std::string(vxENCRYPT("https://login.stellabellum.net/metric/shoulderTap").decrypt()), + webAPI api(std::string(vxENCRYPT("https://login.stellabellum.net/metric/shoulderTap").decrypt()), std::string(vxENCRYPT("StellaBellum WebAPI Metrics Sender").decrypt())); api.addJsonData(std::string(vxENCRYPT("type").decrypt()), std::string(vxENCRYPT("server").decrypt())); From 331dec707b3e798b89c3433225293412d7cda5b9 Mon Sep 17 00:00:00 2001 From: DarthArgus Date: Tue, 15 Nov 2016 07:30:12 +0000 Subject: [PATCH 2/7] apparently we fixed whatever was really causing crashes for this... --- engine/server/library/serverDatabase/src/shared/Persister.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/engine/server/library/serverDatabase/src/shared/Persister.cpp b/engine/server/library/serverDatabase/src/shared/Persister.cpp index 19270519..03295b08 100755 --- a/engine/server/library/serverDatabase/src/shared/Persister.cpp +++ b/engine/server/library/serverDatabase/src/shared/Persister.cpp @@ -604,7 +604,7 @@ void Persister::saveCompleted(Snapshot *completedSnapshot) { m_savingSnapshots.erase(i, m_savingSnapshots.end()); - //delete completedSnapshot; + delete completedSnapshot; if (m_savingSnapshots.empty() && ConfigServerDatabase::getReportSaveTimes()) { @@ -636,7 +636,7 @@ void Persister::saveCompleted(Snapshot *completedSnapshot) else { SnapshotListType::iterator j=std::remove(m_savingCharacterSnapshots.begin(),m_savingCharacterSnapshots.end(),completedSnapshot); - DEBUG_FATAL(i==m_savingCharacterSnapshots.end(),("Programmer bug: SaveCompleted() called with a snapshot that wasn't in m_savingSnapshots or m_savingCharacterSnapshots.")); +DEBUG_FATAL(i==m_savingCharacterSnapshots.end(),("Programmer bug: SaveCompleted() called with a snapshot that wasn't in m_savingSnapshots or m_savingCharacterSnapshots.")); m_savingCharacterSnapshots.erase(j, m_savingCharacterSnapshots.end()); delete completedSnapshot; DEBUG_REPORT_LOG(ConfigServerDatabase::getReportSaveTimes(),("New character save completed\n")); From 74ebc3ec43f619e87342b60c6ae519bd8e9ff05c Mon Sep 17 00:00:00 2001 From: DarthArgus Date: Sun, 20 Nov 2016 06:25:19 -0600 Subject: [PATCH 3/7] if this builds i think it will fix the mem issue --- engine/server/library/serverDatabase/src/shared/Persister.cpp | 3 --- .../library/serverDatabase/src/shared/TaskSaveSnapshot.cpp | 2 ++ 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/engine/server/library/serverDatabase/src/shared/Persister.cpp b/engine/server/library/serverDatabase/src/shared/Persister.cpp index 03295b08..a10784cf 100755 --- a/engine/server/library/serverDatabase/src/shared/Persister.cpp +++ b/engine/server/library/serverDatabase/src/shared/Persister.cpp @@ -604,8 +604,6 @@ void Persister::saveCompleted(Snapshot *completedSnapshot) { m_savingSnapshots.erase(i, m_savingSnapshots.end()); - delete completedSnapshot; - if (m_savingSnapshots.empty() && ConfigServerDatabase::getReportSaveTimes()) { int saveTime = Clock::timeMs() - m_saveStartTime; @@ -638,7 +636,6 @@ void Persister::saveCompleted(Snapshot *completedSnapshot) SnapshotListType::iterator j=std::remove(m_savingCharacterSnapshots.begin(),m_savingCharacterSnapshots.end(),completedSnapshot); DEBUG_FATAL(i==m_savingCharacterSnapshots.end(),("Programmer bug: SaveCompleted() called with a snapshot that wasn't in m_savingSnapshots or m_savingCharacterSnapshots.")); m_savingCharacterSnapshots.erase(j, m_savingCharacterSnapshots.end()); - delete completedSnapshot; DEBUG_REPORT_LOG(ConfigServerDatabase::getReportSaveTimes(),("New character save completed\n")); } } diff --git a/engine/server/library/serverDatabase/src/shared/TaskSaveSnapshot.cpp b/engine/server/library/serverDatabase/src/shared/TaskSaveSnapshot.cpp index 4207b8b1..c57880c0 100755 --- a/engine/server/library/serverDatabase/src/shared/TaskSaveSnapshot.cpp +++ b/engine/server/library/serverDatabase/src/shared/TaskSaveSnapshot.cpp @@ -32,6 +32,8 @@ void TaskSaveSnapshot::onComplete() { m_snapshot->saveCompleted(); Persister::getInstance().saveCompleted(m_snapshot); + delete m_snapshot; + m_snapshot = nullptr; // just in case some brilliant SOE BS uses it again somewhere before this class object is nuked } // ====================================================================== From b2a5fc55abad8bbfd6aafba9d48e6e9ed7e5723f Mon Sep 17 00:00:00 2001 From: DarthArgus Date: Sun, 20 Nov 2016 07:32:49 -0600 Subject: [PATCH 4/7] well, not quite --- engine/server/library/serverDatabase/src/shared/Persister.cpp | 2 ++ .../library/serverDatabase/src/shared/TaskSaveSnapshot.cpp | 2 -- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/engine/server/library/serverDatabase/src/shared/Persister.cpp b/engine/server/library/serverDatabase/src/shared/Persister.cpp index a10784cf..00504d0c 100755 --- a/engine/server/library/serverDatabase/src/shared/Persister.cpp +++ b/engine/server/library/serverDatabase/src/shared/Persister.cpp @@ -603,6 +603,7 @@ void Persister::saveCompleted(Snapshot *completedSnapshot) if (i!=m_savingSnapshots.end()) { m_savingSnapshots.erase(i, m_savingSnapshots.end()); + delete (*i); if (m_savingSnapshots.empty() && ConfigServerDatabase::getReportSaveTimes()) { @@ -636,6 +637,7 @@ void Persister::saveCompleted(Snapshot *completedSnapshot) SnapshotListType::iterator j=std::remove(m_savingCharacterSnapshots.begin(),m_savingCharacterSnapshots.end(),completedSnapshot); DEBUG_FATAL(i==m_savingCharacterSnapshots.end(),("Programmer bug: SaveCompleted() called with a snapshot that wasn't in m_savingSnapshots or m_savingCharacterSnapshots.")); m_savingCharacterSnapshots.erase(j, m_savingCharacterSnapshots.end()); + delete (*j); DEBUG_REPORT_LOG(ConfigServerDatabase::getReportSaveTimes(),("New character save completed\n")); } } diff --git a/engine/server/library/serverDatabase/src/shared/TaskSaveSnapshot.cpp b/engine/server/library/serverDatabase/src/shared/TaskSaveSnapshot.cpp index c57880c0..4207b8b1 100755 --- a/engine/server/library/serverDatabase/src/shared/TaskSaveSnapshot.cpp +++ b/engine/server/library/serverDatabase/src/shared/TaskSaveSnapshot.cpp @@ -32,8 +32,6 @@ void TaskSaveSnapshot::onComplete() { m_snapshot->saveCompleted(); Persister::getInstance().saveCompleted(m_snapshot); - delete m_snapshot; - m_snapshot = nullptr; // just in case some brilliant SOE BS uses it again somewhere before this class object is nuked } // ====================================================================== From cceff1dc1acf2750c42ca666a58fb39469d7da93 Mon Sep 17 00:00:00 2001 From: DarthArgus Date: Sun, 20 Nov 2016 07:34:15 -0600 Subject: [PATCH 5/7] oops, don't want to invalidate... and yes the completedSnapshot should in theory point to the same snapshot, but for whatever reason deleting it crashes the TC but not my local setup --- engine/server/library/serverDatabase/src/shared/Persister.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/engine/server/library/serverDatabase/src/shared/Persister.cpp b/engine/server/library/serverDatabase/src/shared/Persister.cpp index 00504d0c..a7d92062 100755 --- a/engine/server/library/serverDatabase/src/shared/Persister.cpp +++ b/engine/server/library/serverDatabase/src/shared/Persister.cpp @@ -602,8 +602,8 @@ void Persister::saveCompleted(Snapshot *completedSnapshot) SnapshotListType::iterator i=std::remove(m_savingSnapshots.begin(),m_savingSnapshots.end(),completedSnapshot); if (i!=m_savingSnapshots.end()) { - m_savingSnapshots.erase(i, m_savingSnapshots.end()); delete (*i); + m_savingSnapshots.erase(i, m_savingSnapshots.end()); if (m_savingSnapshots.empty() && ConfigServerDatabase::getReportSaveTimes()) { @@ -636,8 +636,8 @@ void Persister::saveCompleted(Snapshot *completedSnapshot) { SnapshotListType::iterator j=std::remove(m_savingCharacterSnapshots.begin(),m_savingCharacterSnapshots.end(),completedSnapshot); DEBUG_FATAL(i==m_savingCharacterSnapshots.end(),("Programmer bug: SaveCompleted() called with a snapshot that wasn't in m_savingSnapshots or m_savingCharacterSnapshots.")); - m_savingCharacterSnapshots.erase(j, m_savingCharacterSnapshots.end()); delete (*j); + m_savingCharacterSnapshots.erase(j, m_savingCharacterSnapshots.end()); DEBUG_REPORT_LOG(ConfigServerDatabase::getReportSaveTimes(),("New character save completed\n")); } } From 23cf1cc58499a19ee5ec06cd7de86929b0c7ac79 Mon Sep 17 00:00:00 2001 From: DarthArgus Date: Sun, 20 Nov 2016 07:47:19 -0600 Subject: [PATCH 6/7] well according to SO this looks correct https://stackoverflow.com/questions/991335/how-to-erase-delete-pointers-to-objects-stored-in-a-vector --- .../library/serverDatabase/src/shared/Persister.cpp | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/engine/server/library/serverDatabase/src/shared/Persister.cpp b/engine/server/library/serverDatabase/src/shared/Persister.cpp index a7d92062..25887d15 100755 --- a/engine/server/library/serverDatabase/src/shared/Persister.cpp +++ b/engine/server/library/serverDatabase/src/shared/Persister.cpp @@ -602,8 +602,9 @@ void Persister::saveCompleted(Snapshot *completedSnapshot) SnapshotListType::iterator i=std::remove(m_savingSnapshots.begin(),m_savingSnapshots.end(),completedSnapshot); if (i!=m_savingSnapshots.end()) { - delete (*i); - m_savingSnapshots.erase(i, m_savingSnapshots.end()); + delete *i; + i = m_savingSnapshots.erase(i, m_savingSnapshots.end()); + *i = nullptr; if (m_savingSnapshots.empty() && ConfigServerDatabase::getReportSaveTimes()) { @@ -636,8 +637,9 @@ void Persister::saveCompleted(Snapshot *completedSnapshot) { SnapshotListType::iterator j=std::remove(m_savingCharacterSnapshots.begin(),m_savingCharacterSnapshots.end(),completedSnapshot); DEBUG_FATAL(i==m_savingCharacterSnapshots.end(),("Programmer bug: SaveCompleted() called with a snapshot that wasn't in m_savingSnapshots or m_savingCharacterSnapshots.")); - delete (*j); - m_savingCharacterSnapshots.erase(j, m_savingCharacterSnapshots.end()); + delete *j; + *j = nullptr; + j = m_savingCharacterSnapshots.erase(j, m_savingCharacterSnapshots.end()); DEBUG_REPORT_LOG(ConfigServerDatabase::getReportSaveTimes(),("New character save completed\n")); } } From 1867ee7cc94a8957f531c6aed5bb7b3fb77eebf9 Mon Sep 17 00:00:00 2001 From: DarthArgus Date: Sun, 20 Nov 2016 07:52:52 -0600 Subject: [PATCH 7/7] maybe try this? --- .../serverDatabase/src/shared/Persister.cpp | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/engine/server/library/serverDatabase/src/shared/Persister.cpp b/engine/server/library/serverDatabase/src/shared/Persister.cpp index 25887d15..25217f4d 100755 --- a/engine/server/library/serverDatabase/src/shared/Persister.cpp +++ b/engine/server/library/serverDatabase/src/shared/Persister.cpp @@ -602,9 +602,7 @@ void Persister::saveCompleted(Snapshot *completedSnapshot) SnapshotListType::iterator i=std::remove(m_savingSnapshots.begin(),m_savingSnapshots.end(),completedSnapshot); if (i!=m_savingSnapshots.end()) { - delete *i; - i = m_savingSnapshots.erase(i, m_savingSnapshots.end()); - *i = nullptr; + m_savingSnapshots.erase(i, m_savingSnapshots.end()); if (m_savingSnapshots.empty() && ConfigServerDatabase::getReportSaveTimes()) { @@ -637,11 +635,16 @@ void Persister::saveCompleted(Snapshot *completedSnapshot) { SnapshotListType::iterator j=std::remove(m_savingCharacterSnapshots.begin(),m_savingCharacterSnapshots.end(),completedSnapshot); DEBUG_FATAL(i==m_savingCharacterSnapshots.end(),("Programmer bug: SaveCompleted() called with a snapshot that wasn't in m_savingSnapshots or m_savingCharacterSnapshots.")); - delete *j; - *j = nullptr; - j = m_savingCharacterSnapshots.erase(j, m_savingCharacterSnapshots.end()); + m_savingCharacterSnapshots.erase(j, m_savingCharacterSnapshots.end()); DEBUG_REPORT_LOG(ConfigServerDatabase::getReportSaveTimes(),("New character save completed\n")); } + + if (completedSnapshot) { + delete completedSnapshot; + completedSnapshot = nullptr; // in case of double deletes by any other pointers to this thing + } else { + DEBUG_WARNING(true, ("We just attempted a double delete!")); + } } // ----------------------------------------------------------------------