Closed malcolmdavey closed 1 year ago
Which compiler did you used ?
Visual Studio - toolset v140 (2015) compiler. Debug x64 .
Just noticed that the PR builds for Fakeit are not running the tests for the windows compile.
The crash happens inside this function, inside the lambda call, after m()
has been called, but before the lambda has returned.
It seems to move the return result from m()
into a new string before returning from the function, but then when it calls the destructor for the old string, the address is just wrong, and it crashes. Still haven't worked out the exact cause.
template<typename ... T, typename std::enable_if<all_true<std::is_copy_constructible<T>::value...>::value, int>::type = 0>
std::function<R(arglist&...)> getOriginalMethodCopyArgsInternal(int) {
void *mPtr = MethodMockingContextBase<R, arglist...>::_mock.getOriginalMethod(_vMethod);
C * instance = &(MethodMockingContextBase<R, arglist...>::_mock.get());
return [=](arglist&... args) -> R {
auto m = union_cast<typename VTableMethodType<R,arglist...>::type>(mPtr);
return m(instance, args...); <<< crashes here in string destructor after call to m()
};
}
Should be fixed by https://github.com/eranpeer/FakeIt/pull/312, it will be available in FakeIt 2.3.3 or 2.4.0 depending on which is the first to be released.
Seems my build is detecting a bad string in the Fakeit unit tests. Haven't worked out the fix yet.
In
std::function<R(arglist&...)> getOriginalMethodCopyArgsInternal(int)
it's hitting a string destructor but the pointer is0xcccccccc
implying it isn't initialised, so maybe an invalid piece of memory has been cast to a string.call stack