Frequent segfaults w/ KiCad 7.0.8 pcbnew on save & menu click

Description

I'm just saving the board pcbnew and the next clicks on menus trigger a crash. Unfortunately it doesn't happen every time.

This didn't happen before on KiCad version 7.0.6 nor 7.0.7, only with 7.0.8 AFAICT.

Steps to reproduce

  1. Save the board while in pcbnew.
  2. Interact with any of the menus.
  3. Crash (SIGSEGV)

KiCad Version

Application: KiCad arm64 on arm64

Version: 7.0.8, release build

Libraries:
	wxWidgets 3.2.2
	FreeType 2.13.0
	HarfBuzz 7.3.0
	FontConfig 2.14.2
	libcurl/8.1.2 (SecureTransport) LibreSSL/3.3.6 zlib/1.2.12 nghttp2/1.55.1

Platform: macOS Version 14.0 (Build 23A344), 64 bit, Little endian, wxMac

Build Info:
	Date: Sep 29 2023 12:23:42
	wxWidgets: 3.2.2 (wchar_t,wx containers)
	Boost: 1.82.0
	OCC: 7.7.0
	Curl: 7.77.0
	ngspice: 38
	Compiler: Clang 13.0.0 with C++ ABI 1002

Build settings:
	KICAD_SPICE=ON

Abridged backtrace

I'm pasting a snippet of one of the backtraces for brevity below as well as attaching a couple of full backtraces/logs as files:

full_backtrace_2.log full_backtrace_1.log

-------------------------------------
Translated Report (Full Report Below)
-------------------------------------

Process:               kicad [28886]
Path:                  /Applications/KiCad/KiCad.app/Contents/MacOS/kicad
Identifier:            org.kicad.kicad
Version:               7.0.8 (7.0.8)
Code Type:             ARM-64 (Native)
Parent Process:        launchd [1]
User ID:               501

Date/Time:             2023-10-28 16:32:50.7214 +1100
OS Version:            macOS 14.0 (23A344)
Report Version:        12
Anonymous UUID:        BDB2C398-1597-7BC4-CB7B-4DFFACA20373

Sleep/Wake UUID:       8EB2EDED-47E4-49C5-BE4D-C8B5E869B993

Time Awake Since Boot: 150000 seconds
Time Since Wake:       13894 seconds

System Integrity Protection: disabled

Crashed Thread:        0  Dispatch queue: com.apple.main-thread

Exception Type:        EXC_BAD_ACCESS (SIGSEGV)
Exception Codes:       KERN_INVALID_ADDRESS at 0x06867cf708765a99 -> 0xfffffcf708765a99 (possible pointer authentication failure)
Exception Codes:       0x0000000000000001, 0x06867cf708765a99

Termination Reason:    Namespace SIGNAL, Code 11 Segmentation fault: 11
Terminating Process:   exc handler [28886]

VM Region Info: 0xfffffcf708765a99 is not in any region.  Bytes after previous region: 18446635177640090266  
      REGION TYPE                    START - END         [ VSIZE] PRT/MAX SHRMOD  REGION DETAIL
      MALLOC_NANO              600140000000-600160000000 [512.0M] rw-/rwx SM=PRV  
--->  
      UNUSED SPACE AT END

Thread 0 Crashed::  Dispatch queue: com.apple.main-thread
0   _pcbnew.kiface                	       0x168dfe6d0 ACTION_MENU::OnMenuEvent(wxMenuEvent&) + 2312
1   _pcbnew.kiface                	       0x168e34fc0 TOOL_DISPATCHER::DispatchWxEvent(wxEvent&) + 2084
2   libwx_osx_cocoau-3.2.0.2.1.dylib	       0x103e0c83c wxEventHashTable::HandleEvent(wxEvent&, wxEvtHandler*) + 444
3   libwx_osx_cocoau-3.2.0.2.1.dylib	       0x103e0de10 wxEvtHandler::ProcessEvent(wxEvent&) + 260
4   _pcbnew.kiface                	       0x168d26a14 EDA_BASE_FRAME::ProcessEvent(wxEvent&) + 96
5   libwx_osx_cocoau-3.2.0.2.1.dylib	       0x103e0df84 wxEvtHandler::ProcessEventLocally(wxEvent&) + 192
6   libwx_osx_cocoau-3.2.0.2.1.dylib	       0x103e0dd44 wxEvtHandler::ProcessEvent(wxEvent&) + 56
7   libwx_osx_cocoau-3.2.0.2.1.dylib	       0x103e0e538 wxEvtHandler::SafelyProcessEvent(wxEvent&) + 24
8   libwx_osx_cocoau-3.2.0.2.1.dylib	       0x103fd64a0 wxMenuBase::ProcessMenuEvent(wxMenu*, wxMenuEvent&, wxWindow*) + 24
9   libwx_osx_cocoau-3.2.0.2.1.dylib	       0x103e70254 wxMenu::HandleMenuItemHighlighted(wxMenuItem*) + 108
10  AppKit                        	       0x18ae2875c -[NSMenu _informDelegateOfHighlightedItem:] + 140
11  AppKit                        	       0x18b37cb30 -[NSCocoaMenuImpl _addHighlightForView:] + 284
12  AppKit                        	       0x18b37c7c8 __60-[NSCocoaMenuImpl _highlightMenuItemView:shouldOpenSubmenu:]_block_invoke + 224
13  AppKit                        	       0x18b37c46c -[NSCocoaMenuImpl _highlightMenuItemView:shouldOpenSubmenu:] + 368
14  AppKit                        	       0x18b37b9ac -[NSCocoaMenuImpl _routeEventIfNeeded:toSubview:] + 564
15  AppKit                        	       0x18b37b530 -[NSCocoaMenuImpl handleMouseEvent:] + 232
16  AppKit                        	       0x18b86bbd0 -[NSMenuBarImpl mouseDown:] + 128
17  AppKit                        	       0x18b1a4ea8 -[NSMenuTrackingSession _mouseDownEventHandler:] + 184
18  AppKit                        	       0x18b248204 -[NSMenuBarTrackingSession _mouseDownEventHandler:] + 160
19  AppKit                        	       0x18b24814c -[NSMenuBarTrackingSession handleEvent:] + 248
20  AppKit                        	       0x18b24802c __61-[NSMenuBarTrackingSession _addMouseDownEventMonitorIfNeeded]_block_invoke + 192
21  AppKit                        	       0x18ad7c624 _NSSendEventToDequeuingObservers + 252
22  AppKit                        	       0x18b35519c -[NSApplication(NSEventRouting) _nextEventMatchingEventMask:untilDate:inMode:dequeue:] + 2260
23  AppKit                        	       0x18ab7443c -[NSApplication run] + 476
24  libwx_osx_cocoau-3.2.0.2.1.dylib	       0x103eebf54 wxGUIEventLoop::OSXDoRun() + 196
25  libwx_osx_cocoau-3.2.0.2.1.dylib	       0x103de28c4 wxCFEventLoop::DoRun() + 40
26  libwx_osx_cocoau-3.2.0.2.1.dylib	       0x103d39630 wxEventLoopBase::Run() + 192
27  libwx_osx_cocoau-3.2.0.2.1.dylib	       0x103d0a0a0 wxAppConsoleBase::MainLoop() + 208
28  libwx_osx_cocoau-3.2.0.2.1.dylib	       0x103e89888 wxApp::OnRun() + 36
29  kicad                         	       0x100f30688 APP_KICAD::OnRun() + 20
30  libwx_osx_cocoau-3.2.0.2.1.dylib	       0x103d6c154 wxEntry(int&, wchar_t**) + 88
31  kicad                         	       0x100f2eb84 main + 52
32  dyld                          	       0x186f51058 start + 2224