# Crash closing application with macos

**URL:** <https://root-forum.cern.ch/t/crash-closing-application-with-macos/37551>\
**Category:** ROOT\
**Created:** [January 13, 2020, 4:19pm UTC](https://root-forum.cern.ch/t/crash-closing-application-with-macos/37551 "2020-01-13T16:19:04Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![dudouet](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/dudouet/32/37750_2.png) [@dudouet](https://root-forum.cern.ch/u/dudouet)\
**Post date:** [January 13, 2020, 4:19pm UTC](https://root-forum.cern.ch/t/crash-closing-application-with-macos/37551/1 "2020-01-13T16:19:04Z")

</div>

Dear all,

I am developing a program based on a TApplication. I just switched to macos, and I get a crash when closing the main window. Actually, if I open only the main window, I can close it without error, but if I open the main window, then click on a button to open a second window, then close this second window and finally close the main window, ROOT crash with this error message:

```auto
2020-01-13 17:11:30.581285+0100 Cubix[63028:750117] Fatal error: requested non-existing drawable 1169

2020-01-13 17:11:30.581368+0100 Cubix[63028:750117] This window not found among allocated/deleted drawables

```

Using a debugger, I found that this is coming from the line:

`NSView<X11Window> * const view = fPimpl->GetWindow(wid).fContentView;`

in the file TGCocoa.mm

Any idea ?

-ROOT Version:\_ 6-18-04  
_Platform:_ macos  
_Compiler:_ Not Provided

* * *

---

<div class="post-metadata">

**Author:** ![dudouet](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/dudouet/32/37750_2.png) [@dudouet](https://root-forum.cern.ch/u/dudouet)\
**Post date:** [January 14, 2020, 3:20pm UTC](https://root-forum.cern.ch/t/crash-closing-application-with-macos/37551/2 "2020-01-14T15:20:36Z")

</div>

From what I found on the web, it seems to be related to cocoa. I tried to install root using the option -Dx11=ON -Dcocoa=OFF, but I have the following error, that I did not succeed to correct:

```auto
In file included from /Users/dudouet/Softs/ROOT/root/graf3d/glew/src/glew.c:49:
include/GL/glxew.h:94:10: fatal error: 'X11/Xlib.h' file not found
#include <X11/Xlib.h>

```

---

<div class="post-metadata">

**Author:** ![dudouet](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/dudouet/32/37750_2.png) [@dudouet](https://root-forum.cern.ch/u/dudouet)\
**Post date:** [January 14, 2020, 3:37pm UTC](https://root-forum.cern.ch/t/crash-closing-application-with-macos/37551/3 "2020-01-14T15:37:16Z")

</div>

After copying /opt/X11/include/X11/\* include/X11/ of my build directory, the Xlib.h error is solved, but I now have the following error:

```auto
[140/2089] Linking C shared library lib/libGLEW.so
FAILED: lib/libGLEW.so 
: && /Library/Developer/CommandLineTools/usr/bin/cc -m64 -pipe -W -Wall -fsigned-char -fno-common -Qunused-arguments -pthread -O2 -g -DNDEBUG -isysroot /Library/Developer/CommandLineTools/SDKs/MacOSX10.15.sdk -dynamiclib -Wl,-headerpad_max_install_names -m64 -single_module -Wl,-dead_strip_dylibs -o lib/libGLEW.so -install_name @rpath/libGLEW.so graf3d/glew/CMakeFiles/GLEW.dir/src/glew.c.o /Library/Developer/CommandLineTools/SDKs/MacOSX10.15.sdk/System/Library/Frameworks/OpenGL.framework/OpenGL.tbd /Library/Developer/CommandLineTools/SDKs/MacOSX10.15.sdk/System/Library/Frameworks/OpenGL.framework/OpenGL.tbd /Library/Developer/CommandLineTools/SDKs/MacOSX10.15.sdk/System/Library/Frameworks/OpenGL.framework/OpenGL.tbd && :
Undefined symbols for architecture x86_64:
  "_glXGetClientString", referenced from:
      _glxewGetExtension in glew.c.o
  "_glXQueryVersion", referenced from:
      _glxewContextInit in glew.c.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)

```

---

<div class="post-metadata">

**Author:** ![Axel](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/axel/32/11084_2.png) [@Axel](https://root-forum.cern.ch/u/Axel)\
**Post date:** [January 20, 2020, 8:26am UTC](https://root-forum.cern.ch/t/crash-closing-application-with-macos/37551/4 "2020-01-20T08:26:36Z")

</div>

Let’s stay with Cocoa for the time being. We will need a reproducer to fix this - can you provide us with one?

---

<div class="post-metadata">

**Author:** ![dudouet](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/dudouet/32/37750_2.png) [@dudouet](https://root-forum.cern.ch/u/dudouet)\
**Post date:** [January 20, 2020, 2:57pm UTC](https://root-forum.cern.ch/t/crash-closing-application-with-macos/37551/5 "2020-01-20T14:57:32Z")

</div>

Hi,

So, by trying to create a piece of code that could reproduce the problem, I found a solution. The second window that I am opening contains an object of class CXCanvas, inherited from TCanvas. To use it I was doing:

```auto
    fRootCanvas = new TRootEmbeddedCanvas("NCCanvas", Main);
    Main->AddFrame(fRootCanvas, new TGLayoutHints(kLHintsExpandX | kLHintsExpandY, 0, 0, 5, 5));
    Int_t canvasid = fRootCanvas->GetCanvasWindowId();
    fCanvas = new CXCanvas("NuclearChartCanvas", 10, 10,canvasid);
    fCanvas->SetMainWindow(fMainWindow);
    fRootCanvas->AdoptCanvas(fCanvas);

```

This is actually the part that made all crashed. To avoid the crash when exiting ROOT, I had to add:

`delete fRootCanvas->GetCanvas();`

before: `Int_t canvasid = fRootCanvas->GetCanvasWindowId();`

But I never had this error before, on linux computers.

Cheers

J.

---

<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:** [February 3, 2020, 2:57pm UTC](https://root-forum.cern.ch/t/crash-closing-application-with-macos/37551/6 "2020-02-03T14:57:34Z")

</div>

Closed on February 3, 2020, 2:57pm UTC

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