Mlpack: A Runtime Exception std::bad_alloc may be caused when using Timer

Created on 17 Nov 2016  ·  3Comments  ·  Source: mlpack/mlpack

toolset version: mlpack 2.1.0, armadillo 7.500.0, openblas 0.2.19, boost 1.62.0
platform: visual studio 2015 win64

Code:

include

using namespace mlpack;

int main(int argc, char ** argv)
{
Timer::Start("some_timer");
Timer::Stop("some_timer");
return 0;
}

Exception:
0x00007FFAD9097788 处(位于 VTM.exe 中)引发的异常: Microsoft C++ 异常: std::bad_alloc,位于内存位置 0x000000EFE24FF320 处。
0x00007FFAD9097788 处(位于 VTM.exe 中)引发的异常: Microsoft C++ 异常: std::bad_alloc,位于内存位置 0x000000EFE24FCD30 处。
0x00007FFAD9097788 处(位于 VTM.exe 中)引发的异常: Microsoft C++ 异常: [rethrow],位于内存位置 0x0000000000000000 处。
0x00007FFAD9097788 处(位于 VTM.exe 中)引发的异常: Microsoft C++ 异常: std::bad_alloc,位于内存位置 0x000000EFE24FCD30 处。
0x00007FFAD9097788 处(位于 VTM.exe 中)引发的异常: Microsoft C++ 异常: [rethrow],位于内存位置 0x0000000000000000 处。
0x00007FFAD9097788 处(位于 VTM.exe 中)引发的异常: Microsoft C++ 异常: std::bad_alloc,位于内存位置 0x000000EFE24FCD30 处。
0x00007FFAD9097788 处(位于 VTM.exe 中)有未经处理的异常: Microsoft C++ 异常: std::bad_alloc,位于内存位置 0x000000EFE24FCD30 处。

Call Stack:
KernelBase.dll!00007ffad9097788() 未知
vcruntime140.dll!00007ffacfb52a10() 未知
ntdll.dll!00007ffadc5f8f23() 未知
mlpack.dll!std::_Tree_comp_alloc,std::allocator >,bool,std::less,std::allocator > >,std::allocator,std::allocator > const ,bool> >,0> >::_Buynode,std::allocator > const & __ptr64>,std::tuple<> >(const std::piecewise_construct_t & <_Val_0>, std::tuple,std::allocator > const &> && <_Val_1>, std::tuple<> && <_Val_2>) 行 887 C++
mlpack.dll!std::map,std::allocator >,bool,std::less,std::allocator > >,std::allocator,std::allocator > const ,bool> > >::operator 行 338 C++
mlpack.dll!mlpack::Timers::StartTimer(const std::basic_string,std::allocator > & timerName) 行 130 C++

VTM.exe!main(int argc, char * * argv) 行 7 C++
[外部代码]

Most helpful comment

Thanks a lot! Finally, I find that is my fault. I have linked the Release library in Debug mode by mistaken. I will close this issue. Thanks again for you help.

All 3 comments

Hi there,

I can't reproduce this because I don't have a Windows machine. I have an idea, but I don't think it will work.

Can you change line 130 of src/mlpack/core/util/timers.cpp from

if ((timerState[timerName] == 1) && (timerName != "total_time"))

to

if ((timerState.count(timerName) > 0) && (timerState[timerName] == 1) && (timerName != "total_time"))

and see if anything is different?

Thanks a lot! Finally, I find that is my fault. I have linked the Release library in Debug mode by mistaken. I will close this issue. Thanks again for you help.

Great, glad you got it figured out! :)

Was this page helpful?
0 / 5 - 0 ratings

Related issues

joeljosephjin picture joeljosephjin  ·  5Comments

mrityunjay-tripathi picture mrityunjay-tripathi  ·  6Comments

zoq picture zoq  ·  6Comments

u8sand picture u8sand  ·  6Comments

kartikdutt18 picture kartikdutt18  ·  3Comments