Closed Weiming-Hu closed 5 years ago
If I do not truncate the FLTs or if I have fewer than 4 FLTs, RAnEn::generateAnalogs
will finish without a problem. Otherwise, for example, when I have 4 FLTs in the forecasts, the function will return the error of stack overflow.
I noticed that if I open a new R session, and source the entire file once, it should complete. When the R session is still alive, I noticed that I have many undealt R sessions. In total there are 32 R session, exatly the number of cores I have. I suspect this has something to do with OpenMP. Although I'm not familiar of how OpenMP and Rcpp work together, the extra R sessions should be terminated when they are done.
If I source the R script again, the exact same script fails this time.
Looks like there is an invalid write happening somewhere in the code.
==17485== Thread 12:
==17485== Invalid write of size 8
==17485== at 0x1060694A: Functions::computeStandardDeviation(Forecasts_array const&, StandardDeviation&, std::vector<unsigned long, std::allocator<unsigned long> >) const [clone ._omp_fn.0] (Function
s.cpp:72)
==17485== by 0x75E997D: ??? (in /usr/lib/x86_64-linux-gnu/libgomp.so.1.0.0)
==17485== by 0x78096DA: start_thread (pthread_create.c:463)
==17485== by 0x558688E: clone (clone.S:95)
==17485== Address 0xb562240 is 0 bytes after a block of size 1,968 alloc'd
==17485== at 0x4C2FB0F: malloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==17485== by 0x4F80133: ??? (in /usr/lib/R/lib/libR.so)
==17485== by 0x4F80346: Rf_allocSExp (in /usr/lib/R/lib/libR.so)
==17485== by 0x4F176DC: ??? (in /usr/lib/R/lib/libR.so)
==17485== by 0x4F84289: Rf_installChar (in /usr/lib/R/lib/libR.so)
==17485== by 0x4FEEBDC: Rf_installTrChar (in /usr/lib/R/lib/libR.so)
==17485== by 0x4F2920F: ??? (in /usr/lib/R/lib/libR.so)
==17485== by 0x4F3EE4A: ??? (in /usr/lib/R/lib/libR.so)
==17485== by 0x4F4E1D7: Rf_eval (in /usr/lib/R/lib/libR.so)
==17485== by 0x4F5066D: ??? (in /usr/lib/R/lib/libR.so)
==17485== by 0x4F4569D: ??? (in /usr/lib/R/lib/libR.so)
==17485== by 0x4F4E1D7: Rf_eval (in /usr/lib/R/lib/libR.so)
==17485==
Bug resolved. This is caused when you are only using part of the times in search times to create analogs. A memory overflow is caused by wrong indexing. This is fixed.
I have the following script.
I get the following results when I'm running it over NAM data. The place that generates this error message is not consistent.