Segmentation Violation using Garfield++

Hello evereyone, I’m trying to run the following code, but even if I don’t receive any error in compilation, when I run the program I got this error:

*** Break *** segmentation violation



===========================================================
There was a crash.
This is the entire stack trace of all threads:
===========================================================
    from libstdcxx.v6.printers import register_libstdcxx_printers
#0  0x00007f5c50803b4c in __libc_waitpid (pid=4826, stat_loc=stat_loc
entry=0x7fff9a726840, options=options
entry=0) at ../sysdeps/unix/sysv/linux/waitpid.c:31
#1  0x00007f5c507892e2 in do_system (line=<optimised out>) at ../sysdeps/posix/system.c:148
#2  0x00007f5c5286f3a3 in TUnixSystem::StackTrace() () from /usr/lib/x86_64-linux-gnu/libCore.so.5.34
#3  0x00007f5c5287107c in TUnixSystem::DispatchSignals(ESignals) () from /usr/lib/x86_64-linux-gnu/libCore.so.5.34
#4  <signal handler called>
#5  0x000000003416ad10 in ?? ()
#6  0x0000000000589d43 in Garfield::PlottingEngineRoot::~PlottingEngineRoot() ()
#7  0x00007f5c5077f259 in __run_exit_handlers (status=0, listp=0x7f5c50b016c8 <__exit_funcs>, run_list_atexit=run_list_atexit
entry=true) at exit.c:82
#8  0x00007f5c5077f2a5 in __GI_exit (status=<optimised out>) at exit.c:104
#9  0x00007f5c50764ecc in __libc_start_main (main=0x412ad0 <main>, argc=1, argv=0x7fff9a728f38, init=<optimised out>, fini=<optimised out>, rtld_fini=<optimised out>, stack_end=0x7fff9a728f28) at libc-start.c:321
#10 0x000000000041337a in _start ()
===========================================================


The lines below might hint at the cause of the crash.
If they do not help you then please submit a bug report at
http://root.cern.ch/bugs. Please post the ENTIRE stack trace
from above as an attachment in addition to anything else
that might help us fixing this issue.
===========================================================
#5  0x000000003416ad10 in ?? ()
#6  0x0000000000589d43 in Garfield::PlottingEngineRoot::~PlottingEngineRoot() ()
#7  0x00007f5c5077f259 in __run_exit_handlers (status=0, listp=0x7f5c50b016c8 <__exit_funcs>, run_list_atexit=run_list_atexit
entry=true) at exit.c:82
#8  0x00007f5c5077f2a5 in __GI_exit (status=<optimised out>) at exit.c:104
#9  0x00007f5c50764ecc in __libc_start_main (main=0x412ad0 <main>, argc=1, argv=0x7fff9a728f38, init=<optimised out>, fini=<optimised out>, rtld_fini=<optimised out>, stack_end=0x7fff9a728f28) at libc-start.c:321
#10 0x000000000041337a in _start ()
===========================================================

The program that I’m running is:

#include <iostream>

#include <TCanvas.h>
#include <TROOT.h>
#include <TApplication.h>

#include "MediumMagboltz.hh"
#include "FundamentalConstants.hh"
#include "GeometrySimple.hh"
#include "SolidTube.hh"
#include "ComponentAnalyticField.hh"
#include "ViewCell.hh"
#include "ViewField.hh"
#include "ViewGeometry.hh"
#include "Solid.hh"
#include "Plotting.hh"
#include "GarfieldConstants.hh"
#include "PlottingEngineRoot.hh"
#include "ViewMedium.hh"


using namespace Garfield;

int main() {
  MediumMagboltz* gas = new MediumMagboltz();
  gas->SetTemperature(300.);
   gas->SetPressure(1*760.);
   gas->LoadGasFile("4he_80_ic4h10_20.gas");
   GeometrySimple* geo = new GeometrySimple();
   double rMin = 0.00125, rMax = 2., halfLenght = 25.;
   SolidTube* tube = new SolidTube(0.,0.,0., rMin, rMax, halfLenght); 
   geo->AddSolid(tube, gas);
   ComponentAnalyticField* cmp = new ComponentAnalyticField();
   cmp->SetGeometry(geo);
   cmp->AddWire(0.0, 0.0, 0.0020, 1860.0, "s");
   cmp->AddWire(1.125, 0.75, 0.0020, 1860.0, "s");
   cmp->AddWire(-0.75, 0.0, 0.0120, 0, "f");
   cmp->AddWire(-0.325, -0.75,  0.0120, 0, "f");
   cmp->AddWire(0.325, -0.75, 0.0120, 0, "f");
   cmp->AddWire(0.75, 0.0, 0.0120, 0, "f");
   cmp->SetPeriodicityX(2.25);
   cmp->SetPeriodicityY(1.5);
   ViewCell* view_cmp = new ViewCell();
   view_cmp->SetComponent(cmp);
   view_cmp->Plot2d();
   }

The error that I got is related to the PlottingEngineRoot, that is a ROOT library. Anyone can help me? Thank you. :mrgreen:

Hi.

I had the same problem but the problem seems to be on Garfield++ side.
Because on ROOT 5.23 Garfield++ works fine

If you have a time, please try.

Thank you for the answer. I’m actually using root 5.34/14, did you have the same problem with this root version?

You should add the code below to your own code:

    TApplication app("app", &argc, argv);
    plottingEngine.SetDefaultStyle();
   
     ------the main body of your code 
  
    app.Run(kTRUE);

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