# Segmentation Violation using Garfield++

**URL:** <https://root-forum.cern.ch/t/segmentation-violation-using-garfield/19832>\
**Category:** Garfield++\
**Created:** [September 13, 2015, 2:14pm UTC](https://root-forum.cern.ch/t/segmentation-violation-using-garfield/19832 "2015-09-13T14:14:41Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![elia](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/e/278dde/32.png) [@elia](https://root-forum.cern.ch/u/elia)\
**Post date:** [September 13, 2015, 2:14pm UTC](https://root-forum.cern.ch/t/segmentation-violation-using-garfield/19832/1 "2015-09-13T14:14:41Z")

</div>

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:

```auto
***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:

```auto
#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:](https://root-forum.cern.ch/uploads/default/original/2X/2/2799b3ea86c419a02327c767288415b2a17e6ee1.gif "Mr. Green")

---

<div class="post-metadata">

**Author:** ![geniejhang](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/g/ee7513/32.png) [@geniejhang](https://root-forum.cern.ch/u/geniejhang)\
**Post date:** [September 14, 2015, 2:35am UTC](https://root-forum.cern.ch/t/segmentation-violation-using-garfield/19832/2 "2015-09-14T02:35:19Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![elia](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/e/278dde/32.png) [@elia](https://root-forum.cern.ch/u/elia)\
**Post date:** [September 18, 2015, 9:06am UTC](https://root-forum.cern.ch/t/segmentation-violation-using-garfield/19832/3 "2015-09-18T09:06:53Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![shenfw](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/s/47e85d/32.png) [@shenfw](https://root-forum.cern.ch/u/shenfw)\
**Post date:** [November 29, 2017, 7:32am UTC](https://root-forum.cern.ch/t/segmentation-violation-using-garfield/19832/4 "2017-11-29T07:32:47Z")

</div>

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);
```

---

<div class="post-metadata">

**Author:** ![system](https://root-forum.cern.ch/uploads/default/original/3X/e/f/efe4f24398fd8ffeb76bccb6ecc46d9d9c003376.png) [@system](https://root-forum.cern.ch/u/system)\
**Post date:** [June 21, 2018, 11:40am UTC](https://root-forum.cern.ch/t/segmentation-violation-using-garfield/19832/5 "2018-06-21T11:40:59Z")

</div>

Closed on June 21, 2018, 11:40am UTC

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