Shark-ML / Shark

The Shark Machine Leaning Library. See more:
http://shark-ml.github.io/Shark/
GNU Lesser General Public License v3.0
504 stars 131 forks source link

Segmentation Fault in shark::NormalizeComponentsUnitInterval.h #285

Open busFred opened 3 years ago

busFred commented 3 years ago

Hello,

It seems that there is a data type error inside the train() method of NormalizeComponentsUnitInterval class that would cause segmentation fault. I used NormalizeComponentsUnitCovariance to normalize the dataset that I am using. The program executed without error. Therefore, I think my dataset is not the smoking gun here.

The attached is the gdb output for the NormalizeComponentsUnitInterval.train() method. It seems like the input.element(0) is not of RealVector type(?

shark::NormalizeComponentsUnitInterval<remora::vector<double, remora::cpu_tag> >::train (this=0x7fffffffd737, model=..., input=...)
    at /usr/local/include/shark/Algorithms/Trainers/NormalizeComponentsUnitInterval.h:84
84              void train(Normalizer<DataType>& model, UnlabeledData<DataType> const& input){
(gdb) s
85                      std:: size_t ic = input.numberOfElements();
(gdb) s
shark::Data<remora::vector<double, remora::cpu_tag> >::numberOfElements (this=0x0) at /usr/local/include/shark/Data/Dataset.h:211
211             std::size_t numberOfElements() const{
(gdb) s
212                     return m_data.numberOfElements();
(gdb) s
shark::detail::SharedContainer<remora::vector<double, remora::cpu_tag> >::numberOfElements (this=0x0) at /usr/local/include/shark/Data/Impl/Dataset.inl:239
239             std::size_t numberOfElements()const{
(gdb) s
240                     std::size_t numElems = 0;
(gdb) s
241                     for(std::size_t i = 0; i != m_data.size(); ++i){
(gdb) n
242                             numElems+=BatchTraits::size(*m_data[i]);
(gdb) n
241                     for(std::size_t i = 0; i != m_data.size(); ++i){
(gdb) n
244                     return numElems;
(gdb) n
245             }
(gdb) s
shark::Data<remora::vector<double, remora::cpu_tag> >::numberOfElements (this=0x7fffffffd8f8) at /usr/local/include/shark/Data/Dataset.h:213
213             }
(gdb) s
shark::NormalizeComponentsUnitInterval<remora::vector<double, remora::cpu_tag> >::train (this=0x7fffffffd840, model=..., input=...)
    at /usr/local/include/shark/Algorithms/Trainers/NormalizeComponentsUnitInterval.h:86
86                      SHARK_RUNTIME_CHECK(ic >= 2, "Input needs to consist of at least two points");
(gdb) n
87                      std::size_t dc = dataDimension(input);
(gdb) n
91                      RealVector min = input.element(0);
(gdb) n

Program received signal SIGSEGV, Segmentation fault.
0x0000555555615c04 in shark::detail::MatrixRowReference<remora::matrix<double, remora::row_major, remora::cpu_tag> const>::operator remora::vector<double, remora::cpu_tag> (
    this=<error reading variable: Cannot access memory at address 0x7fffff7fefe0>) at /usr/local/include/shark/Data/BatchInterface.h:151
151             operator Vector(){