Re: [AD] [allegro] linux joystick + dmalloc support + leak report

[ Thread Index | Date Index | More lists.liballeg.org/allegro-developers Archives ]


At 11:14 PM 6/04/2004, you wrote:
Hi! Two patches this time. Based on CVS one week old or so...

ljoy_2.diff: Adds important version check to the Allegro Linux joystick
driver.This is the same patch as the old one I sent you Eric, except this
one should be endian safe. (The ioctl should return JS_VERSION which has
native endianness AFAIK)

dmalloc.diff: Adds support for the dmalloc malloc debugger suite. I noticed
Allegro recently got support for fortify. All I could find on the internet
was an out of date version 2.2 for DOS which didn't work for me. Also I
found a Debian package which I did not test. In addition I've toyed around
with Valgrind and Electric Fence. both good tools, but slow, memory hogging
or buggy. Valgrind crashes Allegro apps and Electric Fence doesn't report
memory leaks. Dmalloc seems to be perfect though. It is fast when used in
the 'runtime' mode and it reports memory leaks and in what __FILE__ and
__LINE__ the memory were first allocated.

The dmalloc docs suggests -ldmallocth be used on threaded programs
but -ldmalloc works fine for me. At a later time the configure machinery
should check for ALLEGRO_MULTITHREADED and choose the corresponding library
to link with. Also the use of fortify and dmalloc should be made mutually
exclusive. But apply this patch for now as it is tested and works.

By the way... I found four "memory leaks" with dmalloc which turned out to
be bogus. Buffers first allocated as follows: src/readsmp.c:52,
src/readsmp.c:55, src/readbmp.c:51, src/readbmp.c:54. It seems dmalloc
doesn't like memory freed by an exit handler. I don't care much for "Texas"
memory management either. :-) the functions for register_bitmap_file_type()
and register_sample_file_type () should be promoted to the API and
allegro_exit() should just check if they were called (listheads == NULL) to
maintain backwards compatibility.

Fortify 2.2 is good, but it keeps telling me I have a memory leak using strdup(), so I need to confirm it with a different memory manager. I have tried valgrind under cygwin on Windows XP, but it will only compile under linux. It looks to me as though you have used dmalloc on linux. Have you tried it on mingw? I can build and test dmalloc under cygwin. When I try to build and test dmalloc under mingw it builds ok (I use the cygwin bash and configure, but compile it using mingw). When I try to run the tests using make light it says it can't allocate memory:

gcc -g -O2 -DHAVE_STDARG_H=1 -DHAVE_STDLIB_H=1 -DHAVE_STRING_H=1 -DHAVE_UNISTD_ H=1 -DHAVE_SYS_MMAN_H=0 -DHAVE_SYS_TYPES_H=1 -DHAVE_W32API_WINBASE_H=0 -DHAVE_W3
2API_WINDEF_H=0 -DHAVE_SYS_CYGWIN_H=0  -I. -I.  -c malloc.c -o ./malloc.o
ar cr libdmalloc.a arg_check.o compat.o dmalloc_rand.o dmalloc_tab.o env.o heap.
o chunk.o error.o malloc.o
ranlib libdmalloc.a
rm -f dmalloc_t
gcc  -o aout.exe dmalloc_t.o dmalloc_argv.o libdmalloc.a
mv aout.exe dmalloc_t
./dmalloc_t -s -t 10000
ERROR: Random tests failed. Last dmalloc error: could not grow heap by allocati
ng memory
ERROR: Running special tests failed. Last dmalloc error: could not grow heap by
 allocating memory
Random seed is 1081489869. Final dmalloc error: could not grow heap by allocati
ng memory (43)
make: *** [light] Error 1

I've tried changing HAVE_SBRK and HEAP_GROWS_UP in conf.h, and INTERNAL_MEMORY_SPACE in settings.h. It always builds ok, but it won't pass the make light tests. Do you know how to get dmalloc working with mingw?


Sig:
The human brain is the ultimate case of spaghetti programming.





Mail converted by MHonArc 2.6.19+ http://listengine.tuxfamily.org/