Symbol library editor crashes Kicad when editing graphically (lp:#1822186)

[Original report](https://bugs.launchpad.net/bugs/1822186) created by **Barnabas (bmogan)**
```
Below are two instances of Kicad crashing when creating or editing a symbol
with or without running eeschema. I tried multiple times and pretty much
any edit causes Kicad to crash immediately.

——— First instance - steps that lead to crash

open kicad
click create new symbol
select library
select symbol and attempt to edit or create new symbol and attempt to draw

——— Second instance - steps leading to crash

opened kicad
selected create new symbol
selected library
created blank symbol
adding pin leads to crash
- any adding or movement of graphics (inducing text) leads to crash




Below are the
[app info, version info, os, widget info],
[steps leading to crash],
[Kicad version and build settings], and
[MacBook Pro Error Report (excluding binary images and what follows that)]
for each instance.


---------------------------------------------
---------------------------------------------
---------------------------------------------
First Instance:

——— version info

app: Symbol library editor
ver: 5.0.2-5-10.14 release build
os: mac mojave 10.14.3 (18D109)
wxWidgets: 3.0.4

——— steps that lead to crash

open kicad
click create new symbol
select library
select symbol and attempt to edit or create new symbol and attempt to draw

——— kicad version:

Application: kicad
Version: (5.0.2-5-10.14), release build
Libraries:
    wxWidgets 3.0.4
    libcurl/7.54.0 LibreSSL/2.6.4 zlib/1.2.11 nghttp2/1.24.1
Platform: Mac OS X (Darwin 18.2.0 x86_64), 64 bit, Little endian, wxMac
Build Info:
    wxWidgets: 3.0.4 (UTF-8,STL containers,compatible with 2.8)
    Boost: 1.68.0
    OpenCASCADE Community Edition: 6.9.1
    Curl: 7.54.0
    Compiler: Clang 9.0.0 with C++ ABI 1002

Build settings:
    USE_WX_GRAPHICS_CONTEXT=ON
    USE_WX_OVERLAY=ON
    KICAD_SCRIPTING=ON
    KICAD_SCRIPTING_MODULES=ON
    KICAD_SCRIPTING_WXPYTHON=ON
    KICAD_SCRIPTING_ACTION_MENU=ON
    BUILD_GITHUB_PLUGIN=ON
    KICAD_USE_OCE=ON
    KICAD_USE_OCC=OFF
    KICAD_SPICE=ON

——— MacBook pro error report:

Process:               kicad [667]
Path:                  /Applications/KiCad/kicad.app/Contents/MacOS/kicad
Identifier:            org.kicad-pcb.kicad
Version:               ??? (???)
Code Type:             X86-64 (Native)
Parent Process:        ??? [1]
Responsible:           kicad [667]
User ID:               502

Date/Time:             2019-03-28 12:10:28.915 -0400
OS Version:            Mac OS X 10.14.3 (18D109)
Report Version:        12
Anonymous UUID:        98D1C325-C495-0C5E-11D2-F2EA442D0F75


Time Awake Since Boot: 130 seconds

System Integrity Protection: enabled

Crashed Thread:        0  Dispatch queue: com.apple.main-thread

Exception Type:        EXC_BAD_ACCESS (SIGSEGV)
Exception Codes:       EXC_I386_GPFLT
Exception Note:        EXC_CORPSE_NOTIFY

Termination Signal:    Segmentation fault: 11
Termination Reason:    Namespace SIGNAL, Code 0xb
Terminating Process:   exc handler [667]

Application Specific Information:
objc_msgSend() selector name: _subclassOverridesDrawBackgroundInRect


Thread 0 Crashed:: Dispatch queue: com.apple.main-thread
0   libobjc.A.dylib                     0x00007fff65357a29 objc_msgSend +
41
1   com.apple.AppKit                    0x00007fff36ae5cf9
-[NSTableBackgroundView drawRect:] + 274
2   com.apple.AppKit                    0x00007fff36863c29 _NSViewDrawRect
+ 66
3   com.apple.AppKit                    0x00007fff368624db
-[NSView(NSInternal)
_recursive:displayRectIgnoringOpacity:inContext:shouldChangeFontReferenceColor:stopAtLayerBackedViews:]
+ 1545
4   com.apple.AppKit                    0x00007fff36861ec2
__46-[NSView(NSLayerKitGlue) drawLayer:inContext:]_block_invoke + 192
5   com.apple.AppKit                    0x00007fff36861c21
-[NSView(NSLayerKitGlue) _drawViewBackingLayer:inContext:drawingHandler:] +
1769
6   com.apple.AppKit                    0x00007fff36937c04
-[_NSBackingLayerContents drawLayer:inContext:] + 165
7   com.apple.QuartzCore                0x00007fff441c3e56 -[CALayer
drawInContext:] + 281
8   com.apple.AppKit                    0x00007fff3693785e -[_NSTiledLayer
drawTile:inContext:] + 605
9   com.apple.AppKit                    0x00007fff369375a7
-[_NSTiledLayerContents drawLayer:inContext:] + 181
10  com.apple.QuartzCore                0x00007fff441c3e56 -[CALayer
drawInContext:] + 281
11  com.apple.AppKit                    0x00007fff369374e7 -[NSTileLayer
drawInContext:] + 148
12  com.apple.QuartzCore                0x00007fff441b0b23
CABackingStoreUpdate_ + 577
13  com.apple.QuartzCore                0x00007fff442119c5 invocation
function for block in CA::Layer::display_() + 53
14  com.apple.QuartzCore                0x00007fff441afd30 -[CALayer
_display] + 1839
15  com.apple.AppKit                    0x00007fff3693742f -[NSTileLayer
display] + 114
16  com.apple.AppKit                    0x00007fff369358ee
-[_NSTiledLayerContents update:shouldCallPrepareContent:] + 4780
17  com.apple.AppKit                    0x00007fff369343ae -[_NSTiledLayer
display] + 411
18  com.apple.QuartzCore                0x00007fff441af258
CA::Layer::display_if_needed(CA::Transaction*) + 634
19  com.apple.QuartzCore                0x00007fff4419d4cb
CA::Context::commit_transaction(CA::Transaction*) + 319
20  com.apple.QuartzCore                0x00007fff4419cda8
CA::Transaction::commit() + 576
21  com.apple.AppKit                    0x00007fff3683c305
__65+[CATransaction(NSCATransaction)
NS_setFlushesWithDisplayRefresh]_block_invoke + 274
22  com.apple.CoreFoundation            0x00007fff392458ed
__CFRUNLOOP_IS_CALLING_OUT_TO_AN_OBSERVER_CALLBACK_FUNCTION__ + 23
23  com.apple.CoreFoundation            0x00007fff39245822
__CFRunLoopDoObservers + 452
24  com.apple.CoreFoundation            0x00007fff391e7345 __CFRunLoopRun +
1166
25  com.apple.CoreFoundation            0x00007fff391e6c64
CFRunLoopRunSpecific + 463
26  com.apple.HIToolbox                 0x00007fff3847dab5
RunCurrentEventLoopInMode + 293
27  com.apple.HIToolbox                 0x00007fff3847d6f4
ReceiveNextEventCommon + 371
28  com.apple.HIToolbox                 0x00007fff3847d568
_BlockUntilNextEventMatchingListInModeWithFilter + 64
29  com.apple.AppKit                    0x00007fff36738363 _DPSNextEvent +
997
30  com.apple.AppKit                    0x00007fff36737102
-[NSApplication(NSEvent)
_nextEventMatchingEventMask:untilDate:inMode:dequeue:] + 1362
31  com.apple.AppKit                    0x00007fff36731165 -[NSApplication
run] + 699
32  libwx_osx_cocoau-3.0.0.4.0.dylib    0x000000010a07ec0e
wxGUIEventLoop::OSXDoRun() + 174
33  libwx_osx_cocoau-3.0.0.4.0.dylib    0x0000000109f68c51
wxCFEventLoop::DoRun() + 49
34  libwx_osx_cocoau-3.0.0.4.0.dylib    0x0000000109e939c2
wxEventLoopBase::Run() + 162
35  libwx_osx_cocoau-3.0.0.4.0.dylib    0x0000000109e4e9c3
wxAppConsoleBase::MainLoop() + 99
36  libwx_osx_cocoau-3.0.0.4.0.dylib    0x000000010a0139ea wxApp::OnRun() +
26
37  org.kicad-pcb.kicad                 0x0000000109ceeb59
APP_KICAD::OnRun() + 25
38  libwx_osx_cocoau-3.0.0.4.0.dylib    0x0000000109ed7a9a wxEntry(int&,
wchar_t**) + 58
39  org.kicad-pcb.kicad                 0x0000000109cedd40 main + 48
40  libdyld.dylib                       0x00007fff66434ed9 start + 1

Thread 1:
0   libsystem_pthread.dylib             0x00007fff666273f8 start_wqthread +
0
1   ???                                 0x0000000054485244 0 + 1414025796

Thread 2:
0   libsystem_pthread.dylib             0x00007fff666273f8 start_wqthread +
0
1   ???                                 0x0000000054485244 0 + 1414025796

Thread 3:: com.apple.CFSocket.private
0   libsystem_kernel.dylib              0x00007fff665755aa __select + 10
1   com.apple.CoreFoundation            0x00007fff39215c13
__CFSocketManager + 639
2   libsystem_pthread.dylib             0x00007fff66628305 _pthread_body +
126
3   libsystem_pthread.dylib             0x00007fff6662b26f _pthread_start +
70
4   libsystem_pthread.dylib             0x00007fff66627415 thread_start +
13

Thread 4:: com.apple.NSEventThread
0   libsystem_kernel.dylib              0x00007fff6656e17a mach_msg_trap +
10
1   libsystem_kernel.dylib              0x00007fff6656e6d0 mach_msg + 60
2   com.apple.CoreFoundation            0x00007fff391e7fde
__CFRunLoopServiceMachPort + 337
3   com.apple.CoreFoundation            0x00007fff391e752d __CFRunLoopRun +
1654
4   com.apple.CoreFoundation            0x00007fff391e6c64
CFRunLoopRunSpecific + 463
5   com.apple.AppKit                    0x00007fff36740f89 _NSEventThread +
160
6   libsystem_pthread.dylib             0x00007fff66628305 _pthread_body +
126
7   libsystem_pthread.dylib             0x00007fff6662b26f _pthread_start +
70
8   libsystem_pthread.dylib             0x00007fff66627415 thread_start +
13

Thread 5:
0   libsystem_pthread.dylib             0x00007fff666273f8 start_wqthread +
0
1   ???                                 0x0000000054485244 0 + 1414025796

Thread 6:
0   libsystem_pthread.dylib             0x00007fff666273f8 start_wqthread +
0
1   ???                                 0x0000000054485244 0 + 1414025796

Thread 7:
0   libsystem_pthread.dylib             0x00007fff666273f8 start_wqthread +
0

Thread 0 crashed with X86 Thread State (64-bit):
  rax: 0x00000000000000a8  rbx: 0x00000000000000b0  rcx: 0x0000000000000d40
rdx: 0x00007fff98e84c40
  rdi: 0x00007fe420f1acf0  rsi: 0x00007fff373b785d  rbp: 0x00007ffee5f22c20
rsp: 0x00007ffee5f22ba8
   r8: 0x0000000000000000   r9: 0x0000000000000000  r10: 0x00007fff91262c28
r11: 0x00616d6d61472064
  r12: 0x0000600002d7f020  r13: 0x0000000000000001  r14: 0x00007fff37325ed1
r15: 0x00007ffee5f22c30
  rip: 0x00007fff65357a29  rfl: 0x0000000000010202  cr2: 0x0000000115ef9008

Logical CPU:     0
Error Code:      0x00000000
Trap Number:     13



---------------------------------------------
---------------------------------------------
---------------------------------------------
Second Instance:


——— version info

app: Symbol library editor
ver: 5.0.2-5-10.14 release build
os: mac mojave 10.14.3 (18D109)
wxWidgets: 3.0.4

——— steps leading to crash

opened kicad
selected create new symbol
selected library
created blank symbol
adding pin leads to crash
- any adding or movement of graphics (inducing text) leads to crash

——— kicad version:

Application: kicad
Version: (5.0.2-5-10.14), release build
Libraries:
    wxWidgets 3.0.4
    libcurl/7.54.0 LibreSSL/2.6.4 zlib/1.2.11 nghttp2/1.24.1
Platform: Mac OS X (Darwin 18.2.0 x86_64), 64 bit, Little endian, wxMac
Build Info:
    wxWidgets: 3.0.4 (UTF-8,STL containers,compatible with 2.8)
    Boost: 1.68.0
    OpenCASCADE Community Edition: 6.9.1
    Curl: 7.54.0
    Compiler: Clang 9.0.0 with C++ ABI 1002

Build settings:
    USE_WX_GRAPHICS_CONTEXT=ON
    USE_WX_OVERLAY=ON
    KICAD_SCRIPTING=ON
    KICAD_SCRIPTING_MODULES=ON
    KICAD_SCRIPTING_WXPYTHON=ON
    KICAD_SCRIPTING_ACTION_MENU=ON
    BUILD_GITHUB_PLUGIN=ON
    KICAD_USE_OCE=ON
    KICAD_USE_OCC=OFF
    KICAD_SPICE=ON

——— mac error report

Process:               kicad [1113]
Path:                  /Applications/KiCad/kicad.app/Contents/MacOS/kicad
Identifier:            org.kicad-pcb.kicad
Version:               ??? (???)
Code Type:             X86-64 (Native)
Parent Process:        ??? [1]
Responsible:           kicad [1113]
User ID:               502

Date/Time:             2019-03-28 12:26:56.386 -0400
OS Version:            Mac OS X 10.14.3 (18D109)
Report Version:        12
Anonymous UUID:        98D1C325-C495-0C5E-11D2-F2EA442D0F75


Time Awake Since Boot: 1100 seconds

System Integrity Protection: enabled

Crashed Thread:        0  Dispatch queue: com.apple.main-thread

Exception Type:        EXC_BAD_ACCESS (SIGSEGV)
Exception Codes:       KERN_INVALID_ADDRESS at 0x0000000000000014
Exception Note:        EXC_CORPSE_NOTIFY

Termination Signal:    Segmentation fault: 11
Termination Reason:    Namespace SIGNAL, Code 0xb
Terminating Process:   exc handler [1113]

VM Regions Near 0x14:
-->
    __TEXT                 0000000102d86000-0000000102e70000 [  936K]
r-x/rwx SM=COW  /Applications/KiCad/kicad.app/Contents/MacOS/kicad

Thread 0 Crashed:: Dispatch queue: com.apple.main-thread
0   com.apple.AppKit                    0x00007fff36903694 -[NSTableView
_subclassOverridesDrawBackgroundInRect] + 22
1   com.apple.AppKit                    0x00007fff36ae5cf9
-[NSTableBackgroundView drawRect:] + 274
2   com.apple.AppKit                    0x00007fff36863c29 _NSViewDrawRect
+ 66
3   com.apple.AppKit                    0x00007fff368624db
-[NSView(NSInternal)
_recursive:displayRectIgnoringOpacity:inContext:shouldChangeFontReferenceColor:stopAtLayerBackedViews:]
+ 1545
4   com.apple.AppKit                    0x00007fff36861ec2
__46-[NSView(NSLayerKitGlue) drawLayer:inContext:]_block_invoke + 192
5   com.apple.AppKit                    0x00007fff36861c21
-[NSView(NSLayerKitGlue) _drawViewBackingLayer:inContext:drawingHandler:] +
1769
6   com.apple.AppKit                    0x00007fff36937c04
-[_NSBackingLayerContents drawLayer:inContext:] + 165
7   com.apple.QuartzCore                0x00007fff441c3e56 -[CALayer
drawInContext:] + 281
8   com.apple.AppKit                    0x00007fff3693785e -[_NSTiledLayer
drawTile:inContext:] + 605
9   com.apple.AppKit                    0x00007fff369375a7
-[_NSTiledLayerContents drawLayer:inContext:] + 181
10  com.apple.QuartzCore                0x00007fff441c3e56 -[CALayer
drawInContext:] + 281
11  com.apple.AppKit                    0x00007fff369374e7 -[NSTileLayer
drawInContext:] + 148
12  com.apple.QuartzCore                0x00007fff441b0b23
CABackingStoreUpdate_ + 577
13  com.apple.QuartzCore                0x00007fff442119c5 invocation
function for block in CA::Layer::display_() + 53
14  com.apple.QuartzCore                0x00007fff441afd30 -[CALayer
_display] + 1839
15  com.apple.AppKit                    0x00007fff3693742f -[NSTileLayer
display] + 114
16  com.apple.AppKit                    0x00007fff369358ee
-[_NSTiledLayerContents update:shouldCallPrepareContent:] + 4780
17  com.apple.AppKit                    0x00007fff369343ae -[_NSTiledLayer
display] + 411
18  com.apple.QuartzCore                0x00007fff441af258
CA::Layer::display_if_needed(CA::Transaction*) + 634
19  com.apple.QuartzCore                0x00007fff4419d4cb
CA::Context::commit_transaction(CA::Transaction*) + 319
20  com.apple.QuartzCore                0x00007fff4419cda8
CA::Transaction::commit() + 576
21  com.apple.AppKit                    0x00007fff3683c305
__65+[CATransaction(NSCATransaction)
NS_setFlushesWithDisplayRefresh]_block_invoke + 274
22  com.apple.CoreFoundation            0x00007fff392458ed
__CFRUNLOOP_IS_CALLING_OUT_TO_AN_OBSERVER_CALLBACK_FUNCTION__ + 23
23  com.apple.CoreFoundation            0x00007fff39245822
__CFRunLoopDoObservers + 452
24  com.apple.CoreFoundation            0x00007fff391e7345 __CFRunLoopRun +
1166
25  com.apple.CoreFoundation            0x00007fff391e6c64
CFRunLoopRunSpecific + 463
26  com.apple.HIToolbox                 0x00007fff3847dab5
RunCurrentEventLoopInMode + 293
27  com.apple.HIToolbox                 0x00007fff3847d6f4
ReceiveNextEventCommon + 371
28  com.apple.HIToolbox                 0x00007fff3847d568
_BlockUntilNextEventMatchingListInModeWithFilter + 64
29  com.apple.AppKit                    0x00007fff36738363 _DPSNextEvent +
997
30  com.apple.AppKit                    0x00007fff36737102
-[NSApplication(NSEvent)
_nextEventMatchingEventMask:untilDate:inMode:dequeue:] + 1362
31  com.apple.AppKit                    0x00007fff36731165 -[NSApplication
run] + 699
32  libwx_osx_cocoau-3.0.0.4.0.dylib    0x000000010312ec0e
wxGUIEventLoop::OSXDoRun() + 174
33  libwx_osx_cocoau-3.0.0.4.0.dylib    0x0000000103018c51
wxCFEventLoop::DoRun() + 49
34  libwx_osx_cocoau-3.0.0.4.0.dylib    0x0000000102f439c2
wxEventLoopBase::Run() + 162
35  libwx_osx_cocoau-3.0.0.4.0.dylib    0x0000000102efe9c3
wxAppConsoleBase::MainLoop() + 99
36  libwx_osx_cocoau-3.0.0.4.0.dylib    0x00000001030c39ea wxApp::OnRun() +
26
37  org.kicad-pcb.kicad                 0x0000000102d9bb59
APP_KICAD::OnRun() + 25
38  libwx_osx_cocoau-3.0.0.4.0.dylib    0x0000000102f87a9a wxEntry(int&,
wchar_t**) + 58
39  org.kicad-pcb.kicad                 0x0000000102d9ad40 main + 48
40  libdyld.dylib                       0x00007fff66434ed9 start + 1

Thread 1:
0   libsystem_pthread.dylib             0x00007fff666273f8 start_wqthread +
0
1   ???                                 0x0000000054485244 0 + 1414025796

Thread 2:: com.apple.CFSocket.private
0   libsystem_kernel.dylib              0x00007fff665755aa __select + 10
1   com.apple.CoreFoundation            0x00007fff39215c13
__CFSocketManager + 639
2   libsystem_pthread.dylib             0x00007fff66628305 _pthread_body +
126
3   libsystem_pthread.dylib             0x00007fff6662b26f _pthread_start +
70
4   libsystem_pthread.dylib             0x00007fff66627415 thread_start +
13

Thread 3:: com.apple.NSEventThread
0   libsystem_kernel.dylib              0x00007fff6656e17a mach_msg_trap +
10
1   libsystem_kernel.dylib              0x00007fff6656e6d0 mach_msg + 60
2   com.apple.CoreFoundation            0x00007fff391e7fde
__CFRunLoopServiceMachPort + 337
3   com.apple.CoreFoundation            0x00007fff391e752d __CFRunLoopRun +
1654
4   com.apple.CoreFoundation            0x00007fff391e6c64
CFRunLoopRunSpecific + 463
5   com.apple.AppKit                    0x00007fff36740f89 _NSEventThread +
160
6   libsystem_pthread.dylib             0x00007fff66628305 _pthread_body +
126
7   libsystem_pthread.dylib             0x00007fff6662b26f _pthread_start +
70
8   libsystem_pthread.dylib             0x00007fff66627415 thread_start +
13

Thread 4:
0   libsystem_pthread.dylib             0x00007fff666273f8 start_wqthread +
0
1   ???                                 0x0000000054485244 0 + 1414025796

Thread 5:
0   libsystem_pthread.dylib             0x00007fff666273f8 start_wqthread +
0
1   ???                                 0x0000000054485244 0 + 1414025796

Thread 6:
0   libsystem_pthread.dylib             0x00007fff666273f8 start_wqthread +
0
1   libsystem_malloc.dylib              0x00007fff665effdf
tiny_free_try_depot_unmap_no_lock + 369

Thread 0 crashed with X86 Thread State (64-bit):
  rax: 0x0000000000000000  rbx: 0x00000000000000b0  rcx: 0x0000000000000014
rdx: 0x00007fff98e84c40
  rdi: 0x00007fe258ee7340  rsi: 0x00007fff373b785d  rbp: 0x00007ffeece75b90
rsp: 0x00007ffeece75b90
   r8: 0x0000000000000000   r9: 0x0000000000000000  r10: 0x0000000103af33c0
r11: 0x00007fe26f823dd0
  r12: 0x000060000060d500  r13: 0x0000000000000001  r14: 0x00007fff37325ed1
r15: 0x00007ffeece75c20
  rip: 0x00007fff36903694  rfl: 0x0000000000010246  cr2: 0x0000000000000014

Logical CPU:     0
Error Code:      0x00000004
Trap Number:     14
```

Story points: 6.0