|
From: Erik de C. L. <eri...@me...> - 2005-09-25 22:41:45
|
Paul Pluzhnikov wrote: > On 9/25/05, Erik de Castro Lopo <eri...@me...> wrote: > > > Found my problem. The array length was not being initialised correctly. > > But you said the arrays were on the heap ... I was wrong :-). The code in question was written by someone else and contributed to my project and it seemed to work. The only problem was that valgrind was reporting these errors. Looking at the code, pointers to the arrays were in a struct allocated on the heap. The struct was allocated using calloc() so the pointer values should have been NULL. AFAIAC the program should have crashed outside valgrind with a read/write to a NULL pointer. There was some code that allocated memory for these arrays that I had "#if 0"-ed out because I didn't understand why it was placed where it was. Removing the "#if 0" fixed the problem. > Why did VG complain about stack? Something doesn't fit here. How big is the window on the stack that valgrind checks? Does it check a long way below %esp or only a short way? > Perhaps you can provide a small test case demonstrating how a bug in > (heap) array lenght shows up as a read beyond stack under VG? I am still curious as to why the program was seemingly behaving correctly but was in hindsight so wrong. However, Since I have fixed my problem, my motivation for doing more debugging on this is not huge :-). If someone is interested in pursuing this I can provide the code and point them in the right direction. Teh first task would be parring down the example to a workable size; the code is about 40k lines and links to an external library. Erik -- +-----------------------------------------------------------+ Erik de Castro Lopo +-----------------------------------------------------------+ "Data is not information, Information is not knowledge, Knowledge is not understanding, Understanding is not wisdom." -- Clifford Stoll |