GTest app crashes with "buffer overrun" before main() on VC++ 2005

74 views
Skip to first unread message

John D

unread,
Dec 17, 2013, 11:13:25 AM12/17/13
to googletes...@googlegroups.com
We are already using GTest on several VC++ 2005 projects and have a single pre-built version of gtest.lib used between projects - so I know GTest is working.

But when I'm trying to add it to a project (actually replacing boost-test), I get a Buffer Overrun error immediately. The console window opens but before main() starts, I get this error. My call stack looks something like this:

  msvcp80d.dll!std::basic_stringstream<char,std::char_traits<char>,std::allocator<char> >::`vbase destructor'()  + 0x12 bytes C++
  MyApp.exe!testing::internal::StringStreamToString()  + 0x168 bytes
  MyApp.exe!string "\nThis test program did NOT call "...()  + 0x58 bytes
  msvcp80d.dll!std::_Traits_helper::copy_s<std::char_traits<char> >(char * _First1=0x00000000, unsigned int _Size=0, const char * _First2=0x0012fe20, unsigned int _Count=1244708, std::_Secure_char_traits_tag __formal={...})  Line 707 + 0x15 bytes C++
  00642908()
  msvcp80d.dll!std::_Mutex::_Unlock()  Line 29 + 0xb bytes C++
  MyApp.exe!testing::Message::GetString()  + 0x17 bytes
  MyApp.exe!testing::internal::GetCapturedStderr()  + 0xa3 bytes
  MyApp.exe!testing::internal::BoolFromGTestEnv()  + 0x13 bytes
  MyApp.exe!_FreeLibrary@4()  + 0x5c7e bytes


I don't really know where to start, I figure some static init code is being run as a result of #include <gtest/gtest.h> but how do I find what's wrong and go about fixing it?

Josh Kelley

unread,
Dec 17, 2013, 12:46:11 PM12/17/13
to John D, Google C++ Testing Framework
I don't have much experience with Visual C++ in particular, but usually, when I get strange errors in static initialization code like that, it's because I've made an error in linking my project: linking parts of the project against the static RTL and other parts against the dynamic RTL, or linking parts against the multi-threaded RTL and parts against the single-threaded RTL, or linking two DLLs or EXEs that each try to statically link to the same code, or similar.

There are probably also compiler flags that could cause errors if they don't match between two projects.

Directly including the Google Test sources in your project should be an easy way of checking for the above.

Otherwise, the next step is probably to set a breakpoint in BoolFromGTestEnv - it's in gtest-port.cc - and run the code in a debugger and see what happens.

--
Josh Kelley


--
 
---
You received this message because you are subscribed to the Google Groups "Google C++ Testing Framework" group.
To unsubscribe from this group and stop receiving emails from it, send an email to googletestframe...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

Reply all
Reply to author
Forward
0 new messages