TRobustEstimator fails for certain number of observations

Dear ROOT experts,

I have been using the TRobustEstimator to compute covariance matrices.
There’s a strange behaviour when using different number of observations.
It seems for a number of observations less or equal than 500, the class works.
Then, for number of observations greater than 500 and less than 4000 it fails with the message below.
From around 4000 on, it works again!
I could not find the reason for that.

I have put a simple script-example attached.

Many thanks in advance.
Cheers, Bernardo.

Error in <TMatrixTRow_const(const TMatrixT &,Int_t)>: row index out of bounds

*** Break *** segmentation violation

===========================================================
There was a crash (#7 0x0038fb0d in SigHandler(ESignals) () from /home/bernardo/root/lib/libCore.so).
This is the entire stack trace of all threads:

#0 0x00ada424 in __kernel_vsyscall ()
#1 0x00ccb273 in __waitpid_nocancel () from /lib/libc.so.6
#2 0x00c64c53 in do_system () from /lib/libc.so.6
#3 0x00c1d95d in system () from /lib/libpthread.so.0
#4 0x0038a61d in TUnixSystem::Exec(char const*) () from /home/bernardo/root/lib/libCore.so
#5 0x00390d6d in TUnixSystem::StackTrace() () from /home/bernardo/root/lib/libCore.so
#6 0x0038f9ff in TUnixSystem::DispatchSignals(ESignals) () from /home/bernardo/root/lib/libCore.so
#7 0x0038fb0d in SigHandler(ESignals) () from /home/bernardo/root/lib/libCore.so
#8 0x00386b82 in sighandler(int) () from /home/bernardo/root/lib/libCore.so
#9 0x003b57dd in textinput::TerminalConfigUnix::HandleSignal(int) () from /home/bernardo/root/lib/libCore.so
#10 0x003b5a46 in (anonymous namespace)::TerminalConfigUnix__handleSignal(int) () from /home/bernardo/root/lib/libCore.so
#11
#12 0x00b02384 in TRobustEstimator::Evaluate() () from /home/bernardo/root/lib/libPhysics.so
#13 0x009bccb2 in testTRE() () from /home/bernardo/Downloads/./testTRE_C.so
#14 0x009bcd47 in G__testTRE_C_ACLiC_dict__0_1482(G__value*, char const*, G__param*, int) () from /home/bernardo/Downloads/./testTRE_C.so
#15 0x00dfd777 in Cint::G__ExceptionWrapper(int ()(G__value, char const*, G__param*, int), G__value*, char*, G__param*, int) () from /home/bernardo/root/lib/libCint.so
#16 0x00eac3df in G__execute_call () from /home/bernardo/root/lib/libCint.so
#17 0x00ead29a in G__call_cppfunc () from /home/bernardo/root/lib/libCint.so
#18 0x00e89ad8 in G__interpret_func () from /home/bernardo/root/lib/libCint.so
#19 0x00e73ba8 in G__getfunction () from /home/bernardo/root/lib/libCint.so
#20 0x00e4e616 in G__getitem () from /home/bernardo/root/lib/libCint.so
#21 0x00e53b04 in G__getexpr () from /home/bernardo/root/lib/libCint.so
#22 0x00e5d7e8 in G__calc_internal () from /home/bernardo/root/lib/libCint.so
#23 0x00eeb2cb in G__process_cmd () from /home/bernardo/root/lib/libCint.so
#24 0x003508cb in TCint::ProcessLine(char const*, TInterpreter::EErrorCode*) () from /home/bernardo/root/lib/libCore.so
#25 0x0034eb01 in TCint::ProcessLineSynch(char const*, TInterpreter::EErrorCode*) () from /home/bernardo/root/lib/libCore.so
#26 0x002aa880 in TApplication::ExecuteFile(char const*, int*, bool) () from /home/bernardo/root/lib/libCore.so
#27 0x002aac6c in TApplication::ProcessFile(char const*, int*, bool) () from /home/bernardo/root/lib/libCore.so
#28 0x002a8bc0 in TApplication::ProcessLine(char const*, bool, int*) () from /home/bernardo/root/lib/libCore.so
#29 0x00936e82 in TRint::HandleTermInput() () from /home/bernardo/root/lib/libRint.so
#30 0x00936875 in TTermInputHandler::Notify() () from /home/bernardo/root/lib/libRint.so
#31 0x00938e04 in TTermInputHandler::ReadNotify() () from /home/bernardo/root/lib/libRint.so
#32 0x0038de77 in TUnixSystem::CheckDescriptors() () from /home/bernardo/root/lib/libCore.so
#33 0x0038e1c8 in TUnixSystem::DispatchOneEvent(bool) () from /home/bernardo/root/lib/libCore.so
#34 0x00308124 in TSystem::InnerLoop() () from /home/bernardo/root/lib/libCore.so
#35 0x0030a679 in TSystem::Run() () from /home/bernardo/root/lib/libCore.so
#36 0x002a6427 in TApplication::Run(bool) () from /home/bernardo/root/lib/libCore.so
#37 0x00938688 in TRint::Run(bool) () from /home/bernardo/root/lib/libRint.so
#38 0x08048d5f in main ()

testTRE.C (679 Bytes)

Thank you for reporting this problem.
There is a bug in the code, and it will be fixed now both in ROOT 6 and 5.34 patches.
Best Regards

Lorenzo