Re: [boost] [serialization] MSVC8 runtime check error

John Reid wrote:
I'm getting a runtime check error from MSVC8 in the following code checked out from cvs_head:
serialization/collections_load_imp.hpp line 116
...
template<class Archive, class Container, class InputFunction, class R> inline void load_collection(Archive & ar, Container &s) { s.clear(); // retrieve number of elements unsigned int count; unsigned int item_version; ar >> BOOST_SERIALIZATION_NVP(count); if(3 < ar.get_library_version()){ ar >> BOOST_SERIALIZATION_NVP(item_version); } R rx; rx(s, count); InputFunction ifunc; while(count-- > 0){ ifunc(ar, s, item_version); } }
...
The debugger breaks every time ifunc() is called which is frustrating to say the least.
If load_collection() is wrapped with
#pragma runtime_checks( "u", off ) ... #pragma runtime_checks( "u", restore )
it doesn't help - perhaps I've rebuilt it incorrectly, perhaps the pragma needs to be around where the code is instantiated. I managed to get around the problem by assigning 0 to item_version.
What happens when you break into the debugger. VC8 supports range checked iterators, dereferencing an invalid iterator, etc. What is the exception/assert message being generated? Can you use the VC8 debugger and see what values each of the variables are at the point where the assert/exception was generated? Is there any information you can gather by looking up the callstack?
Has anyone specifically chosen to turn runtime checks on for debug builds with MSVC8 or is this just the default?
VC8 has additional error checking when compiling for debug. - Reece _________________________________________________________________ Express yourself instantly with MSN Messenger! Download today it's FREE! http://messenger.msn.click-url.com/go/onm00200471ave/direct/01/

Reece Dunn wrote:
What happens when you break into the debugger. VC8 supports range checked iterators, dereferencing an invalid iterator, etc.
I don't break into the debugger, my program breaks during normal execution.
What is the exception/assert message being generated? Can you use the VC8 debugger and see what values each of the variables are at the point where the assert/exception was generated? Is there any information you can gather by looking up the callstack?
It is clear by inspection that item_version is not initialised if 3 >= ar.get_library_version() and then used as an argument to ifunc. As a minimum/temporary solution I'd advise that the line: unsigned int item_version; is replaced by unsigned int item_version = 0; or put an else clause in the if statement.
VC8 has additional error checking when compiling for debug.
Perhaps these should explicitly be turned on by boost developers and be left off by default so users don't get caught by other problems like this. Regards, John.
participants (2)
-
John Reid
-
Reece Dunn