[cmake-developers] Storage reallocation inside std::vector causing memory problem when using variable_watch

Brad King brad.king at kitware.com
Tue Mar 22 11:48:53 EDT 2016


On 03/22/2016 10:52 AM, Yves Frederix wrote:
> What happens is that 'def' is assigned at the beginning of the
> function, but during the call to  vv->VariableAccessed(...), there is
> an internal memory re-allocation

Thanks for tracking this down!  Let's just add a

  std::string local_def = def;

inside the variable watch block so we have a locally-owned
string to pass instead.  I'm not concerned about the cost of
the local allocation because this variable watches are for
debugging anyway.

Please look at doing that every where VariableAccessed
is called.

Thanks,
-Brad



More information about the cmake-developers mailing list