From: Vincent Penquerc'h <Vin...@ar...> - 2003-06-17 14:55:31
|
If the routine isn't recursive, just add "static" in front of your local array, this will statically allocate it in the bss section rather than dynamically on the stack. As for stack size, I don't really know, maybe someone on the list knows. -- Vincent Penquerc'h > -----Original Message----- > From: Geert Fannes [mailto:gee...@es...] > Sent: Tuesday, June 17, 2003 5:31 PM > To: Vincent Penquerc'h > Subject: Re: [Valgrind-users] thread errors on non-threaded program > > > thank you for your response, it helped a lot! i allocated a > large array > at the beginning of that function in a stupid manner: > > bool GRV::bLoadRVsFromFile(GDLLpGBaseObject *pRVList,const char > *strPathNameRV,const char *strPathNameCPD,bool bFilterStrict) > { > FILE* pFileIn; > long lNrRVs = 0,lNrCPDs = 0,lNrElementsInRVList,i; > !!!char strBuffer[5000000]!!!; > ... > > instead of using: > > new char[5000000]; > > do you have any idea how large my stack (or heap?) is? (i > mean the place > where local variables are located, like the char strBuffer[5000000].) > > greets, > geert. > > > Vincent Penquerc'h wrote: > >>hello, i have a monolythic C++ program (3766634 bytes) for which > >>valgrind gives errors like beneath. i don't know what these > >>errors mean, > >>but i don't trust the threaded stuff in it, since my program is > >>non-threaded (i even don't exactly know what a threaded > >>program is, i'm > >>guessing that it has to do with forking etc.) > > > > > > Not quite. Forking creates a new process, threads are different > > (I guess you could call them micro processes) running in the same > > data space, albeit with different stacks. > > In your case, you have a thread. Every program has a thread, but > > a program is said to be threaded if it has more than 1 thread. > > Your program is not threaded, but the "thread 1" message below > > just says errors come the main program thread, which is, in your > > case, your program's default thread. > > > > > > > >>where can i find more information about the origin of the > >>error and the > >>error itself (i'm guessing that 15180 is some error code)? > > > > > > It's the process ID. > > > > > >>==15180== Invalid write of size 1 > >>==15180== at 0x80C3FDC: > >>GRV::bLoadRVsFromFile(GDLLpGBaseObject*, char > >>const*, char const*, bool) (GRV.cpp:346) > >>==15180== Address 0xBFB388EF is on thread 1's stack > >>==15180== > >>==15180== Invalid write of size 4 > >>==15180== at 0x80C3FE2: > >>GRV::bLoadRVsFromFile(GDLLpGBaseObject*, char > >>const*, char const*, bool) (GRV.cpp:357) > >>==15180== Address 0xBFB388E4 is on thread 1's stack > > > > > > Your program seems to be writing something in a memory location > > which is not accessible. I'm not exactly sure about the error > > message formats, but it looks like it's trying to write under > > the stack pointer (which could be the result of a buffer overflow > > in a local auto array). I'm not very used to Valgrind yet, so > > I could be wrong on that diagnostic, so I'll let the pros figure > > it out :) > > > > > |