Repository: electron
Issue: [Bug]: `app.relaunch` crashes on Mac App Store
Labels: platform/macOS,crash :boom:,bug :beetle:,app-store,28-x-y

### Preflight Checklist

- [X] I have read the [Contributing Guidelines](https://github.com/electron/electron/blob/main/CONTRIBUTING.md) for this project.
- [X] I agree to follow the [Code of Conduct](https://github.com/electron/electron/blob/main/CODE_OF_CONDUCT.md) that this project adheres to.
- [X] I have searched the [issue tracker](https://www.github.com/electron/electron/issues) for a bug report that matches the one I want to file, without success.

### Electron Version

28.2.8

### What operating system are you using?

macOS

### Operating System Version

14.3.1 (23D60)

### What arch are you using?

arm64 (including Apple Silicon)

### Last Known Working Electron version

_No response_

### Expected Behavior

On a sandboxed and signed Mac App Store App, calling:

```
app.reload();
app.quit();
```

should exit the app and relaunch it.

### Actual Behavior

MacOS notifies that the app has quit unexpectedly.

![image](https://github.com/electron/electron/assets/137855/cdceba34-5978-49da-a061-fa2136f07b09)

### Testcase Gist URL

_No response_

### Additional Information

This only affects signed apps published through the app store. Notarized DMGs behave as expected.

The issue has existed in multiple versions of Electron and the issues are closed without resolving the problem.
Latest related issue: https://github.com/electron/electron/issues/38012

Crash report:
```
-------------------------------------
Translated Report (Full Report Below)
-------------------------------------

Process:               Bitwarden [61367]
Path:                  /Applications/Bitwarden.app/Contents/MacOS/Bitwarden
Identifier:            com.bitwarden.desktop
Version:               2024.3.1 (22440)
App Item ID:           1352778147
Code Type:             ARM-64 (Native)
Parent Process:        launchd [1]
User ID:               501

Date/Time:             2024-03-25 14:51:00.4622 +0100
OS Version:            macOS 14.3.1 (23D60)
Report Version:        12
Anonymous UUID:        

Sleep/Wake UUID:       0703C0B3-7211-4254-A6ED-9FB783FF6089

Time Awake Since Boot: 820000 seconds
Time Since Wake:       5800 seconds

System Integrity Protection: enabled

Crashed Thread:        0  Dispatch queue: com.apple.main-thread

Exception Type:        EXC_BREAKPOINT (SIGTRAP)
Exception Codes:       0x0000000000000001, 0x00000001976760a4

Termination Reason:    Namespace SIGNAL, Code 5 Trace/BPT trap: 5
Terminating Process:   exc handler [61367]

Application Specific Signatures:
SYSCALL_SET_PROFILE

Thread 0 Crashed::  Dispatch queue: com.apple.main-thread
0   libsystem_secinit.dylib       	       0x1976760a4 _libsecinit_appsandbox.cold.7 + 84
1   libsystem_secinit.dylib       	       0x197675228 _libsecinit_appsandbox + 1720
2   libsystem_trace.dylib         	       0x18ab3f6d8 _os_activity_initiate_impl + 64
3   libsystem_secinit.dylib       	       0x197674b1c _libsecinit_initializer + 80
4   libSystem.B.dylib             	       0x19768b694 libSystem_initializer + 260
5   dyld                          	       0x18aa79a24 invocation function for block in dyld4::Loader::findAndRunAllInitializers(dyld4::RuntimeState&) const::$_0::operator()() const + 168
6   dyld                          	       0x18aabf328 invocation function for block in dyld3::MachOAnalyzer::forEachInitializer(Diagnostics&, dyld3::MachOAnalyzer::VMAddrConverter const&, void (unsigned int) block_pointer, void const*) const + 340
7   dyld                          	       0x18aab2668 invocation function for block in dyld3::MachOFile::forEachSection(void (dyld3::MachOFile::SectionInfo const&, bool, bool&) block_pointer) const + 496
8   dyld                          	       0x18aa592fc dyld3::MachOFile::forEachLoadCommand(Diagnostics&, void (load_command const*, bool&) block_pointer) const + 300
9   dyld                          	       0x18aab16a0 dyld3::MachOFile::forEachSection(void (dyld3::MachOFile::SectionInfo const&, bool, bool&) block_pointer) const + 192
10  dyld                          	       0x18aabee3c dyld3::MachOAnalyzer::forEachInitializer(Diagnostics&, dyld3::MachOAnalyzer::VMAddrConverter const&, void (unsigned int) block_pointer, void const*) const + 516
11  dyld                          	       0x18aa75b38 dyld4::Loader::findAndRunAllInitializers(dyld4::RuntimeState&) const + 524
12  dyld                          	       0x18aa7f928 dyld4::PrebuiltLoader::runInitializers(dyld4::RuntimeState&) const + 44
13  dyld                          	       0x18aa9b360 dyld4::APIs::runAllInitializersForMain() + 84
14  dyld                          	       0x18aa5dfa0 dyld4::prepare(dyld4::APIs&, dyld3::MachOAnalyzer const*) + 3192
15  dyld                          	       0x18aa5cedc start + 1844


Thread 0 crashed with ARM Thread State (64-bit):
    x0: 0x000000000000003f   x1: 0x0000000197676aed   x2: 0x0000000000000000   x3: 0x000000016f47af0f
    x4: 0x0000000000000000   x5: 0x000000016f47ae70   x6: 0x0000000000000029   x7: 0x0000000000000760
    x8: 0x00000001e06e59a8   x9: 0x0000000197676aee  x10: 0x0000000000000200  x11: 0x000000016f47a9e0
   x12: 0x0000000000000000  x13: 0x0000000000000007  x14: 0x000000013b600000  x15: 0x000000000100000d
   x16: 0x000000018abf3cc0  x17: 0x00000001ea737bc8  x18: 0x0000000000000000  x19: 0x000000016f47aed0
   x20: 0x0000000000000001  x21: 0x000000013cb04470  x22: 0x000000013cb04560  x23: 0x000000013cb048f0
   x24: 0x000000013cb04730  x25: 0x0000000197676dae  x26: 0x0000000000000000  x27: 0x0000000000000001
   x28: 0x0000000197676df2   fp: 0x000000016f47ae90   lr: 0xe215000197676090
    sp: 0x000000016f47ae70   pc: 0x00000001976760a4 cpsr: 0x60001000
   far: 0x0000000000000000  esr: 0xf2000001 (Breakpoint) brk 1

Binary Images:
       0x113d60000 -        0x11c193fff com.github.Electron.framework (*) <4c4c448f-5555-3144-a168-998ed78c5049> /Applications/Bitwarden.app/Contents/Frameworks/Electron Framework.framework/Versions/A/Electron Framework
       0x101290000 -        0x10146ffff libffmpeg.dylib (*) <4c4c44c1-5555-3144-a117-33e45465acb1> /Applications/Bitwarden.app/Contents/Frameworks/Electron Framework.framework/Versions/A/Libraries/libffmpeg.dylib
       0x100980000 -        0x100983fff com.bitwarden.desktop (2024.3.1) <4c4c4472-5555-3144-a147-c542c6b08f8b> /Applications/Bitwarden.app/Contents/MacOS/Bitwarden
       0x197674000 -        0x197676ffb libsystem_secinit.dylib (*) <0a37b0c4-518f-343b-9542-299958362705> /usr/lib/system/libsystem_secinit.dylib
       0x18ab38000 -        0x18ab52fff libsystem_trace.dylib (*) <d243654e-bd35-337c-9714-b0b462fa20ca> /usr/lib/system/libsystem_trace.dylib
       0x19768a000 -        0x19768bfff libSystem.B.dylib (*) <68092300-d766-369d-8407-bf255e29e70f> /usr/lib/libSystem.B.dylib
       0x18aa57000 -        0x18aaeb387 dyld (*) <50746901-db0e-39a0-b391-baaa6b82ad0f> /usr/lib/dyld
               0x0 - 0xffffffffffffffff ??? (*) <00000000-0000-0000-0000-000000000000> ???
       0x18abf2000 -        0x18ac28fff libsystem_malloc.dylib (*) <faa92b9b-9273-3c30-bb9e-36346eca2faf> /usr/lib/system/libsystem_malloc.dylib

External Modification Summary:
  Calls made by other processes targeting this process:
    task_for_pid: 0
    thread_create: 0
    thread_set_state: 0
  Calls made by this process:
    task_for_pid: 0
    thread_create: 0
    thread_set_state: 0
  Calls made by all processes on this machine:
    task_for_pid: 16
    thread_create: 0
    thread_set_state: 52

VM Region Summary:
ReadOnly portion of Libraries: Total=1.8G resident=0K(0%) swapped_out_or_unallocated=1.8G(100%)
Writable regions: Total=184.1M written=0K(0%) resident=0K(0%) swapped_out=0K(0%) unallocated=184.1M(100%)

                                VIRTUAL   REGION 
REGION TYPE                        SIZE    COUNT (non-coalesced) 
===========                     =======  ======= 
Activity Tracing                   256K        1 
Kernel Alloc Once                   32K        1 
MALLOC                           166.2M       17 
MALLOC guard page                   96K        6 
STACK GUARD                       56.0M        1 
Stack                             8176K        1 
VM_ALLOCATE                         32K        1 
__AUTH                            3180K      531 
__AUTH_CONST                      39.2M      781 
__CTF                               824        1 
__DATA                            23.2M      773 
__DATA_CONST                      45.0M      792 
__DATA_DIRTY                      2860K      315 
__FONT_DATA                          4K        1 
__INFO_FILTER                         8        1 
__LINKEDIT                       897.3M        4 
__OBJC_RO                         71.2M        1 
__OBJC_RW                         2171K        1 
__TEXT                           943.0M      810 
dyld private memory               4384K        4 
shared memory                       32K        2 
===========                     =======  ======= 
TOTAL                              2.2G     4045 



-----------
Full Report
-----------

{"roots_installed":0,"app_cohort":"2|date=1711373400000&sf=143456&tid=a0d708d4607ab5429e02fd06be8eadd2a5bde7e2ec43e97e6d6bdb15656de65d&ttype=i","app_name":"Bitwarden","app_version":"2024.3.1","timestamp":"2024-03-25 14:51:00.00 +0100","slice_uuid":"4c4c4472-5555-3144-a147-c542c6b08f8b","adam_id":"1352778147","build_version":"22440","platform":1,"bundleID":"com.bitwarden.desktop","share_with_app_devs":0,"is_first_party":0,"bug_type":"309","os_version":"macOS 14.3.1 (23D60)","incident_id":"0F790199-A812-47AE-9ED0-BACCDDEC00BC","name":"Bitwarden","is_beta":1}
{
  "uptime" : 820000,
  "procRole" : "Unspecified",
  "version" : 2,
  "userID" : 501,
  "deployVersion" : 210,
  "modelCode" : "Mac14,9",
  "coalitionID" : 296773,
  "osVersion" : {
    "train" : "macOS 14.3.1",
    "build" : "23D60",
    "releaseType" : "User"
  },
  "captureTime" : "2024-03-25 14:51:00.4622 +0100",
  "codeSigningMonitor" : 1,
  "incident" : "0F790199-A812-47AE-9ED0-BACCDDEC00BC",
  "pid" : 61367,
  "translated" : false,
  "cpuType" : "ARM-64",
  "roots_installed" : 0,
  "bug_type" : "309",
  "procLaunch" : "2024-03-25 14:51:00.3894 +0100",
  "procStartAbsTime" : 19818610622221,
  "procExitAbsTime" : 19818611847913,
  "procName" : "Bitwarden",
  "procPath" : "\/Applications\/Bitwarden.app\/Contents\/MacOS\/Bitwarden",
  "bundleInfo" : {"CFBundleShortVersionString":"2024.3.1","CFBundleVersion":"22440","CFBundleIdentifier":"com.bitwarden.desktop"},
  "storeInfo" : {"storeCohortMetadata":"2|date=1711373400000&sf=143456&tid=a0d708d4607ab5429e02fd06be8eadd2a5bde7e2ec43e97e6d6bdb15656de65d&ttype=i","itemID":"1352778147","deviceIdentifierForVendor":"2994B5A1-5F3A-579A-81B2-6F21697EF467","thirdParty":true,"entitledBeta":true},
  "parentProc" : "launchd",
  "parentPid" : 1,
  "coalitionName" : "com.bitwarden.desktop",
  "isBeta" : 1,
  "responsiblePid" : 61359,
  "codeSigningID" : "com.bitwarden.desktop",
  "codeSigningTeamID" : "LTZ2PFU5D6",
  "codeSigningFlags" : 570425857,
  "codeSigningValidationCategory" : 2,
  "codeSigningTrustLevel" : 4294967295,
  "instructionByteStream" : {"beforePC":"AgAAkEIIK5HgAxOqAQCBUikBAJRogyTwCKEmkQkAAJApuSuREyUAqQ==","atPC":"IAAg1AgAAJAIUSWRaYMk8CjVBPkgACDUfyMD1f\/DANH0TwGp\/XsCqQ=="},
  "wakeTime" : 5800,
  "sleepWakeUUID" : "0703C0B3-7211-4254-A6ED-9FB783FF6089",
  "sip" : "enabled",
  "exception" : {"codes":"0x0000000000000001, 0x00000001976760a4","rawCodes":[1,6835101860],"type":"EXC_BREAKPOINT","signal":"SIGTRAP"},
  "termination" : {"flags":0,"code":5,"namespace":"SIGNAL","indicator":"Trace\/BPT trap: 5","byProc":"exc handler","byPid":61367},
  "os_fault" : {"process":"Bitwarden"},
  "asiSignatures" : ["SYSCALL_SET_PROFILE"],
  "extMods" : {"caller":{"thread_create":0,"thread_set_state":0,"task_for_pid":0},"system":{"thread_create":0,"thread_set_state":52,"task_for_pid":16},"targeted":{"thread_create":0,"thread_set_state":0,"task_for_pid":0},"warnings":0},
  "faultingThread" : 0,
  "threads" : [{"triggered":true,"id":28678876,"threadState":{"x":[{"value":63},{"value":6835104493},{"value":0},{"value":6161936143},{"value":0},{"value":6161935984},{"value":41},{"value":1888},{"value":8060295592,"symbolLocation":8,"symbol":"gCRAnnotations"},{"value":6835104494},{"value":512},{"value":6161934816},{"value":0},{"value":7},{"value":5291114496},{"value":16777229},{"value":6622756032,"symbolLocation":0,"symbol":"free"},{"value":8228404168},{"value":0},{"value":6161936080},{"value":1},{"value":5313152112},{"value":5313152352},{"value":5313153264},{"value":5313152816},{"value":6835105198},{"value":0},{"value":1},{"value":6835105266}],"flavor":"ARM_THREAD_STATE64","lr":{"value":16290927233917739152},"cpsr":{"value":1610616832},"fp":{"value":6161936016},"sp":{"value":6161935984},"esr":{"value":4060086273,"description":"(Breakpoint) brk 1"},"pc":{"value":6835101860,"matchesCrashFrame":1},"far":{"value":0}},"queue":"com.apple.main-thread","frames":[{"imageOffset":8356,"symbol":"_libsecinit_appsandbox.cold.7","symbolLocation":84,"imageIndex":3},{"imageOffset":4648,"symbol":"_libsecinit_appsandbox","symbolLocation":1720,"imageIndex":3},{"imageOffset":30424,"symbol":"_os_activity_initiate_impl","symbolLocation":64,"imageIndex":4},{"imageOffset":2844,"symbol":"_libsecinit_initializer","symbolLocation":80,"imageIndex":3},{"imageOffset":5780,"symbol":"libSystem_initializer","symbolLocation":260,"imageIndex":5},{"imageOffset":141860,"symbol":"invocation function for block in dyld4::Loader::findAndRunAllInitializers(dyld4::RuntimeState&) const::$_0::operator()() const","symbolLocation":168,"imageIndex":6},{"imageOffset":426792,"symbol":"invocation function for block in dyld3::MachOAnalyzer::forEachInitializer(Diagnostics&, dyld3::MachOAnalyzer::VMAddrConverter const&, void (unsigned int) block_pointer, void const*) const","symbolLocation":340,"imageIndex":6},{"imageOffset":374376,"symbol":"invocation function for block in dyld3::MachOFile::forEachSection(void (dyld3::MachOFile::SectionInfo const&, bool, bool&) block_pointer) const","symbolLocation":496,"imageIndex":6},{"imageOffset":8956,"symbol":"dyld3::MachOFile::forEachLoadCommand(Diagnostics&, void (load_command const*, bool&) block_pointer) const","symbolLocation":300,"imageIndex":6},{"imageOffset":370336,"symbol":"dyld3::MachOFile::forEachSection(void (dyld3::MachOFile::SectionInfo const&, bool, bool&) block_pointer) const","symbolLocation":192,"imageIndex":6},{"imageOffset":425532,"symbol":"dyld3::MachOAnalyzer::forEachInitializer(Diagnostics&, dyld3::MachOAnalyzer::VMAddrConverter const&, void (unsigned int) block_pointer, void const*) const","symbolLocation":516,"imageIndex":6},{"imageOffset":125752,"symbol":"dyld4::Loader::findAndRunAllInitializers(dyld4::RuntimeState&) const","symbolLocation":524,"imageIndex":6},{"imageOffset":166184,"symbol":"dyld4::PrebuiltLoader::runInitializers(dyld4::RuntimeState&) const","symbolLocation":44,"imageIndex":6},{"imageOffset":279392,"symbol":"dyld4::APIs::runAllInitializersForMain()","symbolLocation":84,"imageIndex":6},{"imageOffset":28576,"symbol":"dyld4::prepare(dyld4::APIs&, dyld3::MachOAnalyzer const*)","symbolLocation":3192,"imageIndex":6},{"imageOffset":24284,"symbol":"start","symbolLocation":1844,"imageIndex":6}]}],
  "usedImages" : [
  {
    "source" : "P",
    "arch" : "arm64",
    "base" : 4627759104,
    "CFBundleIdentifier" : "com.github.Electron.framework",
    "size" : 138625024,
    "uuid" : "4c4c448f-5555-3144-a168-998ed78c5049",
    "path" : "\/Applications\/Bitwarden.app\/Contents\/Frameworks\/Electron Framework.framework\/Versions\/A\/Electron Framework",
    "name" : "Electron Framework",
    "CFBundleVersion" : "28.2.8"
  },
  {
    "source" : "P",
    "arch" : "arm64",
    "base" : 4314431488,
    "size" : 1966080,
    "uuid" : "4c4c44c1-5555-3144-a117-33e45465acb1",
    "path" : "\/Applications\/Bitwarden.app\/Contents\/Frameworks\/Electron Framework.framework\/Versions\/A\/Libraries\/libffmpeg.dylib",
    "name" : "libffmpeg.dylib"
  },
  {
    "source" : "P",
    "arch" : "arm64",
    "base" : 4304928768,
    "CFBundleShortVersionString" : "2024.3.1",
    "CFBundleIdentifier" : "com.bitwarden.desktop",
    "size" : 16384,
    "uuid" : "4c4c4472-5555-3144-a147-c542c6b08f8b",
    "path" : "\/Applications\/Bitwarden.app\/Contents\/MacOS\/Bitwarden",
    "name" : "Bitwarden",
    "CFBundleVersion" : "22440"
  },
  {
    "source" : "P",
    "arch" : "arm64e",
    "base" : 6835093504,
    "size" : 12284,
    "uuid" : "0a37b0c4-518f-343b-9542-299958362705",
    "path" : "\/usr\/lib\/system\/libsystem_secinit.dylib",
    "name" : "libsystem_secinit.dylib"
  },
  {
    "source" : "P",
    "arch" : "arm64e",
    "base" : 6621986816,
    "size" : 110592,
    "uuid" : "d243654e-bd35-337c-9714-b0b462fa20ca",
    "path" : "\/usr\/lib\/system\/libsystem_trace.dylib",
    "name" : "libsystem_trace.dylib"
  },
  {
    "source" : "P",
    "arch" : "arm64e",
    "base" : 6835183616,
    "size" : 8192,
    "uuid" : "68092300-d766-369d-8407-bf255e29e70f",
    "path" : "\/usr\/lib\/libSystem.B.dylib",
    "name" : "libSystem.B.dylib"
  },
  {
    "source" : "P",
    "arch" : "arm64e",
    "base" : 6621065216,
    "size" : 607112,
    "uuid" : "50746901-db0e-39a0-b391-baaa6b82ad0f",
    "path" : "\/usr\/lib\/dyld",
    "name" : "dyld"
  },
  {
    "size" : 0,
    "source" : "A",
    "base" : 0,
    "uuid" : "00000000-0000-0000-0000-000000000000"
  },
  {
    "source" : "P",
    "arch" : "arm64e",
    "base" : 6622748672,
    "size" : 225280,
    "uuid" : "faa92b9b-9273-3c30-bb9e-36346eca2faf",
    "path" : "\/usr\/lib\/system\/libsystem_malloc.dylib",
    "name" : "libsystem_malloc.dylib"
  }
],
  "sharedCache" : {
  "base" : 6620315648,
  "size" : 4065345536,
  "uuid" : "c32b200e-cf99-3583-bc9f-b7fb11382e8f"
},
  "vmSummary" : "ReadOnly portion of Libraries: Total=1.8G resident=0K(0%) swapped_out_or_unallocated=1.8G(100%)\nWritable regions: Total=184.1M written=0K(0%) resident=0K(0%) swapped_out=0K(0%) unallocated=184.1M(100%)\n\n                                VIRTUAL   REGION \nREGION TYPE                        SIZE    COUNT (non-coalesced) \n===========                     =======  ======= \nActivity Tracing                   256K        1 \nKernel Alloc Once                   32K        1 \nMALLOC                           166.2M       17 \nMALLOC guard page                   96K        6 \nSTACK GUARD                       56.0M        1 \nStack                             8176K        1 \nVM_ALLOCATE                         32K        1 \n__AUTH                            3180K      531 \n__AUTH_CONST                      39.2M      781 \n__CTF                               824        1 \n__DATA                            23.2M      773 \n__DATA_CONST                      45.0M      792 \n__DATA_DIRTY                      2860K      315 \n__FONT_DATA                          4K        1 \n__INFO_FILTER                         8        1 \n__LINKEDIT                       897.3M        4 \n__OBJC_RO                         71.2M        1 \n__OBJC_RW                         2171K        1 \n__TEXT                           943.0M      810 \ndyld private memory               4384K        4 \nshared memory                       32K        2 \n===========                     =======  ======= \nTOTAL                              2.2G     4045 \n",
  "legacyInfo" : {
  "threadTriggered" : {
    "queue" : "com.apple.main-thread"
  }
},
  "logWritingSignature" : "cbaf75e5c05f95dbbda0504c81cf6e6e90bfb2cf",
  "trialInfo" : {
  "rollouts" : [
    {
      "rolloutId" : "6112d17137f5d11121dcd4e2",
      "factorPackIds" : {

      },
      "deploymentId" : 240000517
    },
    {
      "rolloutId" : "60186475825c62000ccf5450",
      "factorPackIds" : {

      },
      "deploymentId" : 240000069
    }
  ],
  "experiments" : [
    {
      "treatmentId" : "a3f9ec09-b145-49f3-8142-da4a1f338456",
      "experimentId" : "65f21aa774b6f500a45abd7d",
      "deploymentId" : 400000002
    }
  ]
}
}
```