From 2b583e9c9e0a94842be8d63dc2ff25baca644541 Mon Sep 17 00:00:00 2001 From: helixhorned Date: Sun, 2 Feb 2014 15:56:13 +0000 Subject: [PATCH] gloadtex() cleanup, make some vars in kplib.c static, add source/valgrind_errors.log. BUILD_LUNATIC. git-svn-id: https://svn.eduke32.com/eduke32@4295 1a8010ca-5511-0410-912e-c29ae57300e0 --- polymer/eduke32/build/src/kplib.c | 4 +- polymer/eduke32/build/src/mdsprite.c | 30 ++-- .../eduke32/source/jaudiolib/src/multivoc.c | 17 +-- polymer/eduke32/source/valgrind_errors.log | 136 ++++++++++++++++++ 4 files changed, 159 insertions(+), 28 deletions(-) create mode 100644 polymer/eduke32/source/valgrind_errors.log diff --git a/polymer/eduke32/build/src/kplib.c b/polymer/eduke32/build/src/kplib.c index 3aae1649e..1aa199d99 100644 --- a/polymer/eduke32/build/src/kplib.c +++ b/polymer/eduke32/build/src/kplib.c @@ -161,8 +161,8 @@ static kzfilestate kzfs; // pow2mask 128* // dcflagor 64 -int32_t palcol[256] ASMNAME("palcol"), paleng, bakcol, numhufblocks, zlibcompflags; -int8_t coltype, filtype, bitdepth; +static int32_t palcol[256] ASMNAME("palcol"), paleng, bakcol, numhufblocks, zlibcompflags; +static int8_t coltype, filtype, bitdepth; //============================ KPNGILIB begins =============================== diff --git a/polymer/eduke32/build/src/mdsprite.c b/polymer/eduke32/build/src/mdsprite.c index 230cdb5e4..98a9d39b8 100644 --- a/polymer/eduke32/build/src/mdsprite.c +++ b/polymer/eduke32/build/src/mdsprite.c @@ -2546,13 +2546,17 @@ static voxmodel_t *gvox; uint32_t gloadtex(int32_t *picbuf, int32_t xsiz, int32_t ysiz, int32_t is8bit, int32_t dapal) { uint32_t rtexid; - coltype *pic, *pic2; - char *cptr; int32_t i; - pic = (coltype *)picbuf; //Correct for GL's RGB order; also apply gamma here.. - pic2 = (coltype *)Bmalloc(xsiz*ysiz*sizeof(int32_t)); if (!pic2) return((unsigned)-1); - cptr = (char *)&britable[gammabrightness ? 0 : curbrightness][0]; + const char *const cptr = &britable[gammabrightness ? 0 : curbrightness][0]; + + // Correct for GL's RGB order; also apply gamma here: + const coltype *const pic = (const coltype *)picbuf; + coltype *pic2 = (coltype *)Bmalloc(xsiz*ysiz*sizeof(coltype)); + + if (!pic2) + return (unsigned)-1; + if (!is8bit) { for (i=xsiz*ysiz-1; i>=0; i--) @@ -2565,12 +2569,16 @@ uint32_t gloadtex(int32_t *picbuf, int32_t xsiz, int32_t ysiz, int32_t is8bit, i } else { - if (palookup[dapal] == NULL) dapal = 0; + if (palookup[dapal] == NULL) + dapal = 0; + for (i=xsiz*ysiz-1; i>=0; i--) { - pic2[i].b = cptr[palette[(int32_t)palookup[dapal][pic[i].a]*3+2]*4]; - pic2[i].g = cptr[palette[(int32_t)palookup[dapal][pic[i].a]*3+1]*4]; - pic2[i].r = cptr[palette[(int32_t)palookup[dapal][pic[i].a]*3+0]*4]; + const int32_t ii = palookup[dapal][pic[i].a] * 3; + + pic2[i].b = cptr[palette[ii+2]*4]; + pic2[i].g = cptr[palette[ii+1]*4]; + pic2[i].r = cptr[palette[ii+0]*4]; pic2[i].a = 255; } } @@ -2580,8 +2588,10 @@ uint32_t gloadtex(int32_t *picbuf, int32_t xsiz, int32_t ysiz, int32_t is8bit, i bglTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_NEAREST); bglTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_NEAREST); bglTexImage2D(GL_TEXTURE_2D,0,4,xsiz,ysiz,0,GL_RGBA,GL_UNSIGNED_BYTE,(char *)pic2); + Bfree(pic2); - return(rtexid); + + return rtexid; } static int32_t getvox(int32_t x, int32_t y, int32_t z) diff --git a/polymer/eduke32/source/jaudiolib/src/multivoc.c b/polymer/eduke32/source/jaudiolib/src/multivoc.c index 0b9ff5809..bbb01c9c8 100644 --- a/polymer/eduke32/source/jaudiolib/src/multivoc.c +++ b/polymer/eduke32/source/jaudiolib/src/multivoc.c @@ -1597,22 +1597,7 @@ int32_t MV_Init MV_SetErrorCode(MV_Ok); - // MV_TotalMemory + 2: FIXME - // Thread 3: - // Invalid read of size 2 - // at 0x8730513: MV_Mix16BitStereo16Stereo (mixst.c:272) - // by 0x872A5A2: MV_Mix (multivoc.c:285) - // by 0x872B0EA: MV_ServiceVoc (multivoc.c:449) - // by 0x87342C1: fillData (driver_sdl.c:80) - // by 0x428F2AD: ??? (in /usr/lib/libSDL_mixer-1.2.so.0.2.6) - // . . . - // Address 0x11e9fa10 is 0 bytes after a block of size 9,728 alloc'd - // at 0x402732C: calloc (vg_replace_malloc.c:467) - // by 0x87288C8: MV_Init (multivoc.c:2528) - // by 0x871BD20: FX_Init (fx_man.c:160) - // by 0x84597CA: S_SoundStartup (sounds.c:62) - // by 0x80D7869: app_main (game.c:10378) - // by 0x870C9C0: main (sdlayer.c:222) + // MV_TotalMemory + 2: FIXME, see valgrind_errors.log totalmem = Voices * sizeof(VoiceNode) + sizeof(HARSH_CLIP_TABLE_8) + MV_TOTALBUFFERSIZE + 2; ptr = (char *) calloc(1, totalmem); diff --git a/polymer/eduke32/source/valgrind_errors.log b/polymer/eduke32/source/valgrind_errors.log new file mode 100644 index 000000000..b8d7ec013 --- /dev/null +++ b/polymer/eduke32/source/valgrind_errors.log @@ -0,0 +1,136 @@ +build: LTO=0 WITHOUT_GTK=1 RELEASE=0 LUNATIC=0 make +platform: Linux/x86_64 + +---------- + +Thread 3: +Invalid read of size 2 + at 0x8730513: MV_Mix16BitStereo16Stereo (mixst.c:272) + by 0x872A5A2: MV_Mix (multivoc.c:285) + by 0x872B0EA: MV_ServiceVoc (multivoc.c:449) + by 0x87342C1: fillData (driver_sdl.c:80) + by 0x428F2AD: ??? (in /usr/lib/libSDL_mixer-1.2.so.0.2.6) + . . . + Address 0x11e9fa10 is 0 bytes after a block of size 9,728 alloc'd + at 0x402732C: calloc (vg_replace_malloc.c:467) + by 0x87288C8: MV_Init (multivoc.c:2528) + by 0x871BD20: FX_Init (fx_man.c:160) + by 0x84597CA: S_SoundStartup (sounds.c:62) + by 0x80D7869: app_main (game.c:10378) + by 0x870C9C0: main (sdlayer.c:222) + +---------- + +AMC TC: drawing character selection screen? (The program was gdb-stopped for a +while before.) + +Invalid read of size 1 + at 0x11C8A709: bcmp (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so) + by 0x513A08: S_PlayMusic (sounds.c:265) + by 0x4F94E0: G_EnterLevel (premap.c:1917) + by 0x42CCF7: G_NewGame_EnterLevel (game.h:553) + by 0x453BB3: app_main (game.c:11859) + by 0x5BAB3C: main (sdlayer.c:278) + Address 0x19206e30 is 0 bytes after a block of size 0 alloc'd + at 0x11C852DB: malloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so) + by 0x51396F: S_PlayMusic (sounds.c:253) + by 0x4F94E0: G_EnterLevel (premap.c:1917) + by 0x42CCF7: G_NewGame_EnterLevel (game.h:553) + by 0x453BB3: app_main (game.c:11859) + by 0x5BAB3C: main (sdlayer.c:278) + +---------- + +AMC TC: drawing Shadow Warrior Riot Gun. + +Invalid read of size 1 + at 0x5BEE8C: mspritevline (a-c.c:554) + by 0x541AFB: dorotatesprite (engine.c:7742) + by 0x556DAD: rotatesprite_ (engine.c:14581) + by 0x4A7D8F: VM_Execute (gameexec.c:2735) + by 0x4A68F4: VM_Execute (gameexec.c:2346) + by 0x4A4404: VM_Execute (gameexec.c:1779) + by 0x4B1469: VM_Execute (gameexec.c:4974) + by 0x4B1469: VM_Execute (gameexec.c:4974) + by 0x4A43D5: VM_Execute (gameexec.c:1772) + by 0x4B1170: VM_Execute (gameexec.c:4928) + by 0x4A4404: VM_Execute (gameexec.c:1779) + by 0x4B1170: VM_Execute (gameexec.c:4928) + Address 0x1f3524d6 is 22 bytes after a block of size 131,072 free'd + at 0x11C8660C: free (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so) + by 0x4B5BB9: Gv_Free (gamevars.c:49) + by 0x4B6EEF: Gv_ResetVars (gamevars.c:369) + by 0x4F7290: G_NewGame (premap.c:1423) + by 0x42CCED: G_NewGame_EnterLevel (game.h:551) + by 0x453BB3: app_main (game.c:11859) + by 0x5BAB4A: main (sdlayer.c:278) + +---------- + +AMC TC: select James. Switching between his first weapon (a pistol) and the +next one, but still drawing the first one. Appears to happen only once. + +Invalid read of size 1 + at 0x5BEE8C: mspritevline (a-c.c:554) + by 0x541AFB: dorotatesprite (engine.c:7742) + by 0x556DAD: rotatesprite_ (engine.c:14581) + by 0x4A7D8F: VM_Execute (gameexec.c:2735) + by 0x4A68F4: VM_Execute (gameexec.c:2346) + by 0x4A43D5: VM_Execute (gameexec.c:1772) + by 0x4B1170: VM_Execute (gameexec.c:4928) + by 0x4A4404: VM_Execute (gameexec.c:1779) + by 0x4B1170: VM_Execute (gameexec.c:4928) + by 0x4A4404: VM_Execute (gameexec.c:1779) + by 0x4B1170: VM_Execute (gameexec.c:4928) + by 0x4B1170: VM_Execute (gameexec.c:4928) + Address 0x278048b5 is 5 bytes after a block of size 1,024 free'd + at 0x11C8660C: free (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so) + by 0x12B3DAE0: ??? (in /usr/lib/x86_64-linux-gnu/libSDL2-2.0.so.0.0.0) + by 0x12B3DB2C: ??? (in /usr/lib/x86_64-linux-gnu/libSDL2-2.0.so.0.0.0) + by 0x12B40009: SDL_LowerBlit (in /usr/lib/x86_64-linux-gnu/libSDL2-2.0.so.0.0.0) + by 0x12B4023C: SDL_UpperBlit (in /usr/lib/x86_64-linux-gnu/libSDL2-2.0.so.0.0.0) + by 0x5BD15A: showframe (sdlayer.c:1922) + by 0x54C44B: nextpage (engine.c:11208) + by 0x454291: app_main (game.c:12000) + by 0x5BAB4A: main (sdlayer.c:278) + +---------- + +AMC TC: Polymost, voxels, r4292 line numbers + +Use of uninitialised value of size 8 + at 0x59BFF1: gloadtex (mdsprite.c:2571) + by 0x5A06E3: voxdraw (mdsprite.c:3301) + by 0x572F25: polymost_drawsprite (polymost.c:3730) + by 0x53912B: drawsprite_opengl (engine.c:5571) + by 0x53DC18: drawsprite (engine.c:6579) + by 0x545DD2: drawmasks (engine.c:9478) + by 0x43B655: G_HandleMirror (game.c:4296) + by 0x43C6A9: G_DrawRooms (game.c:4638) + by 0x4543AD: app_main (game.c:12018) + by 0x5BAB4A: main (sdlayer.c:278) + +---------- + +Non-pow2 ysize tiles. + +Invalid read of size 1 + at 0x505D26: vlineasm4 (a-c.c:138) + by 0x47A5C1: wallscan (engine.c:3905) + by 0x47E549: drawalls (engine.c:4978) + by 0x48C342: drawrooms (engine.c:9052) + by 0x47192D: yax_drawrooms (engine.c:1174) + by 0x50756B: M32_DrawRoomsAndMasks (build.c:476) + by 0x507F69: app_main (build.c:742) + by 0x502328: main (sdlayer.c:278) + Address 0x1ea6f89d is 0 bytes after a block of size 10,509 alloc'd + at 0x112D62DB: malloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so) + by 0x46A0D3: allocache (cache1d.c:164) + by 0x494A35: loadtile (engine.c:11521) + by 0x475BAE: maskwallscan (engine.c:2832) + by 0x482DC3: drawsprite_classic (engine.c:6094) + by 0x485467: drawsprite (engine.c:6581) + by 0x48D759: drawmasks (engine.c:9495) + by 0x507589: M32_DrawRoomsAndMasks (build.c:479) + by 0x507F69: app_main (build.c:742) + by 0x502328: main (sdlayer.c:278)