|
From: Nicholas N. <nj...@ca...> - 2004-11-18 16:51:32
|
[forwarding to the users list] ---------- Forwarded message ---------- Date: Thu, 18 Nov 2004 22:01:38 +0530 From: asu...@hs... Subject: Some queries regarding the usage of Valgrind Hi, I am using valgrind-2.0.0 for detecting memory leaks in ny code. I'm using the following command line invocation valgrind --leak-check=yes <binary name> The output clearly shows the memory which has been lost completely. I guess this means that the pointer holding the address to the allocated chunks have been overwritten. Is my understnading correct? Secondly, I get traces for memory chunks which can be traced but were not released when the system exited. In following lines I will describe the sequence of memory allocations. I have a global block of memory which is allocated at system config ( say x bytes). I start a transaction and during the processing of the transaction some more memory blocks are allocated ( say y and z bytes). The pointers to these are assigned to some member variables of the previously allocated structure ( of x bytes). Now at the end of processing, valgrind shows that there is memory unreleased for the system config structure. But the size of the structure is larger than the size of memory assigned to structure at config time. Is there some way by which I can get a backtrace of every malloc for which there was no corresponding free using valgrind? Am I using correct command line invocation for valgrind? That will be of great help to me thanks ®ards Aashish Suchdev Hughes Software Systems Gurgaon, India PS: I am working on Redhat Linux 7.3. Also my code uses threads. Anything more I need to do to use valgrind for a multithreaded system? |
|
From: Rahul R. <ra...@ya...> - 2004-11-24 11:34:29
|
Thanks for the information. Could I use either of the following 2 functions for getting the stack, heap address space to detect uninitialized words in the memory? Would I be able to get the lower and upper bounds of the user program address space from the below functions? ( I want to avoid using any addresses which have been initialized by valgrind during program loading, and want to be checking only address used by the client program). esp_at_startup___global_arg = esp_at_startup; VG_(parse_procselfmaps) ( build_segment_map_callback ); /* everything */ Thanks & Regards, ~Rahul. |
|
From: Nicholas N. <nj...@ca...> - 2004-11-24 12:13:55
|
On Wed, 24 Nov 2004, Rahul Ravindran wrote: > Thanks for the information. > Could I use either of the following 2 functions for getting the stack, heap > address space to detect uninitialized words in the memory? Would I be able to > get the lower and upper bounds of the user program address space from the below > functions? ( I want to avoid using any addresses which have been initialized by > valgrind during program loading, and want to be checking only address used by > the client program). > > esp_at_startup___global_arg = esp_at_startup; > VG_(parse_procselfmaps) ( build_segment_map_callback ); /* everything */ It might be much easier to use the VG_(is_client_addr)() function... N |
|
From: Rahul R. <ra...@ya...> - 2004-11-24 14:24:19
|
Hi again, To make my problem a little more clear, I need to find uninitialized words in memory to detect uninitalized usage of memory by the client program. I try doing this at the L1 and L2 cache level. But I find that there are a number of memory reads from addresses which were not initialized (written) before ( Example: usage of uninitialized variables,heap memory etc). I have assumed that these were written by the program loader. I cannot flag such accesses as errors as they are not invalid and is not even part of the client program memory access. I had thought that one way of getting around this problem would be to find the stack and the heap address spaces for the client program and compare memory addresses . If they memory addresses lie only within the heap or stack, would I need to check for initialization. Is there a better approach to solving the above problem? With regard to VG_(is_client_addr)(): Some of the addresses which were initially initialized by valgrind in the client address space would return true in the VG_(is_client_addr)(), right? I want to deal with only the memory space which is directly used by the client program. The above method, returns true , almost all the time. Could you please help me on this, as my project deadline is approaching next week. Thanks a lot, ~Rahul. |