Add Address Sanitizer suppression list.

This replaces the unnecessary deallocations on program termination.
Passing in the suppression list environment variable via setenv()
doesn't seem to work, so I've added a comment in the Makefile to explain
invocation.
This commit is contained in:
dongresource 2020-09-24 03:12:24 +02:00
parent c33f218e56
commit 006d1000c7
5 changed files with 5 additions and 22 deletions

View File

@ -1,6 +1,7 @@
CC=clang CC=clang
CXX=clang++ CXX=clang++
# -w suppresses all warnings (the part that's commented out helps me find memory leaks, it ruins performance though!) # -w suppresses all warnings (the part that's commented out helps me find memory leaks, it ruins performance though!)
# If compiling with ASAN, invoke like this: $ LSAN_OPTIONS=suppressions=suppr.txt bin/fusion
CFLAGS=-O3 #-g3 -fsanitize=address CFLAGS=-O3 #-g3 -fsanitize=address
CXXFLAGS=-Wall -Wno-unknown-pragmas -std=c++17 -O2 -DPROTOCOL_VERSION=$(PROTOCOL_VERSION) -DGIT_VERSION=\"$(shell git describe --tags)\" #-g3 -fsanitize=address CXXFLAGS=-Wall -Wno-unknown-pragmas -std=c++17 -O2 -DPROTOCOL_VERSION=$(PROTOCOL_VERSION) -DGIT_VERSION=\"$(shell git describe --tags)\" #-g3 -fsanitize=address
LDFLAGS=-lpthread -ldl #-g3 -fsanitize=address LDFLAGS=-lpthread -ldl #-g3 -fsanitize=address

View File

@ -6,12 +6,6 @@
std::map<std::pair<int, int>, Chunk*> ChunkManager::chunks; std::map<std::pair<int, int>, Chunk*> ChunkManager::chunks;
void ChunkManager::init() {} // stubbed void ChunkManager::init() {} // stubbed
void ChunkManager::cleanup() {
// cleans up all the allocated chunks
for (auto& pair : chunks) {
delete pair.second;
}
}
void ChunkManager::addNPC(int posX, int posY, int32_t id) { void ChunkManager::addNPC(int posX, int posY, int32_t id) {
std::pair<int, int> pos = grabChunk(posX, posY); std::pair<int, int> pos = grabChunk(posX, posY);

View File

@ -189,19 +189,6 @@ void TableData::init() {
} }
} }
void TableData::cleanup() {
/*
* This is just to shut the address sanitizer up. Dynamically allocated data
* doesn't need to be cleaned up if it's supposed to last the program's full runtime.
*/
for (auto& pair : MissionManager::Rewards)
delete pair.second;
for (auto& pair : MissionManager::Tasks)
delete pair.second;
for (auto& pair : NPCManager::NPCs)
delete pair.second;
}
/* /*
* Some item categories either don't possess iEquipLoc or use a different value for item type. * Some item categories either don't possess iEquipLoc or use a different value for item type.
*/ */

View File

@ -49,9 +49,6 @@ void terminate(int arg) {
shardThread->join(); shardThread->join();
} }
TableData::cleanup();
ChunkManager::cleanup();
exit(0); exit(0);
} }

4
suppr.txt Normal file
View File

@ -0,0 +1,4 @@
leak:TableData::init
leak:ChunkManager::addPlayer
leak:ChunkManager::addNPC
leak:nlohmann::basic_json