[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: memory debugging and C++ (program keeps crashing)



On Tue, Oct 01, 2002 at 08:49:47AM +0200, Cyrille Chepelov wrote:
> > VG_(get_memory_from_mmap): request for 1953656832 bytes failed.
> > VG_(get_memory_from_mmap): 58853360 bytes already allocated.
> 
> Something's trying to allocate 2 gigs of RAM (if I got the order of
> magnitude right) I don't think that's something a regular process is 
> supposed to succeed with frequently on x86-32.

Not my program... It works fine without valgrind (at least at the
moment).

> Are you using a kernel with the regular userland/kernel limit?

Just a standard 2.4.18 kernel, no patches to the VM, not
changes to /proc that would affect the VM system, etc.

> What was the program in question? (It may very well be that the program in
> question was _expecting_ the syscall to fail, but VG didn't know that and
> failed where it shouldn't have. IOW, a bug).

It is a program that I have written. To the best of my knowledge (having
written all of the code minus system libraries) it should never even try
to allocate memory anywhere close to being that big, unless something is
wrong with the compiler:

ii  g++            2.95.4-14      The GNU C++ compiler.

The program doesn't even hesitate while loading, which might
indicate that it is attempting an impossible malloc.

> Can you run this again with the GNOME _debugging_ libraries so that we know
> what attempted that big malloc?

I am not sure valgrind is displaying the stack trace to that big
malloc (is there anyway to change that?). Anyway, the following gets
displayed:

==28926== Estimated CPU clock rate is 847 MHz
==28926== For more details, rerun with: -v
==28926== 
==28926== pthread_mutex_unlock: mutex is not locked
==28926==    at 0x4049773F: __pthread_mutex_unlock (/tmp/buildd/valgrind-1.0.3/vg_libpthread.c:837)
==28926==    by 0x40323F55: (within /usr/lib/libgnomemm-1.2.so.9.0.3)
==28926==    by 0x400473C2: (within /usr/lib/valgrind/valgrind.so)
==28926==    by 0x40047265: (within /usr/lib/valgrind/valgrind.so)

==28926== 
==28926== pthread_mutex_destroy: mutex is still in use
==28926==    at 0x40496978: pthread_error (/tmp/buildd/valgrind-1.0.3/vg_libpthread.c:233)
==28926==    by 0x404977A1: __pthread_mutex_destroy (/tmp/buildd/valgrind-1.0.3/vg_libpthread.c:854)
==28926==    by 0x40AA4940: (within /lib/libc-2.2.5.so)
==28926==    by 0x40AA28F7: (within /lib/libc-2.2.5.so)

[program pauses here for about 5 seconds ]

==28911== 
==28911== Syscall param write(buf) contains uninitialised or unaddressable byte(s)
==28911==    at 0x40AFC404: (within /lib/libc-2.2.5.so)
==28911==    by 0x4065C98B: _IceTransSocketWrite (/mnt/scratch/xfree86/4.1.0/xfree86-4.1.0/build-tree/xc/lib/ICE/../../lib/xtrans/Xtranssock.c:1750)
==28911==    by 0x4065D653: _IceTransWrite (/mnt/scratch/xfree86/4.1.0/xfree86-4.1.0/build-tree/xc/lib/ICE/../../lib/xtrans/Xtrans.c:855)
==28911==    by 0x406551FC: _IceWrite (/mnt/scratch/xfree86/4.1.0/xfree86-4.1.0/build-tree/xc/lib/ICE/misc.c:378)
==28911==    Address 0x4424EEC7 is 3 bytes inside a block of size 1024 alloc'd
==28911==    at 0x4004749B: malloc (/tmp/buildd/valgrind-1.0.3/vg_clientfuncs.c:100)
==28911==    by 0x40652410: IceOpenConnection (/mnt/scratch/xfree86/4.1.0/xfree86-4.1.0/build-tree/xc/lib/ICE/connect.c:219)
==28911==    by 0x40648301: SmcOpenConnection (/mnt/scratch/xfree86/4.1.0/xfree86-4.1.0/build-tree/xc/lib/SM/sm_client.c:109)
==28911==    by 0x404ECC77: (within /usr/lib/libgnomeui.so.32.14.1)

[program pauses here for about 2 seconds ]

==28911== 
==28911== Syscall param write(buf) contains uninitialised or unaddressable byte(s)
==28911==    at 0x40AFC404: (within /lib/libc-2.2.5.so)
==28911==    by 0x4082636B: _X11TransSocketWrite (/mnt/scratch/xfree86/4.1.0/xfree86-4.1.0/build-tree/xc/lib/X11/../../lib/xtrans/Xtranssock.c:1750)
==28911==    by 0x40826E83: _X11TransWrite (/mnt/scratch/xfree86/4.1.0/xfree86-4.1.0/build-tree/xc/lib/X11/../../lib/xtrans/Xtrans.c:855)
==28911==    by 0x4080B9DC: _XFlushInt (/mnt/scratch/xfree86/4.1.0/xfree86-4.1.0/build-tree/xc/lib/X11/XlibInt.c:631)
==28911==    Address 0x441ACB54 is 124 bytes inside a block of size 2048 alloc'd
==28911==    at 0x4004796F: calloc (/tmp/buildd/valgrind-1.0.3/vg_clientfuncs.c:239)
==28911==    by 0x407FF236: XOpenDisplay (/mnt/scratch/xfree86/4.1.0/xfree86-4.1.0/build-tree/xc/lib/X11/OpenDis.c:265)
==28911==    by 0x40793A22: gdk_init_check (/home/tagoh/work/Debian/gtk+1.2/gtk+1.2-1.2.10/gdk/gdk.c:412)
==28911==    by 0x406F1226: gtk_init_check (/home/tagoh/work/Debian/gtk+1.2/gtk+1.2-1.2.10/gtk/gtkmain.c:247)

VG_(get_memory_from_mmap): request for 1953656832 bytes failed.
VG_(get_memory_from_mmap): 61999088 bytes already allocated.

This may mean that you have run out of swap space,
since running programs on valgrind increases their memory
usage at least 3 times.  You might want to use 'top'
to determine whether you really have run out of swap.
If so, you may be able to work around it by adding a
temporary swap file -- this is easier than finding a
new swap partition.  Go ask your sysadmin(s) [politely!]

VG_(get_memory_from_mmap): out of memory!  Fatal!  Bye!
-- 
Brian May <bam@debian.org>



Reply to: