# Segmentation violation - Garfield example

**URL:** <https://root-forum.cern.ch/t/segmentation-violation-garfield-example/22035>\
**Category:** Garfield++\
**Created:** [October 13, 2016, 2:03pm UTC](https://root-forum.cern.ch/t/segmentation-violation-garfield-example/22035 "2016-10-13T14:03:29Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![Mounia\_LAASSIRI](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/m/258eb7/32.png) [@Mounia\_LAASSIRI](https://root-forum.cern.ch/u/Mounia_LAASSIRI)\
**Post date:** [October 13, 2016, 2:03pm UTC](https://root-forum.cern.ch/t/segmentation-violation-garfield-example/22035/1 "2016-10-13T14:03:29Z")

</div>

Dear all ;  
I was wondering if I could get some help in finding out why the errors below are occuring.  
I am trying to execute this example « [garfieldpp.web.cern.ch/garfieldp … nergypion/](http://garfieldpp.web.cern.ch/garfieldpp/examples/mmlowenergypion/) » But it gives me this error.  
Could really use some advice for this problem. Thanks.  
Mounia

```auto
***Break*** segmentation violation

===========================================================
There was a crash.
This is the entire stack trace of all threads:
===========================================================
#0 0x00007fd76b895a0c in __libc_waitpid (pid=15087, stat_loc=stat_loc
entry=0x7ffdf8e47b00, options=options
entry=0) at ../sysdeps/unix/sysv/linux/waitpid.c:31
#1 0x00007fd76b81b232 in do_system (line=<optimized out>) at ../sysdeps/posix/system.c:148
#2 0x00007fd76db39703 in TUnixSystem::StackTrace() () from /home/mounia/Documents/root/lib/libCore.so
#3 0x00007fd76db3b40c in TUnixSystem::DispatchSignals(ESignals) () from /home/mounia/Documents/root/lib/libCore.so
#4 <signal handler called>
#5 0x00007fd76cb9f684 in TPad::WaitPrimitive(char const*, char const*) () from /home/mounia/Documents/root/lib/libGpad.so
#6 0x00000000004e7a4e in Garfield::ViewDrift::Plot3d(bool) ()
#7 0x000000000044bbf3 in main ()
===========================================================

The lines below might hint at the cause of the crash.
If they do not help you then please submit a bug report at
[root.cern.ch/bugs](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 0x00007fd76cb9f684 in TPad::WaitPrimitive(char const*, char const*) () from /home/mounia/Documents/root/lib/libGpad.so
#6 0x00000000004e7a4e in Garfield::ViewDrift::Plot3d(bool) ()
#7 0x000000000044bbf3 in main ()
===========================================================

```

---

<div class="post-metadata">

**Author:** ![Danilo](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/danilo/32/34528_2.png) [@Danilo](https://root-forum.cern.ch/u/Danilo)\
**Post date:** [October 16, 2016, 7:54pm UTC](https://root-forum.cern.ch/t/segmentation-violation-garfield-example/22035/2 "2016-10-16T19:54:19Z")

</div>

Hi,

the stack does not say much. Did you try to find help on Garfield resources?

Danilo

---

<div class="post-metadata">

**Author:** ![Mounia\_LAASSIRI](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/m/258eb7/32.png) [@Mounia\_LAASSIRI](https://root-forum.cern.ch/u/Mounia_LAASSIRI)\
**Post date:** [October 17, 2016, 10:33am UTC](https://root-forum.cern.ch/t/segmentation-violation-garfield-example/22035/3 "2016-10-17T10:33:54Z")

</div>

Thank Danilo for your reply;  
I have tried my best to understand the problem. But reading through the internet did not help.  
I receive the following errors when I try to plot the electric field inside a drift chamber.

---

<div class="post-metadata">

**Author:** ![couet](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/couet/32/12037_2.png) [@couet](https://root-forum.cern.ch/u/couet)\
**Post date:** [October 17, 2016, 11:43am UTC](https://root-forum.cern.ch/t/segmentation-violation-garfield-example/22035/4 "2016-10-17T11:43:30Z")

</div>

The only element of this trace back sounding familiar to me is “TPad::WaitPrimitive”…  
It seems your script does some specific graphics interaction.  
Can you post here the example macro you are running ? (if not to big)

---

<div class="post-metadata">

**Author:** ![Mounia\_LAASSIRI](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/m/258eb7/32.png) [@Mounia\_LAASSIRI](https://root-forum.cern.ch/u/Mounia_LAASSIRI)\
**Post date:** [October 17, 2016, 2:22pm UTC](https://root-forum.cern.ch/t/segmentation-violation-garfield-example/22035/5 "2016-10-17T14:22:03Z")

</div>

I thought that this is what one includes in the makefile. My makefile is the following

```auto
CXX = g++
OBJDIR = $(GARFIELD_HOME)/Object
SRCDIR = $(GARFIELD_HOME)/Source
INCDIR = $(GARFIELD_HOME)/Include
HEEDDIR = $(GARFIELD_HOME)/Heed
LIBDIR = $(GARFIELD_HOME)/Library

# Compiler flags
CFLAGS = `root-config --cflags` -I$(INCDIR) -I$(HEEDDIR) -c

# Debug flags
# CFLAGS += -g

LDFLAGS = -L$(LIBDIR) -lGarfield 
LDFLAGS += -L/usr/local/lib -lgfortran
LDFLAGS += `root-config --glibs` -lGeom

TARGET = main_example

all: $(TARGET).cpp 
	$(CXX) $(CFLAGS) $(TARGET).cpp
	$(CXX) $(TARGET).o $(LDFLAGS) -o $(TARGET)

```

A working version of the code (tested with Garfield++ SVN revision 304) can be downloaded along with the Magboltz gas file and an example makefile ([garfieldpp.web.cern.ch/garfieldp … nergypion/](http://garfieldpp.web.cern.ch/garfieldpp/examples/mmlowenergypion/)).

Thanks for your help,

---

<div class="post-metadata">

**Author:** ![couet](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/couet/32/12037_2.png) [@couet](https://root-forum.cern.ch/u/couet)\
**Post date:** [October 17, 2016, 3:01pm UTC](https://root-forum.cern.ch/t/segmentation-violation-garfield-example/22035/6 "2016-10-17T15:01:23Z")

</div>

Thanks.  
As it seems to be a garfield problem.  
Have you tried the Garfield support ? here: [garfieldpp.web.cern.ch/garfieldpp/support/](http://garfieldpp.web.cern.ch/garfieldpp/support/)

---

<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-garfield-example/22035/7 "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.
