From 0d0f3a1cd2274ca8e46fc8b135e7309dcd5438dd Mon Sep 17 00:00:00 2001 From: helixhorned Date: Sat, 8 Feb 2014 14:37:41 +0000 Subject: [PATCH] Add Makefile.common switch ALLOCACHE_AS_MALLOC, remove DEBUG_WITH_VALGRIND. git-svn-id: https://svn.eduke32.com/eduke32@4298 1a8010ca-5511-0410-912e-c29ae57300e0 --- polymer/eduke32/Makefile.common | 10 ++++++++ polymer/eduke32/build/src/a-c.c | 19 -------------- polymer/eduke32/build/src/cache1d.c | 4 --- polymer/eduke32/source/game.c | 4 --- polymer/eduke32/source/valgrind_errors.log | 30 +++++++++++++++++++++- 5 files changed, 39 insertions(+), 28 deletions(-) diff --git a/polymer/eduke32/Makefile.common b/polymer/eduke32/Makefile.common index 69d1e4800..133c96833 100644 --- a/polymer/eduke32/Makefile.common +++ b/polymer/eduke32/Makefile.common @@ -178,6 +178,12 @@ DMALLOC?=0 PROFILER?=0 MUDFLAP?=0 +# Make allocache() a wrapper around malloc()? Useful for debugging +# allocache()-allocated memory accesses with e.g. Valgrind. +# For debugging with Valgrind + GDB, see +# http://valgrind.org/docs/manual/manual-core-adv.html#manual-core-adv.gdbserver +ALLOCACHE_AS_MALLOC?=0 + # Select the default optimization level for release and debug builds. ifeq ($(RELEASE),0) OPTLEVEL?=0 @@ -343,6 +349,10 @@ endif debug+= -O$(OPTLEVEL) +ifneq ($(ALLOCACHE_AS_MALLOC),0) + debug+= -DDEBUG_ALLOCACHE_AS_MALLOC +endif + # See http://clang.llvm.org/docs/UsersManual.html#controlling-code-generation # for a list of possible UBSan options. # Clang 3.2 does only supports -fsanitize=address for the AddressSanitizer diff --git a/polymer/eduke32/build/src/a-c.c b/polymer/eduke32/build/src/a-c.c index 14b4cda62..ef8213654 100644 --- a/polymer/eduke32/build/src/a-c.c +++ b/polymer/eduke32/build/src/a-c.c @@ -8,15 +8,6 @@ #include "a.h" -// For this, it's also sensible to uncomment DEBUG_ALLOCACHE_AS_MALLOC: -//#define DEBUG_WITH_VALGRIND - -#ifdef DEBUG_WITH_VALGRIND -// For debugging with Valgrind + GDB, see -// http://valgrind.org/docs/manual/manual-core-adv.html#manual-core-adv.gdbserver -# include -#endif - #ifdef ENGINE_USING_A_C int32_t krecip(int32_t num); // from engine.c @@ -131,19 +122,9 @@ static inline uint32_t ourmulscale32(uint32_t a, uint32_t b) static inline int32_t getpix(int32_t logy, const char *buf, uint32_t vplc) { if (logy != 0) - { -#ifdef DEBUG_WITH_VALGRIND - VALGRIND_CHECK_MEM_IS_DEFINED(&buf[vplc>>logy], 1); -#endif return buf[vplc>>logy]; - } else - { -#ifdef DEBUG_WITH_VALGRIND - VALGRIND_CHECK_MEM_IS_DEFINED(&buf[ourmulscale32(vplc,globaltilesizy)], 1); -#endif return buf[ourmulscale32(vplc,globaltilesizy)]; - } } void setupvlineasm(int32_t neglogy) { glogy = neglogy; } diff --git a/polymer/eduke32/build/src/cache1d.c b/polymer/eduke32/build/src/cache1d.c index bc9a1598a..d4892e868 100644 --- a/polymer/eduke32/build/src/cache1d.c +++ b/polymer/eduke32/build/src/cache1d.c @@ -83,10 +83,6 @@ static intptr_t kzipopen(const char *filnam) // After calling uninitcache, it is still ok to call allocache // without first calling initcache. -// Uncomment for easier allocache-allocated bound checking (e.g. with Valgrind) -// KEEPINSYNC game.c -//#define DEBUG_ALLOCACHE_AS_MALLOC - #define MAXCACHEOBJECTS 9216 #if !defined DEBUG_ALLOCACHE_AS_MALLOC diff --git a/polymer/eduke32/source/game.c b/polymer/eduke32/source/game.c index ab3547bff..a958de23d 100644 --- a/polymer/eduke32/source/game.c +++ b/polymer/eduke32/source/game.c @@ -1371,10 +1371,6 @@ void G_GameQuit(void) G_GameExit("Timed out."); } -// Uncomment for easier allocache-allocated bound checking (e.g. with Valgrind) -// KEEPINSYNC cache1d.c -//#define DEBUG_ALLOCACHE_AS_MALLOC - #if !defined DEBUG_ALLOCACHE_AS_MALLOC extern int32_t cacnum; extern cactype cac[]; diff --git a/polymer/eduke32/source/valgrind_errors.log b/polymer/eduke32/source/valgrind_errors.log index b8d7ec013..50055535f 100644 --- a/polymer/eduke32/source/valgrind_errors.log +++ b/polymer/eduke32/source/valgrind_errors.log @@ -1,8 +1,10 @@ -build: LTO=0 WITHOUT_GTK=1 RELEASE=0 LUNATIC=0 make +build: ALLOCACHE_AS_MALLOC=1 LTO=0 WITHOUT_GTK=1 RELEASE=0 LUNATIC=0 make platform: Linux/x86_64 ---------- +See the comment in MV_Init(). + Thread 3: Invalid read of size 2 at 0x8730513: MV_Mix16BitStereo16Stereo (mixst.c:272) @@ -134,3 +136,29 @@ Invalid read of size 1 by 0x507589: M32_DrawRoomsAndMasks (build.c:479) by 0x507F69: app_main (build.c:742) by 0x502328: main (sdlayer.c:278) + +---------- + +BLiGHT: strafing (tilts the screen). + +Invalid read of size 1 + at 0x5BE3A6: vlineasm4 (a-c.c:125) + by 0x532C3E: wallscan (engine.c:3905) + by 0x5356CB: parascan (engine.c:4607) + by 0x536288: drawalls (engine.c:4853) + by 0x5449BF: drawrooms (engine.c:9052) + by 0x529FAA: yax_drawrooms (engine.c:1174) + by 0x43C627: G_DrawRooms (game.c:4650) + by 0x45426D: app_main (game.c:12014) + by 0x5BA9A5: main (sdlayer.c:278) + Address 0x26c8a44a is 10 bytes after a block of size 128,000 alloc'd + at 0x11C852DB: malloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so) + by 0x51D524: allocache (cache1d.c:160) + by 0x54D0B2: loadtile (engine.c:11521) + by 0x4F3BF4: G_CacheMapData (premap.c:487) + by 0x4F930A: G_EnterLevel (premap.c:1910) + by 0x4BC269: G_NewGame_EnterLevel (game.h:553) + by 0x4C5364: M_DisplayMenus (menus.c:2442) + by 0x486A91: G_PlaybackDemo (demo.c:936) + by 0x453A46: app_main (game.c:11844) + by 0x5BA9A5: main (sdlayer.c:278)