[sldev] Subtle STL bug in VC8/VS2005 build

Matt Kimmel mattk at electricsheepcompany.com
Thu Jun 28 20:10:06 PDT 2007


Hey all,

While attempting to revive the "test" project for the VS2005 build (the
subject of another thread entirely!), I uncovered a subtle but serious
bug that has quite possibly been causing a lot of the crashes that
various contributers have seen when building under VS2005.

It was fixable with a project-file change, so I've uploaded new versions
of the VS2005 project files to
https://jira.secondlife.com/browse/VWR-1151 with the fix included.

For those interested, here are the technical details, cut and pasted
from my comment on the JIRA:

"Found a very subtle but global bug caused by a change in behavior
between VC7.1's STL implementation and VC8's STL implementation. VC8, by
default, checks STL iterators to ensure that they have a back-link to
their associated container. If they don't, the program will break (if
you're running in the debugger) or crash (if you're not). However, you
can still create a containerless iterator by calling the default
constructor on an iterator type--and, as it turns out,
LLSD::Impl::beginArray() and LLSD::Impl::endArray() do exactly that.
This means that if beginArray() or endArray() are called on the
"immutableUndefined" LLSD instance returned by LLSD::Impl::undef(), an
iterator will be created that will later crash the app.

The solution to this is to pre-define the preprocessor symbol
_SECURE_SCL to be 0, in the project files. This causes that particular
iterator check to be disabled, and the behavior reverts to exactly what
it was in VC7.1. With the project files contained in this JIRA issue,
the easiest way to do that is to add _SECURE_SCL=0 to the preprocessor
definitions in SL-UpgradeFromVC71_vc8.vsprops, so that all projects and
all configurations inherit it."

Hopefully, this will stabilize the VS2005 build considerably!

-Matt
-- 
Matt Kimmel, Software Alchemist
The Electric Sheep Company
-------------------------------------
Email: mattk at electricsheepcompany.com
SL: Feep Larsson



More information about the SLDev mailing list