[protobuf] valgrind invalid write and double free errors

2010-10-13 Thread CB
I've been using protobuf 2.3.0 for several weeks, using
SerializeToString.  The
other day, I switched to using SerializeToOstream, and started seeing
the
following invalid write and double free errors reported by valgrind
when my
program is terminated;

==15778== Invalid write of size 4
==15778==at 0x6623464:
google::protobuf::FileDescriptorTables::~FileDescriptorTables()
(hashtable:532)
==15778==by 0x4D821BE: __run_exit_handlers (exit.c:78)
==15778==by 0x4D8222E: exit (exit.c:100)
==15778==by 0x4D69BDD: (below main) (libc-start.c:258)
==15778==  Address 0x635dc80 is 0 bytes inside a block of size 48
free'd
==15778==at 0x4024851: operator delete(void*) (vg_replace_malloc.c:
387)
==15778==by 0x4D821BE: __run_exit_handlers (exit.c:78)
==15778==by 0x4D8222E: exit (exit.c:100)
==15778==by 0x4D69BDD: (below main) (libc-start.c:258)
==15778==
==15778== Invalid free() / delete / delete[]
==15778==at 0x4024851: operator delete(void*) (vg_replace_malloc.c:
387)
==15778==by 0x4D821BE: __run_exit_handlers (exit.c:78)
==15778==by 0x4D8222E: exit (exit.c:100)
==15778==by 0x4D69BDD: (below main) (libc-start.c:258)
==15778==  Address 0x635dc80 is 0 bytes inside a block of size 48
free'd
==15778==at 0x4024851: operator delete(void*) (vg_replace_malloc.c:
387)
==15778==by 0x4D821BE: __run_exit_handlers (exit.c:78)
==15778==by 0x4D8222E: exit (exit.c:100)
==15778==by 0x4D69BDD: (below main) (libc-start.c:258)

The above are one example of several reports.  it appears there is one
set of
these for each proto message I have defined.

I've tried to recreate this error in a smaller example program for
several days
without success.  Am wondering if anyone on the list has seen this
problem, and
knows what might cause it?

I'm using SerializeToOstream in basically the following manner;


  char buf[512];
  std::stringbuf sbuf;
  sbuf.pubsetbuf((char*)buf, 512);
  std::ostream os(&sbuf);
  message.SerializeToOstream(&os);

Any feedback on how to further debug this problem would be
appreciated.

--CB

-- 
You received this message because you are subscribed to the Google Groups 
"Protocol Buffers" group.
To post to this group, send email to proto...@googlegroups.com.
To unsubscribe from this group, send email to 
protobuf+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/protobuf?hl=en.



Re: [protobuf] valgrind invalid write and double free errors

2010-10-13 Thread Evan Jones

On Oct 13, 2010, at 16:53 , CB wrote:

Any feedback on how to further debug this problem would be
appreciated.


You aren't doing anything strange like using dlopen() to dynamically  
load/unload libraries, are you? I can't think of anything obvious that  
might cause this kind of error. The FileDescriptorTables are "static"  
objects of sorts, I think. Are you calling ShutdownProtobufLibrary()  
somewhere? Maybe more than once? Memory leaks *will* be reported by  
valgrind if you don't call ShutdownProtobufLibrary(), but I don't know  
what could cause a double free.


Evan


--
Evan Jones
http://evanjones.ca/

--
You received this message because you are subscribed to the Google Groups "Protocol 
Buffers" group.
To post to this group, send email to proto...@googlegroups.com.
To unsubscribe from this group, send email to 
protobuf+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/protobuf?hl=en.



Re: [protobuf] valgrind invalid write and double free errors

2010-10-19 Thread Kenton Varda
These don't look like they have anything to do with the I/O change.  The
"FileDescriptor" class describes the contents of a .proto file (it's not
related to OS file descriptors).  The problems you're seeing appear to be
happening while running global destructors -- i.e. at program shutdown.  Are
you sure that this is the result of switching from strings to ostreams?  I
strongly suspect that you changed something else at the same time which lead
to the problem, or the problem actually existed before the change and you
didn't notice for some reason.

On Wed, Oct 13, 2010 at 1:53 PM, CB  wrote:

> I've been using protobuf 2.3.0 for several weeks, using
> SerializeToString.  The
> other day, I switched to using SerializeToOstream, and started seeing
> the
> following invalid write and double free errors reported by valgrind
> when my
> program is terminated;
>
> ==15778== Invalid write of size 4
> ==15778==at 0x6623464:
> google::protobuf::FileDescriptorTables::~FileDescriptorTables()
> (hashtable:532)
> ==15778==by 0x4D821BE: __run_exit_handlers (exit.c:78)
> ==15778==by 0x4D8222E: exit (exit.c:100)
> ==15778==by 0x4D69BDD: (below main) (libc-start.c:258)
> ==15778==  Address 0x635dc80 is 0 bytes inside a block of size 48
> free'd
> ==15778==at 0x4024851: operator delete(void*) (vg_replace_malloc.c:
> 387)
> ==15778==by 0x4D821BE: __run_exit_handlers (exit.c:78)
> ==15778==by 0x4D8222E: exit (exit.c:100)
> ==15778==by 0x4D69BDD: (below main) (libc-start.c:258)
> ==15778==
> ==15778== Invalid free() / delete / delete[]
> ==15778==at 0x4024851: operator delete(void*) (vg_replace_malloc.c:
> 387)
> ==15778==by 0x4D821BE: __run_exit_handlers (exit.c:78)
> ==15778==by 0x4D8222E: exit (exit.c:100)
> ==15778==by 0x4D69BDD: (below main) (libc-start.c:258)
> ==15778==  Address 0x635dc80 is 0 bytes inside a block of size 48
> free'd
> ==15778==at 0x4024851: operator delete(void*) (vg_replace_malloc.c:
> 387)
> ==15778==by 0x4D821BE: __run_exit_handlers (exit.c:78)
> ==15778==by 0x4D8222E: exit (exit.c:100)
> ==15778==by 0x4D69BDD: (below main) (libc-start.c:258)
>
> The above are one example of several reports.  it appears there is one
> set of
> these for each proto message I have defined.
>
> I've tried to recreate this error in a smaller example program for
> several days
> without success.  Am wondering if anyone on the list has seen this
> problem, and
> knows what might cause it?
>
> I'm using SerializeToOstream in basically the following manner;
>
>
>  char buf[512];
>  std::stringbuf sbuf;
>  sbuf.pubsetbuf((char*)buf, 512);
>  std::ostream os(&sbuf);
>  message.SerializeToOstream(&os);
>
> Any feedback on how to further debug this problem would be
> appreciated.
>
> --CB
>
> --
> You received this message because you are subscribed to the Google Groups
> "Protocol Buffers" group.
> To post to this group, send email to proto...@googlegroups.com.
> To unsubscribe from this group, send email to
> protobuf+unsubscr...@googlegroups.com
> .
> For more options, visit this group at
> http://groups.google.com/group/protobuf?hl=en.
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Protocol Buffers" group.
To post to this group, send email to proto...@googlegroups.com.
To unsubscribe from this group, send email to 
protobuf+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/protobuf?hl=en.