|
From: <Mi...@gm...> - 2005-02-19 15:39:51
|
Hi, I am working on a large C++ application (ca. 15.000 LOC), and only recently got onto valgrind. The app runs nicely since years on Linux and Solaris, but when trying to port it to MinGW on Windows, it SIGSEGVs right on startup. So I tried to hunt down the bug with valgrind, suspecting it might be a memory problem. But the error messages valgrind produces are confusing me, I cannot see any reason. Example 1: assignments with declaration of local variables - this line (in fact the very first in my app) unsigned int testanz = 0; causes valgrind to issue ==4138== Invalid write of size 4 ==4138== at 0x804ED59: main (runner.cc:22) ==4138== by 0x4030E856: __libc_start_main (in /lib/libc.so.6) ==4138== by 0x8049140: (within /home/micha/e5/runner) ==4138== Address 0xBFFFF32C is not stack'd, malloc'd or free'd Example 2: libc usage: any use of a mem...() or str...() libc function generates an error like ==6300== Invalid read of size 4 ==6300== at 0x1BA79CB2: memset (in /lib/libc.so.6) ==6300== by 0x1BA12856: __libc_start_main (in /lib/libc.so.6) ==6300== by 0x8049170: (within /home/micha/e5/runner) ==6300== Address 0x5290FDD0 is on thread 1's stack What does it all mean to me? Miq. -- DSL Komplett von GMX +++ Supergünstig und stressfrei einsteigen! AKTION "Kein Einrichtungspreis" nutzen: http://www.gmx.net/de/go/dsl |
|
From: Robert W. <rj...@du...> - 2005-02-19 18:49:05
|
> What does it all mean to me? Are you using a home-grown thread package? --=20 Robert Walsh Amalgamated Durables, Inc. - "We don't make the things you buy." Email: rj...@du... |
|
From: MIchael H. <Mi...@gm...> - 2005-02-19 20:15:56
|
> > What does it all mean to me? > > Are you using a home-grown thread package? > > -- > Robert Walsh > Amalgamated Durables, Inc. - "We don't make the things you buy." > Email: rj...@du... > No, nothing at all. It is a plain old single-thread console app... Valgrind warns - if called with the -v option - Warning: client switching stacks? %esp: 0x52BFE35C --> 0x5290FDD0 That may be the reason why, the stack pointer grows a large amount, but I don't know why. Miq. -- Lassen Sie Ihren Gedanken freien Lauf... z.B. per FreeSMS GMX bietet bis zu 100 FreeSMS/Monat: http://www.gmx.net/de/go/mail |
|
From: Olly B. <ol...@su...> - 2005-02-19 20:22:56
|
On 2005-02-19, MIchael Harwerth <Mi...@gm...> wrote:
> No, nothing at all. It is a plain old single-thread console app... Valgrind
> warns - if called with the -v option -
>
> Warning: client switching stacks? %esp: 0x52BFE35C --> 0x5290FDD0
>
> That may be the reason why, the stack pointer grows a large amount, but I
> don't know why.
Do you declare any large automatic arrays?
something like:
int func(void) {
int bigarray[1000000];
func2();
}
Valgrind has a heuristic to try to detect stack switches - this warning
means it fired. If you aren't switching stacks, something like the
above is likely to be the reason (and may explain crashes on platforms
which aren't able to allocate large amounts of extra stack on demand).
Cheers,
Olly
|