I've been trying to trace down a strange problem which I am having. I
am creating a DLL and linking to protobufs statically, as the DLL uses
protobufs internally. When the DLL is loaded, it crashes in
CodedOutputStream::WriteRaw(), trying to memcpy new data directly into
an output stream buffer.

I believe the error occurs during the resizing of the output stream's

Stepping into...

The member StringOutputStream::target_ gets resized (was: empty, now:
47 bytes allocated).

Next is now supposed to return a pointer to the std::string's internal
buffer. To do this it calls a function in stl_util.h called
"string_as_array", which I believe is supposed to provide direct
access to the interal buffer of a string. This is where I believe the
error occurs, because the returned buffer is NULL.

Accodring to the debugger, the string that was passed is a valid
string capable of holding 47-bytes. str->empty() evaluates to false,
and str->_Mysize == 47.

The comments indicate that this function is doing some sort of
workaround to get direct access to the string's internal buffer.
Perhaps this workaround is broken on the MSVC 9.0 implementation of
the stl?

Oddly, I am unable to duplicate the error in a smaller test-jig. To
throw a wrench in the works, when I attach a debugger to the release
build appears to crash at a different place during the initialization,
but I haven't figured out what is going on there.

Is there something obvious which I may have missed? Any help is
appreciated, thanks!

Justin Muncaster
Toyon Research Corporation
You received this message because you are subscribed to the Google Groups 
"Protocol Buffers" group.
To post to this group, send email to protobuf@googlegroups.com
To unsubscribe from this group, send email to 
For more options, visit this group at 

Reply via email to