Using gdb you can put a watch on a variable or memory location. As soon as
it changes the program will break and you can look at what the last
instruction was. It probably won't seem to have anything to do with the fd
itself, probably an array or something that's getting overwritten.
I'd link to the relevant page on how to do this but my internet is out and
I'm responding on my phone right now.
On Jan 1, 2015 1:45 PM, João M. S. Silva <joao.m.santos.si...@gmail.com>
wrote:
> On 01/01/2015 06:03 PM, Tom Hughes wrote:
> > Surely the easy fix is to fix your program to stop it trying to read
> > from an invalid file descriptor? Surely that is a bug that you will want
> > to fix anyway?
>
> Yes. I've printed the fd value and it goes from 13 to 29541 with no
> deliberate function overwriting it. One thing that I find strange is why
> didn't valgrind detect the instruction that overwrote the fd?
>
> If I use a watch in gdb to catch this change, it does not occur.
>
> Also, fd is a private member variable. If I make it public, this does
> not happen.
>
> Also, if I compile with clang instead of gcc, this does not happen.
>
> I'm trying to analyze this, but I'm not still sure from which code or
> tool the error might be coming.
>
> Any hints?
>
> Thanks.
>
> --
> João M. S. Silva
>
>
> ------------------------------------------------------------------------------
> Dive into the World of Parallel Programming! The Go Parallel Website,
> sponsored by Intel and developed in partnership with Slashdot Media, is
> your
> hub for all things parallel software development, from weekly thought
> leadership blogs to news, videos, case studies, tutorials and more. Take a
> look and join the conversation now. http://goparallel.sourceforge.net
> _______________________________________________
> Valgrind-users mailing list
> Valgrind-users@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/valgrind-users
>
------------------------------------------------------------------------------
Dive into the World of Parallel Programming! The Go Parallel Website,
sponsored by Intel and developed in partnership with Slashdot Media, is your
hub for all things parallel software development, from weekly thought
leadership blogs to news, videos, case studies, tutorials and more. Take a
look and join the conversation now. http://goparallel.sourceforge.net
_______________________________________________
Valgrind-users mailing list
Valgrind-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/valgrind-users