# Segmentation fault occured when qSlicerMainWindow's destructor called

**URL:** <https://discourse.slicer.org/t/segmentation-fault-occured-when-qslicermainwindows-destructor-called/25136>\
**Category:** Development\
**Created:** [September 7, 2022, 6:33am UTC](https://discourse.slicer.org/t/segmentation-fault-occured-when-qslicermainwindows-destructor-called/25136 "2022-09-07T06:33:46Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![nnzzll](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/nnzzll/32/16350_2.png) [@nnzzll](https://discourse.slicer.org/u/nnzzll)\
**Post date:** [September 7, 2022, 6:33am UTC](https://discourse.slicer.org/t/segmentation-fault-occured-when-qslicermainwindows-destructor-called/25136/1 "2022-09-07T06:33:46Z")

</div>

I’m developing a custom application of Slicer.  
When the program exits, a Segmentation fault occured during calling the destructor of `qSlicerMainWindow`  
Here is the call traceback by gdb:

```auto
#0 0x00007fffedaa1f01 in std::__atomic_base<int>::load (
    __m=std::memory_order_relaxed, this=0x6f00740065006c)
    at /usr/include/c++/7/bits/atomic_base.h:396
#1 QAtomicOps<int>::load<int> (_q_value=...)
    at /opt/Qt5.12.3/5.12.3/gcc_64/include/QtCore/qatomic_cxx11.h:227
#2 0x00007fffedaa1021 in QBasicAtomicInteger<int>::load (
    this=0x6f00740065006c)
    at /opt/Qt5.12.3/5.12.3/gcc_64/include/QtCore/qbasicatomic.h:103
#3 0x00007fffeda9f569 in QtPrivate::RefCount::ref (this=0x6f00740065006c)
    at /opt/Qt5.12.3/5.12.3/gcc_64/include/QtCore/qrefcount.h:55
#4 0x00007fffedb03b15 in QList<ctkLayoutViewFactory*>::QList (
    this=0x7fffffffda40, l=...)
    at /opt/Qt5.12.3/5.12.3/gcc_64/include/QtCore/qlist.h:812
#5 0x00007fffedb02dd0 in ctkLayoutFactory::registeredViewFactories (
    this=0x555557b3e990)
    at /home/nzl/vela/build/CTK/Libs/Widgets/ctkLayoutFactory.cpp:99
#6 0x00007fffee752717 in qMRMLLayoutManager::mrmlViewFactories (
    this=0x555557b3e990)
    at /home/nzl/vela/build/slicersources-src/Libs/MRML/Widgets/qMRMLLayoutManager.cxx:779
#7 0x00007fffee75287d in qMRMLLayoutManager::mrmlViewFactory (
    this=0x555557b3e990, viewClassName=...)
    at /home/nzl/vela/build/slicersources-src/Libs/MRML/Widgets/qMRMLLayoutManag---Type <return> to continue, or q <return> to quit---
er.cxx:794
#8 0x00007fffee753150 in qMRMLLayoutManager::mrmlSliceLogics (
    this=0x555557b3e990)
    at /home/nzl/vela/build/slicersources-src/Libs/MRML/Widgets/qMRMLLayoutManager.cxx:928
#9 0x00007fffef7b94cc in qSlicerMainWindow::~qSlicerMainWindow (
    this=0x555556f76cb0, __in_chrg=<optimized out>)
    at /home/nzl/vela/build/slicersources-src/Base/QTApp/qSlicerMainWindow.cxx:774

```

I have no idea with these information, can anyone tell me what happened and how to solve it ?
