use leak sanitizer for debug build and break the build in case of unresolved symbols in libraries

This commit is contained in:
Sebastian Krzyszkowiak 2017-08-19 01:26:53 +02:00
parent bfda2cdbd6
commit b7346ea330
3 changed files with 10 additions and 2 deletions

View file

@ -5,7 +5,12 @@ if (NOT LIBSUPERDERPY_CONFIG_INCLUDED)
add_definitions(-DLIBSUPERDERPY_ORIENTATION_${LIBSUPERDERPY_ORIENTATION}=true)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -std=c11")
set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -fsanitize=undefined")
set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -O1 -fno-optimize-sibling-calls -fno-omit-frame-pointer -fsanitize=leak -DLEAK_SANITIZER=1 -fno-common -fsanitize-recover=all")
if(APPLE)
set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -Wl,-undefined,error")
else(APPLE)
set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -Wl,--no-undefined")
endif(APPLE)
if(APPLE)
if(CMAKE_INSTALL_PREFIX MATCHES "/usr/local")

View file

@ -514,8 +514,10 @@ SYMBOL_EXPORT void libsuperderpy_destroy(struct Game *game) {
tmp->loaded = false;
}
if (tmp->handle && !RUNNING_ON_VALGRIND) {
#ifndef LEAK_SANITIZER
PrintConsole(game, "Closing gamestate \"%s\"...", tmp->name);
dlclose(tmp->handle);
#endif
}
free(tmp->name);
if (tmp->api) {
@ -556,6 +558,6 @@ SYMBOL_EXPORT void libsuperderpy_destroy(struct Game *game) {
#ifdef ALLEGRO_MACOSX
chdir(game->_priv.cwd);
#endif
execv(argv[0], argv); // FIXME: on OSX there's chdir called which might break it
execv(argv[0], argv);
}
}

View file

@ -51,6 +51,7 @@ SYMBOL_EXPORT void DrawTextWithShadow(ALLEGRO_FONT *font, ALLEGRO_COLOR color, f
}
SYMBOL_EXPORT int DrawWrappedText(ALLEGRO_FONT *font, ALLEGRO_COLOR color, float x, float y, int width, int flags, char const* text) {
// TODO: use al_do_multiline_text; and switch to al_draw_multiline_text once it returns number of lines
char stext[1024]; // Copy of the passed text.
char *pch; // A pointer to each word.