nnstreamer / nntrainer

NNtrainer is Software Framework for Training Neural Network Models on Devices.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

#2214 has a 'std::bad_alloc' issues with model->save(MODEL_FORMAT_INI)

songgot opened this issue · comments

#2214 has a 'std::bad_alloc' issues.
If run the app after adding 'model->save()' to YOLO Application for saving ini file, a segment fault occurs at the location below.

    model->compile();
    model->initialize();
    // model->load(MODEL_INIT_BIN_PATH);
+  model->save("./yolov2.ini", ml::train::ModelFormat::MODEL_FORMAT_INI);

The location is "IniGraphInterpreter interpreter;"

[neuralnet.cpp]

void NeuralNetwork::saveModelIni(const std::string &file_path) {
[...]
  IniWrapper wrapper("model_saver", sections);
  ml_loge("here");
  wrapper.save_ini(file_path);
  ml_loge("here");
  IniGraphInterpreter interpreter;  <=============== here !!
  ml_loge("here");
  interpreter.serialize(graph_representation, file_path);
  ml_loge("here");
}

The location is the end of IniGraphInterpreter().
[ini_interpreter.cpp]

IniGraphInterpreter::IniGraphInterpreter(
  const AppContext &app_context_,
  std::function<const std::string(const std::string &)> pathResolver_) :
  app_context(app_context_),
  pathResolver(pathResolver_) {}  <=== here !!
(gdb) thread 1
[Switching to thread 1 (Thread 0x7ffff4639780 (LWP 8701))]
#0  nntrainer::IniGraphInterpreter::IniGraphInterpreter(nntrainer::AppContext const&, std::function<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const (std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)>) (this=0x7fffffffd600, app_context_=..., pathResolver_=...) at /home/hyunil/new/baek2sm/nntrainer/nntrainer/compiler/ini_interpreter.cpp:53
53	  pathResolver(pathResolver_) {}
(gdb) bt
#0  nntrainer::IniGraphInterpreter::IniGraphInterpreter(nntrainer::AppContext const&, std::function<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const (std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)>) (this=0x7fffffffd600, app_context_=..., pathResolver_=...) at /home/hyunil/new/baek2sm/nntrainer/nntrainer/compiler/ini_interpreter.cpp:53
#1  0x00007ffff78deff1 in nntrainer::NeuralNetwork::saveModelIni (this=0x55555566b800, file_path="./yolov2.ini") at /home/hyunil/new/baek2sm/nntrainer/nntrainer/models/neuralnet.cpp:576
#2  0x00007ffff78dd7e0 in nntrainer::NeuralNetwork::save (this=0x55555566b800, file_path="./yolov2.ini", format=ml::train::ModelFormat::MODEL_FORMAT_INI)
    at /home/hyunil/new/baek2sm/nntrainer/nntrainer/models/neuralnet.cpp:428
#3  0x00005555555bd7f2 in main (argc=1, argv=0x7fffffffdd98) at ../Applications/YOLO/jni/main.cpp:323
(gdb) p app_context_
[...]
_M_manager = 0x7ffff79dc848 <std::_Function_base::_Base_manager<std::unique_ptr<nntrainer::Optimizer, std::default_delete<nntrainer::Optimizer> > (*)(std::vector<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::allocator<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > > > const&)>::_M_manager(std::_Any_data&, std::_Any_data const&, std::_Manager_operation)>}, 
          _M_invoker = 0x7ffff79dc7d7 <std::_Function_handler<std::unique_ptr<nntrainer::Optimizer, std::default_delete<nntrainer::Optimizer> > (std::vector<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::allocator<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > > > const&), std::unique_ptr<nntrainer::Optimizer, std::default_delete<nntrainer::Optimizer> > (*)(std::vector<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::allocator<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > > > const&)>::_M_invoke(std::_Any_data const&, std::vector<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::allocator<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > > > const&)>}}, 
[2] = std::unordered_map with 3 elements = {[999] = "unknown", [0] = "adam", [1] = "sgd"}}, [2] = std::tuple containing = {[1] = std::unordered_map with 43 elements = {
        [<error: Cannot access memory at address 0xd0000000c>] = {<std::_Maybe_unary_or_binary_function<std::unique_ptr<nntrainer::Layer, std::default_delete<nntrainer::Layer> >, std::vector<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::allocator<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > > > const&>> = {<std::unary_function<std::vector<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::allocator<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > > > const&, std::unique_ptr<nntrainer::Layer, std::default_delete<nntrainer::Layer> > >> = {<No data fields>}, <No data fields>}, <std::_Function_base> = {static _M_max_size = 16, static _M_max_align = 8, _M_functor = {_M_unused = {
                _M_object = 0x1500000014, _M_const_object = 0x1500000014, _M_function_pointer = 0x1500000014, 
                _M_member_pointer = (void (std::_Undefined_class::*)(std::_Undefined_class * const)) 0x1500000014, this adjustment -8259855652879343104}, 
              _M_pod_data = "\024\000\000\000\025\000\000\000\000\342\037\332\v\031_\215"}, 
[...]
(gdb) n
(gdb) n
uncaught error while running! details: std::bad_alloc

Thread 1 "nntrainer_yolov" received signal SIGSEGV, Segmentation fault.
__GI___libc_free (mem=0xd0000000c) at malloc.c:3102
3102	malloc.c: No such file or directory.
(gdb) 

see address 0xd0000000c. the address is shown in side _M_invoker = 0x7ffff79dc7d7 and "Cannot access memory at address 0xd0000000c"
I tried to check further, but it's not in my power.
Thank you.

:octocat: cibot: Thank you for posting issue #2224. The person in charge will reply soon.