Virtualc64: Crash on Exit of VirtualC64 (findAttachmentInMemory)

Created on 26 Mar 2019  路  20Comments  路  Source: dirkwhoffmann/virtualc64

Repeated Crash on Fast close as program is loading

Priority-High bug

All 20 comments

Repeating the loop, open close, I get another crash (Scenario 2).
To reproduce that I do,

  1. open test.prg
  2. close the window quickly

Thread 0 Crashed:: Dispatch queue: com.apple.main-thread
0 de.dirkwhoffmann.VirtualC64 0x0000000106b846f4 MyDocument.flashAttachmentIntoMemory() + 244 (MyDocument.swift:400)
1 de.dirkwhoffmann.VirtualC64 0x0000000106b840c9 MyDocument.mountAttachment(action:text:) + 377 (MyDocument.swift:311)
2 de.dirkwhoffmann.VirtualC64 0x0000000106b87a02 partial apply for closure #1 in MyDocument.mountAttachment() + 66
3 de.dirkwhoffmann.VirtualC64 0x0000000106ba7ef0 thunk for @escaping @callee_guaranteed () -> () + 32
4 libdispatch.dylib 0x00007fff5a8cf63d _dispatch_client_callout + 8
5 libdispatch.dylib 0x00007fff5a8d1de6 _dispatch_continuation_pop + 414
6 libdispatch.dylib 0x00007fff5a8e0f42 _dispatch_source_invoke + 2056
7 libdispatch.dylib 0x00007fff5a8da54b _dispatch_main_queue_callback_4CF + 813
8 com.apple.CoreFoundation 0x00007fff2e4a5227 __CFRUNLOOP_IS_SERVICING_THE_MAIN_DISPATCH_QUEUE__ + 9
9 com.apple.CoreFoundation 0x00007fff2e4a4951 __CFRunLoopRun + 2289
10 com.apple.CoreFoundation 0x00007fff2e4a3e0e CFRunLoopRunSpecific + 455
11 com.apple.HIToolbox 0x00007fff2d7909db RunCurrentEventLoopInMode + 292
12 com.apple.HIToolbox 0x00007fff2d790715 ReceiveNextEventCommon + 603
13 com.apple.HIToolbox 0x00007fff2d7904a6 _BlockUntilNextEventMatchingListInModeWithFilter + 64
14 com.apple.AppKit 0x00007fff2bb2affb _DPSNextEvent + 965
15 com.apple.AppKit 0x00007fff2bb29d93 -[NSApplication(NSEvent) _nextEventMatchingEventMask:untilDate:inMode:dequeue:] + 1361
16 com.apple.AppKit 0x00007fff2bb23eb0 -[NSApplication run] + 699
17 com.apple.AppKit 0x00007fff2bb133f0 NSApplicationMain + 777
18 de.dirkwhoffmann.VirtualC64 0x0000000106b09779 main + 9 (MyAppDelegate.swift:59)
19 libdyld.dylib 0x00007fff5a91c3d5 start + 1

Strange. It happens at two completely different program locations. I guess the C64 emulator reference is uses somewhere although it has already beed deleted.

Can you provide me the following information?

Was the debug panel open when you quit the emulator?
Are you on macOS Mojave?

  1. I am on Mojave
  2. I do not have the panel open.

Just captured one of the exceptions under debugger. Trying to bring this info in the issue now

Ok. so the issue happens in the MyDocument class, in flashAttachmentIntoMemory.

2019-03-29 10:43:28.387740+0000 VirtualC64[95097:1300437] [DYMTLInitPlatform] platform initialization successful
MyDocument.55::init()
UserDefaults.59::registerUserDefaults()
2019-03-29 10:43:28.590240+0000 VirtualC64[95097:1300408] C64Proxy::init
C64: Creating virtual C64[0x119000000]
SIDBridge: Setting clock frequency to 985249
ReSID: Setting clock frequency to 985249 cycles per second.
Drive1: Duration a CPU cycle is 10149 1/10 nsec.
Drive2: Duration a CPU cycle is 10149 1/10 nsec.
C64: Resetting virtual C64[0x119000000]
C64: Setting PC to FCE2
MyDocument.67::makeWindowControllers()
MetalView.186::awakeFromNib()
2019-03-29 10:43:29.052236+0000 VirtualC64[95097:1300408] Metal GPU Frame Capture Enabled
2019-03-29 10:43:29.054402+0000 VirtualC64[95097:1300408] Metal API Validation Enabled
MyController.340::awakeFromNib()
AudioEngine.27::init(withSID:)
2019-03-29 10:43:29.689463+0000 VirtualC64[95097:1300408]   saved enable noise cancellation setting is the same as the default (=1)
SIDBridge: Changing sample rate from 44100 to 44100
ReSID: Setting sample rate to 44100 samples per second.
FastSID: Setting sample rate to 44100
MyController.353::windowDidLoad()
GamePad.72::init(manager:vendorID:productID:locationID:)
GamePad.72::init(manager:vendorID:productID:locationID:)
GamePad.72::init(manager:vendorID:productID:locationID:)
GamePadManager.310::restoreFactorySettings()
WindowDelegate.167::adjustWindowSize()
MetalSetup.28::setupMetal()
MetalSetup.44::buildMetal()
MetalSetup.75::buildTextures()
MetalSetup.414::buildPipeline()
UserDefaults.89::loadUserDefaults()
ROMFile: File /Users/thierry/Emulation/CBM/ROMS/basic.901226-01.rom read successfully
ROMFile: File /Users/thierry/Emulation/CBM/ROMS/characters.901225-01.rom read successfully
ROMFile: File /Users/thierry/Emulation/CBM/ROMS/jiffydos-kernal-6.01.rom read successfully
ROMFile: File /Users/thierry/Emulation/CBM/ROMS/jiffydos-1541-II-6.00.rom read successfully
UserDefaults.42::decode(_:forKey:): Decoded VC64KeyMap successfully
UserDefaults.42::decode(_:forKey:): Decoded VC64JoyKeyMap1 successfully
UserDefaults.42::decode(_:forKey:): Decoded VC64JoyKeyMap2 successfully
UserDefaults.42::decode(_:forKey:): Decoded VC64ShaderOptionsKey successfully
UserDefaults.42::decode(_:forKey:): Decoded VC64AutoMountAction successfully
UserDefaults.42::decode(_:forKey:): Decoded VC64AutoType successfully
UserDefaults.42::decode(_:forKey:): Decoded VC64AutoTypeText successfully
SIDBridge: Setting clock frequency to 985249
ReSID: Setting clock frequency to 985249 cycles per second.
Drive1: Duration a CPU cycle is 10149 1/10 nsec.
Drive2: Duration a CPU cycle is 10149 1/10 nsec.
ReSID: Emulating SID model MOS8580.
ReSID: Enabling audio filter emulation.
ReSID: Using sampling method SAMPLE_INTERPOLATE.
MyController.434::addListener()
MyController.451::addListener(): Listener is in place
C64: Resetting virtual C64[0x119000000]
C64 memory: Grabbing reset vector from source 2
C64: Setting PC to FCE2
MyController.467::createTimer(): GUI timer is up and running
MyAppDelegate.66::applicationDidFinishLaunching(_:)
Animation.194::blendIn(): Blending in...
Dragged in filename
MyDocument.182::createAttachment(from:): Creating attachment from URL hello.prg.
MyDocument.208::createAttachment(from:ofType:): Read 6571 bytes from file hello.prg.
MyDocument.306::mountAttachment(action:text:): Action = flashFirstFile
MyDocument.318::mountAttachment(action:text:): Auto typing: RUN
WindowDelegate.50::windowWillClose(_:)
MetalView.549::cleanup()
MyDocument.539::removeWindowController(_:)
2019-03-29 10:43:43.567081+0000 VirtualC64[95097:1300408] C64Proxy::kill
C64: Destroying virtual C64[0x119000000]
MyDocument.55::init()
UserDefaults.59::registerUserDefaults()
2019-03-29 10:43:46.260376+0000 VirtualC64[95097:1300408] C64Proxy::init
C64: Creating virtual C64[0x119000000]
SIDBridge: Setting clock frequency to 985249
ReSID: Setting clock frequency to 985249 cycles per second.
Drive1: Duration a CPU cycle is 10149 1/10 nsec.
Drive2: Duration a CPU cycle is 10149 1/10 nsec.
C64: Resetting virtual C64[0x119000000]
C64: Setting PC to FCE2
MyDocument.67::makeWindowControllers()
MetalView.186::awakeFromNib()
MyController.340::awakeFromNib()
AudioEngine.27::init(withSID:)
SIDBridge: Changing sample rate from 44100 to 44100
ReSID: Setting sample rate to 44100 samples per second.
FastSID: Setting sample rate to 44100
MyController.353::windowDidLoad()
GamePad.72::init(manager:vendorID:productID:locationID:)
GamePad.72::init(manager:vendorID:productID:locationID:)
GamePad.72::init(manager:vendorID:productID:locationID:)
GamePadManager.310::restoreFactorySettings()
WindowDelegate.167::adjustWindowSize()
MetalSetup.28::setupMetal()
MetalSetup.44::buildMetal()
MetalSetup.75::buildTextures()
MetalSetup.414::buildPipeline()
UserDefaults.89::loadUserDefaults()
ROMFile: File /Users/thierry/Emulation/CBM/ROMS/basic.901226-01.rom read successfully
ROMFile: File /Users/thierry/Emulation/CBM/ROMS/characters.901225-01.rom read successfully
ROMFile: File /Users/thierry/Emulation/CBM/ROMS/jiffydos-kernal-6.01.rom read successfully
ROMFile: File /Users/thierry/Emulation/CBM/ROMS/jiffydos-1541-II-6.00.rom read successfully
UserDefaults.42::decode(_:forKey:): Decoded VC64KeyMap successfully
UserDefaults.42::decode(_:forKey:): Decoded VC64JoyKeyMap1 successfully
UserDefaults.42::decode(_:forKey:): Decoded VC64JoyKeyMap2 successfully
UserDefaults.42::decode(_:forKey:): Decoded VC64ShaderOptionsKey successfully
UserDefaults.42::decode(_:forKey:): Decoded VC64AutoMountAction successfully
UserDefaults.42::decode(_:forKey:): Decoded VC64AutoType successfully
UserDefaults.42::decode(_:forKey:): Decoded VC64AutoTypeText successfully
SIDBridge: Setting clock frequency to 985249
ReSID: Setting clock frequency to 985249 cycles per second.
Drive1: Duration a CPU cycle is 10149 1/10 nsec.
Drive2: Duration a CPU cycle is 10149 1/10 nsec.
ReSID: Emulating SID model MOS8580.
ReSID: Enabling audio filter emulation.
ReSID: Using sampling method SAMPLE_INTERPOLATE.
MyController.434::addListener()
MyController.451::addListener(): Listener is in place
C64: Resetting virtual C64[0x119000000]
C64 memory: Grabbing reset vector from source 2
C64: Setting PC to FCE2
MyController.467::createTimer(): GUI timer is up and running
WindowDelegate.16::windowDidBecomeMain(_:)
WindowDelegate.167::adjustWindowSize()
Animation.194::blendIn(): Blending in...
WindowDelegate.37::windowDidResignMain(_:)
Dragged in filename
MyDocument.182::createAttachment(from:): Creating attachment from URL hello.prg.
MyDocument.208::createAttachment(from:ofType:): Read 6571 bytes from file hello.prg.
MyDocument.306::mountAttachment(action:text:): Action = flashFirstFile
MyDocument.318::mountAttachment(action:text:): Auto typing: RUN
WindowDelegate.16::windowDidBecomeMain(_:)
WindowDelegate.167::adjustWindowSize()
Dragged in filename
MyDocument.182::createAttachment(from:): Creating attachment from URL hello.prg.
MyDocument.208::createAttachment(from:ofType:): Read 6571 bytes from file hello.prg.
MyDocument.306::mountAttachment(action:text:): Action = flashFirstFile
MyDocument.318::mountAttachment(action:text:): Auto typing: RUN
WindowDelegate.50::windowWillClose(_:)
MetalView.549::cleanup()
WindowDelegate.37::windowDidResignMain(_:)
MyDocument.539::removeWindowController(_:)
2019-03-29 10:44:03.290292+0000 VirtualC64[95097:1300408] C64Proxy::kill
C64: Destroying virtual C64[0x119000000]
MyDocument.55::init()
UserDefaults.59::registerUserDefaults()
2019-03-29 10:44:07.365939+0000 VirtualC64[95097:1300408] C64Proxy::init
C64: Creating virtual C64[0x119000000]
SIDBridge: Setting clock frequency to 985249
ReSID: Setting clock frequency to 985249 cycles per second.
Drive1: Duration a CPU cycle is 10149 1/10 nsec.
Drive2: Duration a CPU cycle is 10149 1/10 nsec.
C64: Resetting virtual C64[0x119000000]
C64: Setting PC to FCE2
MyDocument.67::makeWindowControllers()
MetalView.186::awakeFromNib()
MyController.340::awakeFromNib()
AudioEngine.27::init(withSID:)
SIDBridge: Changing sample rate from 44100 to 44100
ReSID: Setting sample rate to 44100 samples per second.
FastSID: Setting sample rate to 44100
MyController.353::windowDidLoad()
GamePad.72::init(manager:vendorID:productID:locationID:)
GamePad.72::init(manager:vendorID:productID:locationID:)
GamePad.72::init(manager:vendorID:productID:locationID:)
GamePadManager.310::restoreFactorySettings()
WindowDelegate.167::adjustWindowSize()
MetalSetup.28::setupMetal()
MetalSetup.44::buildMetal()
MetalSetup.75::buildTextures()
SIDBridge: Changing sample rate from 44100 to 44100
ReSID: Setting sample rate to 44100 samples per second.
FastSID: Setting sample rate to 44100
MetalSetup.414::buildPipeline()
UserDefaults.89::loadUserDefaults()
ROMFile: File /Users/thierry/Emulation/CBM/ROMS/basic.901226-01.rom read successfully
ROMFile: File /Users/thierry/Emulation/CBM/ROMS/characters.901225-01.rom read successfully
ROMFile: File /Users/thierry/Emulation/CBM/ROMS/jiffydos-kernal-6.01.rom read successfully
ROMFile: File /Users/thierry/Emulation/CBM/ROMS/jiffydos-1541-II-6.00.rom read successfully
UserDefaults.42::decode(_:forKey:): Decoded VC64KeyMap successfully
UserDefaults.42::decode(_:forKey:): Decoded VC64JoyKeyMap1 successfully
UserDefaults.42::decode(_:forKey:): Decoded VC64JoyKeyMap2 successfully
UserDefaults.42::decode(_:forKey:): Decoded VC64ShaderOptionsKey successfully
UserDefaults.42::decode(_:forKey:): Decoded VC64AutoMountAction successfully
UserDefaults.42::decode(_:forKey:): Decoded VC64AutoType successfully
UserDefaults.42::decode(_:forKey:): Decoded VC64AutoTypeText successfully
SIDBridge: Setting clock frequency to 985249
ReSID: Setting clock frequency to 985249 cycles per second.
Drive1: Duration a CPU cycle is 10149 1/10 nsec.
Drive2: Duration a CPU cycle is 10149 1/10 nsec.
ReSID: Emulating SID model MOS8580.
ReSID: Enabling audio filter emulation.
ReSID: Using sampling method SAMPLE_INTERPOLATE.
MyController.434::addListener()
MyController.451::addListener(): Listener is in place
C64: Resetting virtual C64[0x119000000]
C64 memory: Grabbing reset vector from source 2
C64: Setting PC to FCE2
MyController.467::createTimer(): GUI timer is up and running
WindowDelegate.16::windowDidBecomeMain(_:)
WindowDelegate.167::adjustWindowSize()
Animation.194::blendIn(): Blending in...
WindowDelegate.37::windowDidResignMain(_:)
WindowDelegate.16::windowDidBecomeMain(_:)
WindowDelegate.167::adjustWindowSize()
WindowDelegate.37::windowDidResignMain(_:)
WindowDelegate.16::windowDidBecomeMain(_:)
WindowDelegate.167::adjustWindowSize()
Dragged in filename
MyDocument.182::createAttachment(from:): Creating attachment from URL hello.prg.
MyDocument.208::createAttachment(from:ofType:): Read 6571 bytes from file hello.prg.
MyDocument.306::mountAttachment(action:text:): Action = flashFirstFile
MyDocument.318::mountAttachment(action:text:): Auto typing: RUN
WindowDelegate.50::windowWillClose(_:)
MetalView.549::cleanup()
WindowDelegate.37::windowDidResignMain(_:)
MyDocument.539::removeWindowController(_:)
2019-03-29 10:44:21.317315+0000 VirtualC64[95097:1300408] C64Proxy::kill
C64: Destroying virtual C64[0x119000000]
MyDocument.55::init()
UserDefaults.59::registerUserDefaults()
2019-03-29 10:44:26.167061+0000 VirtualC64[95097:1300408] C64Proxy::init
C64: Creating virtual C64[0x119000000]
SIDBridge: Setting clock frequency to 985249
ReSID: Setting clock frequency to 985249 cycles per second.
Drive1: Duration a CPU cycle is 10149 1/10 nsec.
Drive2: Duration a CPU cycle is 10149 1/10 nsec.
C64: Resetting virtual C64[0x119000000]
C64: Setting PC to FCE2
MyDocument.67::makeWindowControllers()
SIDBridge: Changing sample rate from 44100 to 44100
ReSID: Setting sample rate to 44100 samples per second.
FastSID: Setting sample rate to 44100
MetalView.186::awakeFromNib()
MyController.340::awakeFromNib()
AudioEngine.27::init(withSID:)
SIDBridge: Changing sample rate from 44100 to 44100
ReSID: Setting sample rate to 44100 samples per second.
FastSID: Setting sample rate to 44100
MyController.353::windowDidLoad()
GamePad.72::init(manager:vendorID:productID:locationID:)
GamePad.72::init(manager:vendorID:productID:locationID:)
GamePad.72::init(manager:vendorID:productID:locationID:)
GamePadManager.310::restoreFactorySettings()
WindowDelegate.167::adjustWindowSize()
MetalSetup.28::setupMetal()
MetalSetup.44::buildMetal()
MetalSetup.75::buildTextures()
MetalSetup.414::buildPipeline()
UserDefaults.89::loadUserDefaults()
ROMFile: File /Users/thierry/Emulation/CBM/ROMS/basic.901226-01.rom read successfully
ROMFile: File /Users/thierry/Emulation/CBM/ROMS/characters.901225-01.rom read successfully
ROMFile: File /Users/thierry/Emulation/CBM/ROMS/jiffydos-kernal-6.01.rom read successfully
ROMFile: File /Users/thierry/Emulation/CBM/ROMS/jiffydos-1541-II-6.00.rom read successfully
UserDefaults.42::decode(_:forKey:): Decoded VC64KeyMap successfully
UserDefaults.42::decode(_:forKey:): Decoded VC64JoyKeyMap1 successfully
UserDefaults.42::decode(_:forKey:): Decoded VC64JoyKeyMap2 successfully
UserDefaults.42::decode(_:forKey:): Decoded VC64ShaderOptionsKey successfully
UserDefaults.42::decode(_:forKey:): Decoded VC64AutoMountAction successfully
UserDefaults.42::decode(_:forKey:): Decoded VC64AutoType successfully
UserDefaults.42::decode(_:forKey:): Decoded VC64AutoTypeText successfully
SIDBridge: Setting clock frequency to 985249
ReSID: Setting clock frequency to 985249 cycles per second.
Drive1: Duration a CPU cycle is 10149 1/10 nsec.
Drive2: Duration a CPU cycle is 10149 1/10 nsec.
ReSID: Emulating SID model MOS8580.
ReSID: Enabling audio filter emulation.
ReSID: Using sampling method SAMPLE_INTERPOLATE.
MyController.434::addListener()
MyController.451::addListener(): Listener is in place
C64: Resetting virtual C64[0x119000000]
C64 memory: Grabbing reset vector from source 2
C64: Setting PC to FCE2
MyController.467::createTimer(): GUI timer is up and running
WindowDelegate.16::windowDidBecomeMain(_:)
WindowDelegate.167::adjustWindowSize()
Animation.194::blendIn(): Blending in...
Dragged in filename
MyDocument.182::createAttachment(from:): Creating attachment from URL hello.d64.
MyDocument.208::createAttachment(from:ofType:): Read 174848 bytes from file hello.d64.
D64File::D64File()
MyDocument.306::mountAttachment(action:text:): Action = insertIntoDrive8
Drive1: prepareToInsert
Drive1: insertDisk
WindowDelegate.50::windowWillClose(_:)
MetalView.549::cleanup()
WindowDelegate.37::windowDidResignMain(_:)
MyDocument.539::removeWindowController(_:)
2019-03-29 10:44:30.770373+0000 VirtualC64[95097:1300408] C64Proxy::kill
C64: Destroying virtual C64[0x119000000]
MyDocument.55::init()
UserDefaults.59::registerUserDefaults()
2019-03-29 10:44:32.963956+0000 VirtualC64[95097:1300408] C64Proxy::init
C64: Creating virtual C64[0x119000000]
SIDBridge: Setting clock frequency to 985249
ReSID: Setting clock frequency to 985249 cycles per second.
Drive1: Duration a CPU cycle is 10149 1/10 nsec.
Drive2: Duration a CPU cycle is 10149 1/10 nsec.
C64: Resetting virtual C64[0x119000000]
C64: Setting PC to FCE2
MyDocument.67::makeWindowControllers()
SIDBridge: Changing sample rate from 44100 to 44100
ReSID: Setting sample rate to 44100 samples per second.
FastSID: Setting sample rate to 44100
MetalView.186::awakeFromNib()
MyController.340::awakeFromNib()
AudioEngine.27::init(withSID:)
SIDBridge: Changing sample rate from 44100 to 44100
ReSID: Setting sample rate to 44100 samples per second.
FastSID: Setting sample rate to 44100
MyController.353::windowDidLoad()
GamePad.72::init(manager:vendorID:productID:locationID:)
GamePad.72::init(manager:vendorID:productID:locationID:)
GamePad.72::init(manager:vendorID:productID:locationID:)
GamePadManager.310::restoreFactorySettings()
WindowDelegate.167::adjustWindowSize()
MetalSetup.28::setupMetal()
MetalSetup.44::buildMetal()
MetalSetup.75::buildTextures()
MetalSetup.414::buildPipeline()
UserDefaults.89::loadUserDefaults()
ROMFile: File /Users/thierry/Emulation/CBM/ROMS/basic.901226-01.rom read successfully
ROMFile: File /Users/thierry/Emulation/CBM/ROMS/characters.901225-01.rom read successfully
ROMFile: File /Users/thierry/Emulation/CBM/ROMS/jiffydos-kernal-6.01.rom read successfully
ROMFile: File /Users/thierry/Emulation/CBM/ROMS/jiffydos-1541-II-6.00.rom read successfully
UserDefaults.42::decode(_:forKey:): Decoded VC64KeyMap successfully
UserDefaults.42::decode(_:forKey:): Decoded VC64JoyKeyMap1 successfully
UserDefaults.42::decode(_:forKey:): Decoded VC64JoyKeyMap2 successfully
UserDefaults.42::decode(_:forKey:): Decoded VC64ShaderOptionsKey successfully
UserDefaults.42::decode(_:forKey:): Decoded VC64AutoMountAction successfully
UserDefaults.42::decode(_:forKey:): Decoded VC64AutoType successfully
UserDefaults.42::decode(_:forKey:): Decoded VC64AutoTypeText successfully
SIDBridge: Setting clock frequency to 985249
ReSID: Setting clock frequency to 985249 cycles per second.
Drive1: Duration a CPU cycle is 10149 1/10 nsec.
Drive2: Duration a CPU cycle is 10149 1/10 nsec.
ReSID: Emulating SID model MOS8580.
ReSID: Enabling audio filter emulation.
ReSID: Using sampling method SAMPLE_INTERPOLATE.
MyController.434::addListener()
MyController.451::addListener(): Listener is in place
C64: Resetting virtual C64[0x119000000]
C64 memory: Grabbing reset vector from source 2
C64: Setting PC to FCE2
MyController.467::createTimer(): GUI timer is up and running
WindowDelegate.16::windowDidBecomeMain(_:)
WindowDelegate.167::adjustWindowSize()
Animation.194::blendIn(): Blending in...
Dragged in filename
MyDocument.182::createAttachment(from:): Creating attachment from URL hello.d64.
MyDocument.208::createAttachment(from:ofType:): Read 174848 bytes from file hello.d64.
D64File::D64File()
MyDocument.306::mountAttachment(action:text:): Action = insertIntoDrive8
Drive1: prepareToInsert
Drive1: insertDisk
WindowDelegate.50::windowWillClose(_:)
MetalView.549::cleanup()
WindowDelegate.37::windowDidResignMain(_:)
MyDocument.539::removeWindowController(_:)
2019-03-29 10:44:38.703415+0000 VirtualC64[95097:1300408] C64Proxy::kill
C64: Destroying virtual C64[0x119000000]
MyDocument.55::init()
UserDefaults.59::registerUserDefaults()
2019-03-29 10:44:40.471912+0000 VirtualC64[95097:1300408] C64Proxy::init
C64: Creating virtual C64[0x119000000]
SIDBridge: Setting clock frequency to 985249
ReSID: Setting clock frequency to 985249 cycles per second.
Drive1: Duration a CPU cycle is 10149 1/10 nsec.
Drive2: Duration a CPU cycle is 10149 1/10 nsec.
C64: Resetting virtual C64[0x119000000]
C64: Setting PC to FCE2
MyDocument.67::makeWindowControllers()
SIDBridge: Changing sample rate from 44100 to 44100
ReSID: Setting sample rate to 44100 samples per second.
FastSID: Setting sample rate to 44100
MetalView.186::awakeFromNib()
MyController.340::awakeFromNib()
AudioEngine.27::init(withSID:)
SIDBridge: Changing sample rate from 44100 to 44100
ReSID: Setting sample rate to 44100 samples per second.
FastSID: Setting sample rate to 44100
MyController.353::windowDidLoad()
GamePad.72::init(manager:vendorID:productID:locationID:)
GamePad.72::init(manager:vendorID:productID:locationID:)
GamePad.72::init(manager:vendorID:productID:locationID:)
GamePadManager.310::restoreFactorySettings()
WindowDelegate.167::adjustWindowSize()
MetalSetup.28::setupMetal()
MetalSetup.44::buildMetal()
MetalSetup.75::buildTextures()
MetalSetup.414::buildPipeline()
UserDefaults.89::loadUserDefaults()
ROMFile: File /Users/thierry/Emulation/CBM/ROMS/basic.901226-01.rom read successfully
ROMFile: File /Users/thierry/Emulation/CBM/ROMS/characters.901225-01.rom read successfully
ROMFile: File /Users/thierry/Emulation/CBM/ROMS/jiffydos-kernal-6.01.rom read successfully
ROMFile: File /Users/thierry/Emulation/CBM/ROMS/jiffydos-1541-II-6.00.rom read successfully
UserDefaults.42::decode(_:forKey:): Decoded VC64KeyMap successfully
UserDefaults.42::decode(_:forKey:): Decoded VC64JoyKeyMap1 successfully
UserDefaults.42::decode(_:forKey:): Decoded VC64JoyKeyMap2 successfully
UserDefaults.42::decode(_:forKey:): Decoded VC64ShaderOptionsKey successfully
UserDefaults.42::decode(_:forKey:): Decoded VC64AutoMountAction successfully
UserDefaults.42::decode(_:forKey:): Decoded VC64AutoType successfully
UserDefaults.42::decode(_:forKey:): Decoded VC64AutoTypeText successfully
SIDBridge: Setting clock frequency to 985249
ReSID: Setting clock frequency to 985249 cycles per second.
Drive1: Duration a CPU cycle is 10149 1/10 nsec.
Drive2: Duration a CPU cycle is 10149 1/10 nsec.
ReSID: Emulating SID model MOS8580.
ReSID: Enabling audio filter emulation.
ReSID: Using sampling method SAMPLE_INTERPOLATE.
MyController.434::addListener()
MyController.451::addListener(): Listener is in place
C64: Resetting virtual C64[0x119000000]
C64 memory: Grabbing reset vector from source 2
C64: Setting PC to FCE2
MyController.467::createTimer(): GUI timer is up and running
WindowDelegate.16::windowDidBecomeMain(_:)
WindowDelegate.167::adjustWindowSize()
Animation.194::blendIn(): Blending in...
Dragged in filename
MyDocument.182::createAttachment(from:): Creating attachment from URL hello.prg.
MyDocument.208::createAttachment(from:ofType:): Read 6571 bytes from file hello.prg.
MyDocument.306::mountAttachment(action:text:): Action = flashFirstFile
MyDocument.318::mountAttachment(action:text:): Auto typing: RUN
Dragged in filename
MyDocument.182::createAttachment(from:): Creating attachment from URL hello.prg.
MyDocument.208::createAttachment(from:ofType:): Read 6571 bytes from file hello.prg.
MyDocument.306::mountAttachment(action:text:): Action = flashFirstFile
MyDocument.318::mountAttachment(action:text:): Auto typing: RUN
Animation.142::rotateBack(): Rotating back...
C64: Resetting virtual C64[0x119000000]
C64 memory: Grabbing reset vector from source 2
C64: Setting PC to FCE2
Dragged in filename
MyDocument.182::createAttachment(from:): Creating attachment from URL hello.prg.
MyDocument.208::createAttachment(from:ofType:): Read 6571 bytes from file hello.prg.
MyDocument.306::mountAttachment(action:text:): Action = flashFirstFile
MyDocument.318::mountAttachment(action:text:): Auto typing: RUN
Dragged in filename
WindowDelegate.37::windowDidResignMain(_:)
MyDocument.55::init()
UserDefaults.59::registerUserDefaults()
2019-03-29 10:45:12.237356+0000 VirtualC64[95097:1300408] C64Proxy::init
C64: Creating virtual C64[0x128914000]
SIDBridge: Setting clock frequency to 985249
ReSID: Setting clock frequency to 985249 cycles per second.
Drive1: Duration a CPU cycle is 10149 1/10 nsec.
Drive2: Duration a CPU cycle is 10149 1/10 nsec.
C64: Resetting virtual C64[0x128914000]
C64: Setting PC to FCE2
MyDocument.182::createAttachment(from:): Creating attachment from URL hello.prg.
MyDocument.208::createAttachment(from:ofType:): Read 6571 bytes from file hello.prg.
MyDocument.67::makeWindowControllers()
MetalView.186::awakeFromNib()
MyController.340::awakeFromNib()
AudioEngine.27::init(withSID:)
SIDBridge: Changing sample rate from 44100 to 44100
ReSID: Setting sample rate to 44100 samples per second.
FastSID: Setting sample rate to 44100
MyController.353::windowDidLoad()
GamePad.72::init(manager:vendorID:productID:locationID:)
GamePad.72::init(manager:vendorID:productID:locationID:)
GamePad.72::init(manager:vendorID:productID:locationID:)
GamePadManager.310::restoreFactorySettings()
WindowDelegate.167::adjustWindowSize()
MetalSetup.28::setupMetal()
MetalSetup.44::buildMetal()
MetalSetup.75::buildTextures()
MetalSetup.414::buildPipeline()
UserDefaults.89::loadUserDefaults()
ROMFile: File /Users/thierry/Emulation/CBM/ROMS/basic.901226-01.rom read successfully
ROMFile: File /Users/thierry/Emulation/CBM/ROMS/characters.901225-01.rom read successfully
ROMFile: File /Users/thierry/Emulation/CBM/ROMS/jiffydos-kernal-6.01.rom read successfully
ROMFile: File /Users/thierry/Emulation/CBM/ROMS/jiffydos-1541-II-6.00.rom read successfully
UserDefaults.42::decode(_:forKey:): Decoded VC64KeyMap successfully
UserDefaults.42::decode(_:forKey:): Decoded VC64JoyKeyMap1 successfully
UserDefaults.42::decode(_:forKey:): Decoded VC64JoyKeyMap2 successfully
UserDefaults.42::decode(_:forKey:): Decoded VC64ShaderOptionsKey successfully
UserDefaults.42::decode(_:forKey:): Decoded VC64AutoMountAction successfully
UserDefaults.42::decode(_:forKey:): Decoded VC64AutoType successfully
UserDefaults.42::decode(_:forKey:): Decoded VC64AutoTypeText successfully
SIDBridge: Setting clock frequency to 985249
ReSID: Setting clock frequency to 985249 cycles per second.
Drive1: Duration a CPU cycle is 10149 1/10 nsec.
Drive2: Duration a CPU cycle is 10149 1/10 nsec.
ReSID: Emulating SID model MOS8580.
ReSID: Enabling audio filter emulation.
ReSID: Using sampling method SAMPLE_INTERPOLATE.
MyController.434::addListener()
MyController.451::addListener(): Listener is in place
C64: Resetting virtual C64[0x128914000]
C64 memory: Grabbing reset vector from source 2
C64: Setting PC to FCE2
MyController.467::createTimer(): GUI timer is up and running
Animation.194::blendIn(): Blending in...
WindowDelegate.16::windowDidBecomeMain(_:)
WindowDelegate.167::adjustWindowSize()
MyDocument.306::mountAttachment(action:text:): Action = flashFirstFile
MyDocument.318::mountAttachment(action:text:): Auto typing: RUN
WindowDelegate.37::windowDidResignMain(_:)
MyDocument.55::init()
UserDefaults.59::registerUserDefaults()
2019-03-29 10:45:17.864287+0000 VirtualC64[95097:1300408] C64Proxy::init
C64: Creating virtual C64[0x137060000]
SIDBridge: Setting clock frequency to 985249
ReSID: Setting clock frequency to 985249 cycles per second.
Drive1: Duration a CPU cycle is 10149 1/10 nsec.
Drive2: Duration a CPU cycle is 10149 1/10 nsec.
C64: Resetting virtual C64[0x137060000]
C64: Setting PC to FCE2
MyDocument.182::createAttachment(from:): Creating attachment from URL hello.prg.
MyDocument.208::createAttachment(from:ofType:): Read 6571 bytes from file hello.prg.
MyDocument.67::makeWindowControllers()
MetalView.186::awakeFromNib()
MyController.340::awakeFromNib()
AudioEngine.27::init(withSID:)
SIDBridge: Changing sample rate from 44100 to 44100
ReSID: Setting sample rate to 44100 samples per second.
FastSID: Setting sample rate to 44100
MyController.353::windowDidLoad()
GamePad.72::init(manager:vendorID:productID:locationID:)
GamePad.72::init(manager:vendorID:productID:locationID:)
GamePad.72::init(manager:vendorID:productID:locationID:)
GamePadManager.310::restoreFactorySettings()
WindowDelegate.167::adjustWindowSize()
MetalSetup.28::setupMetal()
MetalSetup.44::buildMetal()
MetalSetup.75::buildTextures()
MetalSetup.414::buildPipeline()
UserDefaults.89::loadUserDefaults()
ROMFile: File /Users/thierry/Emulation/CBM/ROMS/basic.901226-01.rom read successfully
ROMFile: File /Users/thierry/Emulation/CBM/ROMS/characters.901225-01.rom read successfully
ROMFile: File /Users/thierry/Emulation/CBM/ROMS/jiffydos-kernal-6.01.rom read successfully
ROMFile: File /Users/thierry/Emulation/CBM/ROMS/jiffydos-1541-II-6.00.rom read successfully
UserDefaults.42::decode(_:forKey:): Decoded VC64KeyMap successfully
UserDefaults.42::decode(_:forKey:): Decoded VC64JoyKeyMap1 successfully
UserDefaults.42::decode(_:forKey:): Decoded VC64JoyKeyMap2 successfully
UserDefaults.42::decode(_:forKey:): Decoded VC64ShaderOptionsKey successfully
UserDefaults.42::decode(_:forKey:): Decoded VC64AutoMountAction successfully
UserDefaults.42::decode(_:forKey:): Decoded VC64AutoType successfully
UserDefaults.42::decode(_:forKey:): Decoded VC64AutoTypeText successfully
SIDBridge: Setting clock frequency to 985249
ReSID: Setting clock frequency to 985249 cycles per second.
Drive1: Duration a CPU cycle is 10149 1/10 nsec.
Drive2: Duration a CPU cycle is 10149 1/10 nsec.
ReSID: Emulating SID model MOS8580.
ReSID: Enabling audio filter emulation.
ReSID: Using sampling method SAMPLE_INTERPOLATE.
MyController.434::addListener()
MyController.451::addListener(): Listener is in place
C64: Resetting virtual C64[0x137060000]
C64 memory: Grabbing reset vector from source 2
C64: Setting PC to FCE2
MyController.467::createTimer(): GUI timer is up and running
Animation.194::blendIn(): Blending in...
WindowDelegate.16::windowDidBecomeMain(_:)
WindowDelegate.167::adjustWindowSize()
WindowDelegate.50::windowWillClose(_:)
MetalView.549::cleanup()
WindowDelegate.37::windowDidResignMain(_:)
WindowDelegate.16::windowDidBecomeMain(_:)
WindowDelegate.167::adjustWindowSize()
MyDocument.539::removeWindowController(_:)
2019-03-29 10:45:19.567683+0000 VirtualC64[95097:1300408] C64Proxy::kill
C64: Destroying virtual C64[0x137060000]
MyDocument.306::mountAttachment(action:text:): Action = flashFirstFile
Fatal error: Unexpectedly found nil while unwrapping an Optional value
2019-03-29 10:45:20.321082+0000 VirtualC64[95097:1300408] Fatal error: Unexpectedly found nil while unwrapping an Optional value

image

the action I do is in loop

  1. open hello.prg
  2. close tab asap

OK, thanks!!!

If I understand it correctly, you are closing the window just after opening a file. This would make sense: The highlighted Swift code crashes, because windowForSheet is assumed to be != NULL. It seems like I have to replace all statements of the form

windowForSheet!. ...

by a guarded statement of the form

if let sheet = windowForSheet { sheet. ... }

You are correct. Now the other exception is rarer. I should not have put it in the same issue. I will track it the same way and If I can identify the problem with XCode I will raise the issue with debugging details.

HI Dirk,

Same error but the problem occurs almost immediately with the following scenario
open app.prg
open app.prg
close last window

0 de.dirkwhoffmann.VirtualC64 0x000000010c45b55e MyDocument.flashAttachmentIntoMemory() + 254 (MyDocument.swift:400)
1 de.dirkwhoffmann.VirtualC64 0x000000010c45af0b MyDocument.mountAttachment(action:text:) + 283 (MyDocument.swift:311)
2 de.dirkwhoffmann.VirtualC64 0x000000010c45edbd partial apply for closure #1 in MyDocument.mountAttachment() + 109
3 de.dirkwhoffmann.VirtualC64 0x000000010c47aa60 thunk for @escaping @callee_guaranteed () -> () + 32
4 libdispatch.dylib 0x00007fff6411763d _dispatch_client_callout + 8
5 libdispatch.dylib 0x00007fff64119de6 _dispatch_continuation_pop + 414
6 libdispatch.dylib 0x00007fff64128f42 _dispatch_source_invoke + 2056
7 libdispatch.dylib 0x00007fff6412254b _dispatch_main_queue_callback_4CF + 813

Hmm, strange enough. I don't manage to reproduce it 鈽癸笍.

In 3.3.1, line 400 is

   if let archive = attachment as? AnyArchiveProxy {

which should be super safe now.

Are you able to gather an Xcode screenshot like in your above post?

will do further testing tonight.

So far so good on the prg open loop. I was missing part of your delivery, recompiled and tested continuously for 30 mins previously crashing scenarios without a problem.
repeated open and close of prg seems to work fine.

Now I did an alternative test opening/closing a d64 and get a regular crash with an open close loop of a disk image (I have no run action attached to opening a d64. the close happening before the disk noise signal. If I wait after the disk being mounted, i.e. after the disk noise, it does not seem to fail ever.

image

Thread 0 Crashed:: Dispatch queue: com.apple.main-thread
0   de.dirkwhoffmann.VirtualC64     0x0000000102a1d1f4 MyDocument.proceedWithUnexportedDisk(drive:) + 340 (Alerts.swift:85)
1   de.dirkwhoffmann.VirtualC64     0x0000000102a1fff9 MyDocument.mountAttachmentAsDisk(drive:) + 89 (MyDocument.swift:374)
2   de.dirkwhoffmann.VirtualC64     0x0000000102a1fcd8 MyDocument.mountAttachment(action:text:) + 328
3   de.dirkwhoffmann.VirtualC64     0x0000000102a23b5d partial apply for closure #1 in MyDocument.mountAttachment() + 109
4   de.dirkwhoffmann.VirtualC64     0x0000000102a3f800 thunk for @escaping @callee_guaranteed () -> () + 32

Do you want me to create a different issue?

In any cases the details under debugger:

2019-05-01 19:16:50.861635+0100 VirtualC64[21144:15445298] C64Proxy::kill
C64: Destroying virtual C64[0x122300000]
MyDocument.306::mountAttachment(action:text:): Action = insertIntoDrive8
Fatal error: Unexpectedly found nil while unwrapping an Optional value
2019-05-01 19:16:51.365325+0100 VirtualC64[21144:15445298] Fatal error: Unexpectedly found nil while unwrapping an Optional value

image

Last complement, without tracking the code logic, the following setup is probably of importance:

image

Ok, I am starting to automate what I can using osascript. I found another one
the script is just a simple open/close of a document (opclose-fast.applescript)
the 2 other scenarios repeated in loop from shell are opclose-prg.applescript: working and opclose-d64.applescript: crashing.

various-tests.tar.gz

I will explore the automation to create a couple of other test scenarios (opening d64, tape, prg), closing, parallel/serialized if it helps you.

Thread 0 Crashed:: Dispatch queue: com.apple.main-thread
0   de.dirkwhoffmann.VirtualC64     0x000000010a9824c2 -[C64Proxy alwaysWarp] + 18 (C64.h:441)
1   de.dirkwhoffmann.VirtualC64     0x000000010a9de6a4 specialized MyController.processMessage(_:) + 100 (MyController.swift:620)
2   de.dirkwhoffmann.VirtualC64     0x000000010a9dfcdf partial apply for closure #1 in closure #1 in MyController.addListener() + 31
3   de.dirkwhoffmann.VirtualC64     0x000000010aa3a800 thunk for @escaping @callee_guaranteed () -> () + 32
4   libdispatch.dylib               0x00007fff641165f8 _dispatch_call_block_and_release + 12
5   libdispatch.dylib               0x00007fff6411763d _dispatch_client_callout + 8
6   libdispatch.dylib               0x00007fff6412268d _dispatch_main_queue_callback_4CF + 1135

image

MetalView.549::cleanup()
WindowDelegate.33::windowDidResignMain(_:)
MyDocument.543::removeWindowController(_:)
2019-05-01 20:06:28.176109+0100 VirtualC64[13411:15691343] C64Proxy::kill
C64: Destroying virtual C64[0x119500000]

Great! Using your script, I can reproduce the bug. I'll try to come up with a solution...

I did find the problem, but I don't have a solution yet.

The issue here is that some actions are scheduled asynchronously (such as the call to processMessage() when the GUI receives a notification from the emulator). When the window gets closes, these messages still get processed. Your specific test-case (immediately shutting down the window) is likely to fail especially of this "feature":

    // Check if the emulator has just been startet. In that case, we have
    // to wait until the Kernal boot routine has been executed. Otherwise,
    // the C64 would ignore everything we are doing here.
    let delay = (c64.cpu.cycle() < 3000000) ? 2.0 : 0.0

    // Execute asynchronously ...
    DispatchQueue.main.asyncAfter(deadline: .now() + delay, execute: {
        self.mountAttachment(action: action, text: autoTypeText)
    })

What I need to do is to keep the emulator instance alive until the window and its associated document and window controller really get deleted. Right now, I'm killing the emulator in method

NSDocument::removeWindowController(_ windowController: NSWindowController)
{
    super.removeWindowController(windowController)
    c64.kill()     
}

which has turned out to be too early. I need to find a way to postpone the deletion, but I didn't find one yet.

I found a solution for postponing emulator deletion. It is now killed in MyDocument::deinit which is the Swift destructor. Embarrassingly, I just learned today that deconstructors exist in Swift 馃檮. Of course, the deconstructor is the natural place for releasing objects.

Good news: We don't have to override removeWindowController any more. Hooray!

Bad news: The emulator still crashes (at a later point) 馃槵:

Screenshot 2019-05-02 at 21 31 55

I thought I can rely on the document being present all the time (which I just learned is wrong 馃檮).

Cool, I am progressing on a set of other tests as well. Is there a way to defect events like accessing the content of the screen?

I've just uploaded beta 2 which doesn't crash any more on my machine:

http://dirkwhoffmann.de/virtualc64/VirtualC64_3.3.1b2.zip

Can you give it a try?

Is there a way to defect events like accessing the content of the screen?

What exactly do you want to achieve? 馃

Version 3.3.1 is now available via the update server.
Please reopen if the problem occurs again.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

Alessandro1970 picture Alessandro1970  路  3Comments

bluecursor picture bluecursor  路  5Comments

dirkwhoffmann picture dirkwhoffmann  路  4Comments

puleyo picture puleyo  路  6Comments

dirkwhoffmann picture dirkwhoffmann  路  5Comments