*** Break *** segmentation violation error in a script

Hello! I am running a script of mine, which runs fine and gives expected output in my ubuntu 20.04 (root 6.22) and even Ubuntu 22.04 (installed in a virtual machine on Mac with root 6.24) systems but when I run the same script in MacOS (root 6.30), it runs well at root[0] prompt but gives me the following huge error upon making a function call (defined within the script) in the root[1] command prompt. What can this error be arising from and how can I solve this. Grateful for any help, thank you!


*** Break *** segmentation violation

[/usr/lib/system/libsystem_platform.dylib] _sigtramp (no debug info)

[] (no debug info)

[] (no debug info)

[] (no debug info)

[/opt/homebrew/Cellar/root/6.30.02/lib/root/libCling.so] cling::IncrementalExecutor::executeWrapper(llvm::StringRef, cling::Value*) const (no debug info)

[/opt/homebrew/Cellar/root/6.30.02/lib/root/libCling.so] cling::Interpreter::RunFunction(clang::FunctionDecl const*, cling::Value*) (no debug info)

[/opt/homebrew/Cellar/root/6.30.02/lib/root/libCling.so] cling::Interpreter::EvaluateInternal(std::__1::basic_string<char, std::__1::char_traits, std::__1::allocator> const&, cling::CompilationOptions, cling::Value*, cling::Transaction**, unsigned long) (no debug info)

[/opt/homebrew/Cellar/root/6.30.02/lib/root/libCling.so] cling::Interpreter::process(std::__1::basic_string<char, std::__1::char_traits, std::__1::allocator> const&, cling::Value*, cling::Transaction**, bool) (no debug info)

[/opt/homebrew/Cellar/root/6.30.02/lib/root/libCling.so] cling::MetaProcessor::process(llvm::StringRef, cling::Interpreter::CompilationResult&, cling::Value*, bool) (no debug info)

[/opt/homebrew/Cellar/root/6.30.02/lib/root/libCling.so] HandleInterpreterException(cling::MetaProcessor*, char const*, cling::Interpreter::CompilationResult&, cling::Value*) (no debug info)

[/opt/homebrew/Cellar/root/6.30.02/lib/root/libCling.so] TCling::ProcessLine(char const*, TInterpreter::EErrorCode*) (no debug info)

[/opt/homebrew/Cellar/root/6.30.02/lib/root/libRint.so] TRint::ProcessLineNr(char const*, char const*, int*) (no debug info)

[/opt/homebrew/Cellar/root/6.30.02/lib/root/libRint.so] TRint::HandleTermInput() (no debug info)

[/opt/homebrew/Cellar/root/6.30.02/lib/root/libCore.so] TUnixSystem::CheckDescriptors() (no debug info)

[/opt/homebrew/Cellar/root/6.30.02/lib/root/libCore.so] TMacOSXSystem::DispatchOneEvent(bool) (no debug info)

[/opt/homebrew/Cellar/root/6.30.02/lib/root/libCore.so] TSystem::InnerLoop() (no debug info)

[/opt/homebrew/Cellar/root/6.30.02/lib/root/libCore.so] TSystem::Run() (no debug info)

[/opt/homebrew/Cellar/root/6.30.02/lib/root/libCore.so] TApplication::Run(bool) (no debug info)

[/opt/homebrew/Cellar/root/6.30.02/lib/root/libRint.so] TRint::Run(bool) (no debug info)

[/opt/homebrew/Cellar/root/6.30.02/bin/root.exe] main (no debug info)

[/usr/lib/dyld] start (no debug info)


I am sorry you experienced this issue.
The information provided is not enough to point to a ROOT related issue.
Could you share a minimal reproducer for the crash?


Thank you for your response! My script has this function F() that does so when I make a call to it in the root[1] command prompt. In the root[0] prompt, I execute the script in which I load a data file, open a branch in a histogram, declare that histogram in a global variable and then access it within F() and hence IdentifyPeaks().

code_snippet.cpp (2.2 KB)

Thank you for your time.

Hi Prabhat,

Can you also share the input and a copy paste invocation so that we can reproduce?

Thanks a lot,

Hello Danilo,
Apologies for the late reply. I was trying to break down and give only required part of the script but the whole script is entangled and it seems I should just upload the whole script.

Prabhat_Script_mod9.cpp (17.2 KB)

  1. Please download the data file and keep it in the same folder as the script.
  2. Run the script as usual with root Prabhat_Script_mod9.cpp
  3. On the prompt it will ask for adding files, copy paste the name of the file in the terminal.
  4. It will ask to view list all branches individually, input “y”.
  5. input “v”, then “s” then “22 02”.
  6. access the histogram that opened by dragging the x-axis
  7. in the terminal type “F();”. this calls the function F(), now this is the step that goes well in the ubuntu system like I mentioned earlier but not in Mac.
    Please let me know if something else is needed.

Thank you,

Hi Prabhat,

Thanks. Could you please simplify the script? The reproducing procedure seems very laborious and error prone.


Hello sir,

I have made a few changes and made it non-optional to make the choices within the script. Here’s the revised version of the code. Please run the script from within the same folder as the data file I attached earlier.

code_snippet.cpp (15.3 KB)

After running, my problem, as I had mentioned before, is that when I make a call to the function F(); in the root prompt (which I need for calibration purposes after the spectrum opens up), it runs well in the ubuntu systems but not in my Mac.

Thank you!


Hello @Danilo sir, I was wishing to enquire if you found the solution or the potential problem. Thanks for your help!

Yours sincerely


I cannot figure out what is happening. I notice that for me (on mac) the macro crashes because of this line

TObjArray *branches = t->GetListOfBranches();

This is expected since I do not have any input file to test the macro.


(The input file is in the dropbox link above.)

It works for me on Ubuntu without crash.

@psharma can you run it compiled instead of interpreted? And repost the stack trace then.


you are right. I compiled and debugged on mac.
The line that crashes is the following:

Int_t numP = H->ShowPeaks(ProjSpecSigma, "", ProjSpecResol);

H seems to be corrupt. Some debugging is needed at this point on the user side I fear. I believe it works on linux by chance.


Maybe you could try with:

Int_t numP = gCurrentHistogram ? TSpectrum::StaticSearch(gCurrentHistogram, ProjSpecSigma, "", ProjSpecResol) : 0;

Linux here, working too.
From the canvas displayed by ShowSpectra, we see that h has a huge peak at x=0 (and the first “data” start around 120+), which may be meaningless or not useful in this case and might be causing trouble with ShowPeaks(?); maybe try

  t -> Draw((branchName+">>h(8192,1,8191)").c_str());

instead of starting from 0, and see if that works better.

Hello to all of you!
I tried all your suggestions, but still I can not seem to make it work. I tried taking the range from 101 to 8191. I tried the line: Int_t numP = gCurrentHistogram ? TSpectrum::StaticSearch(gCurrentHistogram, ProjSpecSigma, “”, ProjSpecResol) : 0;
Based on some further inspection, I also can partly confirm that this is the line that is creating problem, probably because of some pointer to string to object conversion. But I am a bit too naive to solve this problem on my own :sweat_smile:. I would appreciate if someone can hint me into solving this problem.

Thank you!

What happens if you replace ProjSpecSigma and ProjSpecResol with a fixed hard-coded value?

Hello all!

Thank you for the help and suggestions.

I did figure it out finally, the problem is line 372. I did define a histogram and then ran the command:
t → Draw((branchName+“>>h(8192,0,8191)”).c_str());
thus, “redefining h”, however as it turns out, this command does not actually save the branch and draw it in the form of a histogram, rather it creates a temporary histogram “h”.

Now I would however, like to continue seeking a solution to the ultimate problem, i.e., returning a histogram “h” to the gCurrentHistogram in view(). (In simpler words, the problem is to get a branch and directly save it as a histogram with defined bins.)

If anyone can suggest me a way to do that other than the following (which takes about 30 seconds on my mac), I’d appreciate that.

Double_t histogramValues;
t → SetBranchAddress(branchName.c_str(), &histogramValues);
Long64_t nEntries = t->GetEntries();
for (Long64_t i = 0; i < nEntries; ++i) {
t ->GetEntry(i);
// Fill the TH1F histogram with the histogram values
h ->Fill(histogramValues);
h → Draw();

Thank you

To continue to append data to an existing histogram, use "+" in front of the histogram name.

See ROOT: TTree Class Reference

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.