Hi, I'm trying to use protobuf and am experiencing a release mode
static initialization crash. Specifically a crash in
FileOptions::Clear(). Partial stack trace follows the message.

We're using MS Visual C++ 2005 to compile libprotobuf.lib and
libprotoc.lib statically (rev 89, 2.0.4-SNAPSHOT), and link to the CRT
statically. Our project gets compiled (also via MSVC++ 2005) into a
DLL and links to MFC and the CRT statically as well (/MT). We're
experiencing this crash when a process loads our project dll. Now the
peculiar thing is that we've narrowed it down to being able to trigger
the crash with just a single line:

std::ofstream out;

If we define an ofstream object anywhere, even locally in a function,
then the dll fails to load and crashes. This doesn't occur in debug
mode. I've tried disabling most optimizations, and I've found that
didn't make a difference.  We've also had trouble reproducing this in
example projects which don't seem to be any different from our live
project, except perhaps being simpler. Our project doesn't link to any
other 3rd party libraries except whatever gets pulled in with MFC and
Windows (which hasn't given us any issues similar before).

We did try compiling protobuf and our project to link to the CRT
and that seemed to get rid of this issue, but for various reasons
interested in having it work with linking to the CRT statically.

I'm looking for ideas as to what may be causing this. I'm concerned
isn't the only thing involved with this and would like to avoid
future issues. Any ideas would be much appreciated.


Here's the stack trace I receive:
>       _crt_debugger_hook(_Reserved=4194304) Line 65   C
        _invalid_parameter(pszExpression=0x00000000, pszFunction=0x00000000,
pszFile=0x00000000, nLine=0, pReserved=0) Line 86 + 0x7 bytes   C++
        _invalid_parameter_noinfo() Line 99 + 0xc bytes C++
>::erase(_First=0x05aaad98 "com.google.protobuf", _Last=0x05aaadab "")
Line 1265 + 0x24 bytes  C++
>::clear() Line 1272    C++
        google::protobuf::FileOptions::Clear() Line 3474        C++
Line 139 + 0x9 bytes    C++
 com.google.protobufB DescriptorProtosH ") Line 151     C++
(options_to_interpret=0x05aaaf40) Line 3300 + 0xa bytes C++
descriptor_assigner=) Line 2405 + 0x15 bytes    C++
(data=0x049e3538, size=3449, descriptor_assigner=0x04985d90) Line 1962
+ 0x4d bytes    C++
() Line 547     C++
(message=0x05a97a00, proto={...}) Line 2890 + 0xe bytes C++
proto=) Line 2871 + 0x18 bytes  C++
descriptor_assigner=0x049563d0) Line 2400       C++
(data=0x049dfd68, size=342, descriptor_assigner=0x049563d0) Line 1962
+ 0x4d bytes    C++
        fs::proto::protobuf_BuildDesc_arraydata_2eproto() Line 68       C++

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