Crash with TF1::GetRandom

Here is the code I am running, with the crash & stack trace:

*  ROOT v6.03/01  *

root [0] TF1 f("landau","landau",0,10)
(TF1 &) @0x109951030
root [1] f.SetParameters(1,1,1)
root [2] f.GetRandom(0,1e7)
(Double_t) 9.986638e+00
root [3] f.GetRandom(0,1e8)
(Double_t) 7.222248e-01
root [4] f.GetRandom(0,1e9)

 *** Break *** segmentation violation
 Generating stack trace...
 0x0000000100457ceb in (anonymous namespace)::TerminalConfigUnix__handleSignal(int) (in (TerminalConfigUnix.cpp:37)
 0x00007fff8ba365aa in _sigtramp (in libsystem_platform.dylib) + 26
 0x0000000000002800 in <unknown function>
 0x00000001034ef28e in <unknown function>
 0x0000000100d5bc02 in cling::IncrementalExecutor::executeFunction(llvm::StringRef, cling::Value*) (in (IncrementalExecutor.cpp:274)
 0x0000000100d7e703 in cling::Interpreter::RunFunction(clang::FunctionDecl const*, cling::Value*) (in (Interpreter.cpp:756)
 0x0000000100d7cc66 in cling::Interpreter::EvaluateInternal(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, cling::CompilationOptions const&, cling::Value*, cling::Transaction**
 0x0000000100d7b78a in cling::Interpreter::process(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, cling::Value*, cling::Transaction**) (in (Interpreter.cpp:504)
 0x0000000100e25a37 in cling::MetaProcessor::process(char const*, cling::Interpreter::CompilationResult&, cling::Value*) (in (MetaProcessor.cpp:162)
 0x00000001009b999f in TCling::ProcessLine(char const*, TInterpreter::EErrorCode*) (in (TCling.cxx:1870)
 0x000000010022816c in TApplication::ProcessLine(char const*, bool, int*) (in (TApplication.cxx:982)
 0x0000000100852f0d in TRint::ProcessLineNr(char const*, char const*, int*) (in (TRint.cxx:727)
 0x0000000100854f75 in TRint::HandleTermInput() (in (TRint.cxx:599)
 0x00000001008508ca in TTermInputHandler::Notify() (in (TRint.cxx:124)
 0x0000000100856709 in TTermInputHandler::ReadNotify() (in (TRint.cxx:116)
 0x00000001003a61be in TUnixSystem::CheckDescriptors() (in (TUnixSystem.cxx:1297)
 0x00000001003b6dac in TMacOSXSystem::DispatchOneEvent(bool) (in (
 0x00000001002be6a3 in TSystem::InnerLoop() (in (TSystem.cxx:410)
 0x00000001002be4d3 in TSystem::Run() (in (TSystem.cxx:359)
 0x0000000100229e04 in TApplication::Run(bool) (in (TApplication.cxx:1131)
 0x0000000100852dbd in TRint::Run(bool) (in (TRint.cxx:453)
 0x0000000100111b07 in main (in root.exe) (rmain.cxx:31)
 0x00007fff8f3ea5fd in start (in libdyld.dylib) + 1

This also occurs with other functions (like “gaus”). Always between 1e8 and 1e9 for the upper argument.

When searching for a previous post on ROOTTalk I learned that TF1::GetRandom actually randomly selects a point among the Npx points, instead of actually re-evaluating the function at a random point in the given range. So I agree it wouldn’t make sense to GetRandom this way outside of the set function range, but it shouldn’t crash like this, I think.


TF1 f(“landau”, “landau”, 0, 1e10); // you explicitly define “xmin” and “xmax” for this function here