NSView scrollWheel crash

Hello,


I am not sure where to put this but here it is. Every once in a great while, my app will crash--it just quits and disappears. The crash report is always the same. A snippit is below. It always happens when I am scrolling up and down in an open document. It seems like this is something in the Appkit and is out of my control. But there is always the possibility that this is a result of something I am doing although I can't figure out what it is. As I mentioned, it is very infrequent--maybe once a month? Any ideas?


Application Specific Information:

objc_msgSend() selector name: scrollView:scrollWheelWithEvent:


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

0 libobjc.A.dylib 0x00007fff762bc69d objc_msgSend + 29

1 com.apple.AppKit 0x00007fff49366033 forwardMethod + 211

2 com.apple.AppKit 0x00007fff49414bb2 -[NSView scrollWheel:] + 341

3 com.apple.AppKit 0x00007fff49366033 forwardMethod + 211

4 com.apple.AppKit 0x00007fff49414bb2 -[NSView scrollWheel:] + 341

5 com.apple.AppKit 0x00007fff49366033 forwardMethod + 211

6 com.apple.AppKit 0x00007fff49414bb2 -[NSView scrollWheel:] + 341

7 com.apple.AppKit 0x00007fff49366033 forwardMethod + 211

8 com.apple.AppKit 0x00007fff49414bb2 -[NSView scrollWheel:] + 341

9 com.apple.AppKit 0x00007fff49366033 forwardMethod + 211

10 com.apple.AppKit 0x00007fff49414bb2 -[NSView scrollWheel:] + 341

11 com.apple.AppKit 0x00007fff492a2367 -[NSWindow(NSEventRouting) _reallySendEvent:isDelayedEvent:] + 6840

12 com.apple.AppKit 0x00007fff492a0667 -[NSWindow(NSEventRouting) sendEvent:] + 478

13 com.apple.AppKit 0x00007fff49140626 -[NSApplication(NSEvent) sendEvent:] + 2310

14 com.apple.AppKit 0x00007fff4912e5e0 -[NSApplication run] + 755

15 com.apple.AppKit 0x00007fff4911dae8 NSApplicationMain + 777

16 libdyld.dylib 0x00007fff77a983d5 start + 1

Could you show the code where you scroll the document (if any)


Did you override

func scrollWheel(with: NSEvent)


Did you run sanitizers, zombie detection … Could well be from time to time, an object is deallocated and you still try to access.

I don't override any of the scrolling functions nor do I subclass the scrollView. I have been using this code for about 5 years and haven't had this issue until the past few months. There really isn't any code to show that is relevant.

Did you try to instrument code to detect memory issues ?

Could you post the actual reason for the crash, shown in the crash report above the "Application Specific Information"? This is the block of information that show the exception type, the termination reason, etc.

Yes I can. I didn't want to post too much spam in the original thread.

I changed the name to MyApp--seriously, this isn't the real name of the app!


Process: MyApp [742]

Path: /Applications/MyApp.app/Contents/MacOS/MyApp

Identifier: com.xxxxxxxx.xxxxxxx

Version: 3.7.5 (655)

Code Type: X86-64 (Native)

Parent Process: ??? [1]

Responsible: MyApp [742]

User ID: 501



Date/Time: 2020-02-20 07:26:42.828 -0600

OS Version: Mac OS X 10.14.6 (18G95)

Report Version: 12

Anonymous UUID: BEC7CDC5-D62B-AA47-E79D-00333BADAC10



Sleep/Wake UUID: 3EAF2810-813F-417F-88AA-A2B2F9A6C887



Time Awake Since Boot: 2100 seconds

Time Since Wake: 650 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 0x00004411b0845158

Exception Note: EXC_CORPSE_NOTIFY



Termination Signal: Segmentation fault: 11

Termination Reason: Namespace SIGNAL, Code 0xb

Terminating Process: exc handler [742]



VM Regions Near 0x4411b0845158:

MALLOC_LARGE_REUSABLE 00000001189db000-00000001199db000 [ 16.0M] rw-/rwx SM=PRV

-->

MALLOC_NANO 0000600000000000-0000600008000000 [128.0M] rw-/rwx SM=PRV



Application Specific Information:

objc_msgSend() selector name: scrollView:scrollWheelWithEvent:





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

0 libobjc.A.dylib 0x00007fff762bc69d objc_msgSend + 29

1 com.apple.AppKit 0x00007fff49366033 forwardMethod + 211

2 com.apple.AppKit 0x00007fff49414bb2 -[NSView scrollWheel:] + 341

3 com.apple.AppKit 0x00007fff49366033 forwardMethod + 211

4 com.apple.AppKit 0x00007fff49414bb2 -[NSView scrollWheel:] + 341

5 com.apple.AppKit 0x00007fff49366033 forwardMethod + 211

6 com.apple.AppKit 0x00007fff49414bb2 -[NSView scrollWheel:] + 341

7 com.apple.AppKit 0x00007fff49366033 forwardMethod + 211

8 com.apple.AppKit 0x00007fff49414bb2 -[NSView scrollWheel:] + 341

9 com.apple.AppKit 0x00007fff49366033 forwardMethod + 211

10 com.apple.AppKit 0x00007fff49414bb2 -[NSView scrollWheel:] + 341

11 com.apple.AppKit 0x00007fff492a2367 -[NSWindow(NSEventRouting) _reallySendEvent:isDelayedEvent:] + 6840

12 com.apple.AppKit 0x00007fff492a0667 -[NSWindow(NSEventRouting) sendEvent:] + 478

13 com.apple.AppKit 0x00007fff49140626 -[NSApplication(NSEvent) sendEvent:] + 2310

14 com.apple.AppKit 0x00007fff4912e5e0 -[NSApplication run] + 755

15 com.apple.AppKit 0x00007fff4911dae8 NSApplicationMain + 777

16 libdyld.dylib 0x00007fff77a983d5 start + 1

I am not detecting any memory issues.

It looks like this crashed trying to referenced memory in a memory region that's been freed. It also looks like event handling is trying to forward the scroll wheel event up the event chain. Putting those things together, it looks like you have a view that's been deallocated too early, but there's no information here to help find out why or what.


Can you relate this to something that was being done at the time of the crash that would deallocate view, for example scrolling a table view, or performing a segue, etc?

The crash is very infrequent--say maybe once or twice a month at most.


The app is a text editor, NSDocument based. I am doing multiple pages similar to the page view mode in the TextEdit sample code--multiple textViews put in an NSView that is the overall "container" that holds all the textViews. That NSView is in a scrollview. This scrollView is created in interface builder and is there for the life of the app. Everything contained in the scrollView is created programmatically. The NSView that it is scrolling is created once and exists for the life of the app. The textViews get added or removed as needed.


The only thing I am doing when it crashes is slowly scrolling a document up and down. For example, if I have a 20 page document and I go in it to edit, make changes, etc. So I open it and slowly scroll up and down to try to remember what I already did (memory isn't what it used to be). It is just a leisurely scrolling and all of a sudden, the app just crashes and disappears and I get the crash report. But as I said, it is very infrequent. I have thought about this and I can't point my finger at what could be causing it. During this event, my app isn't doing anything like adding or removing pages or stuff like that. It is just scrolling an existing NSView that contains what I said above.


Thank you for your help.

I've got the same issue in our app. We get infrequent crashes in scrollWheelWithEvent and we have absolutely no idea how to prevent them.
NSView scrollWheel crash
 
 
Q