Xcode debugger hangs entire system - xcode

I am trying to resolve a Bonjour network service, and there is a bug in my netServiceDidResolveAddress: handler, a null reference exception. When I run the app, it hits the bug, and Xcode drops into the debugger, showing the offending line and "Thread 1: Program received signal: EXC_BAD_ACCESS". All fine.
But when it does this, my entire system hangs. Not just Xcode, but the entire OS X UI is frozen. The mouse moves, and music and other background tasks seem to continue, but the UI is completely unresponsive. The only way out is a hard reboot of the entire system. Yikes.
I do a fair amount of low-level programming and this is happening more often than I'd like. I've seen the other questions here about Xcode itself freezing on breakpoints and exceptions but nothing about a full system hang.
Has anyone else encountered this? Any suggestions on recovering (or avoiding the issue entirely)?

Related

App windows on MAC regularly gets swiftly and temporarily grayed out

I am trying to troubleshoot some error that is causing any window on any app to quickly get grayed out for a dussin milliseconds, and at times get grayed out without getting "clicked back" again. I don't know if the issue lies in the cursor since it happens regardless of the current cursor location. It happens at least five times a day, and every time it happens it is very distracting.
I thought this could be caused by the trackpad clicking it out by itself since I've had issues with the trackpad a while back. But that doesn't make any sense since the location of the cursor is unaffected.
I have tried chrome, and other mac apps, but the error has persisted.
I have also tried full-screen mode on youtube (not browser full screen) but the same thing there.
I don't know if this could be relevant, but I have coded python a tiny bit although not more than installing a few packages. Though I coded python after this error started.
I want whatever error that causes app windows to get "grayed out" to be fixed.
Macos 10.15.5 Catalina

Macbook pro M1 max and MATLAB GUI problem

All the functions starting with ui (uigetfile, uigetdir, etc...) fail to work (and return 0). They do not even pop up a Window to select files.
This happened on OSX Monterey 12.3 with MATLAB 2019b, 2020b, 2021b, 2022b.
I realized that when the MATLAB process hangs after a ui command, a new process is created for analytics and improvement. And this process apparently crashed. I tried to kill it but it did not help. I tried to disable in the preferences > Security > Privacy tab but was not able to (the GUI was not populating).
Eventually I rebooted and was able to disable Analytics and Improvements. After that MATLAB behaved fine.
Sorry you had experienced a problem.
The UI functions in MATLAB display native macOS open/save panels - native open/save panels run out-of-process and are controlled by various system services.
Therefore, if either the QuickLook or openAndSavePanel service crashed before the panel could start (or finish) displaying, instead of a crash, you may see nothing happening. It sounds like this is probably what happened.
If that's the case, this issue has nothing to do with analytics, as macOS analytics only come into play once something crashed. Rebooting the machine is likely the thing that made the issue go away, not the disabling of analytics.
To find the root cause of the issue, the best bet is to contact MathWorks tech support and provide diagnostics, such as unified system logs, spindumps, spotlight diagnostics, quicklook database cache, native crash reports, etc.
I hope this was helpful.

Windbg break-in takes very long time

I want to capture a stacktrace of an application which sometimes stops responding for few minutes.
When the application stops responding, the windows desktop also stops responding to mouse clicks, although some other already running applications are working fine at that time (for example windbg works fine, ProcessExplorer refreshes its screen, but does not respond to mouse events).
While the application is non responsive, it is actually taking about 80% of one CPU core. That is why I would like to get a stacktrace.
The misbehaving application usually takes about 2-3 minutes to do its strange job or if Ctrl+Esc is pressed it becomes responsive immediately (and the start menu opens of course...)
I have WinDbg attached to the misbehaving application and when I issue the Break command, the break-in does not happen until the application starts to respond again.
From what I understand the break-in actually creates a remote thread which pretty soon calls DbgBreakPoint.
What could be preventing debugger's thread from executing?
EDIT:
First of all thanks for your help!
I was also thinking that this might be caused by a bad device driver or something that installs a system wide hook somewhere.
I was thinking to enable kernel debugging and get a stack trace from the kernel for the offending thread or enable manual bluescreen trigger to produce a dump and look at that afterwards.
Process Explorer and Process Monitor does not reveal anything interesting. They also become unusable when the bug is triggered (updating their windows but not responsive to mouse or keyboard).
EDIT2:
Background info:
App uses QT, OpenGL and also DirectSound and runs on Windows 7 SP1 x64
I am currently suspecting something with the graphics part.
The strange thing is that if a system-wide lock is taken (like GDI Lock), this would prevent drawing of other Windows, but that does not happen. WinDbg on same machine works fine. ProcessExplorer updates but does not receive mouse clicks, Desktop updates but no mouse clicks.
I currently have a kernel debugger attached...
EDIT3
ETW was most useful for debugging. It turns out that Qt's main event processing loop goes crazy. PeekMessage and MsgWaitForMultipleObjectsEx (with 0 timeout) gets called in a tight loop. That is where the high CPU usage comes from.
It looks like the App is generating/getting loads of messages at that time. But it is not easy to see what the messages are (or I don't know how to access function parameters in ETW). Using a debugger also does not help much but, with a breakpoint in the QT's event loop leads me to believe that WM_TIMER messages are the culprit.
Given that the desktop also misbehaves during this time, it sounds like your app isn't necessarily misbehaving but merely aggravating a bug elsewhere (e.g., in a device driver or some crummy anti-malware code that has injected itself into other processes). Stack traces from your app may or may not be very revealing.
If the problem is easily reproducible, I'd set a breakpoint somewhere in the "middle" of the app and see if the problem happens before or after that. Then move the breakpoint until you find the last instruction your app executes before things go bonkers. Figuring out what your app does that triggers this behavior may give a clue as what's going on.
Another option is to try using some system-wide debugging tools. First, I'd peak in the Event Viewer to see if there are suspicious error or warning events posting in proximity to the moment the machine goes haywire. Then I'd try a tool like Sysinternal's Process Monitor or Process Explorer to get a better view of what's happening. You might also try ETW to capture a system-wide trace of what's happening on the system that you can study after the fact. (ETW can be hard to use, so check out Bruce Dawson's UIforETW.)
Use ETW to find the cause. Install the Windows Performance Toolkit (part of the Win10 v1511 SDK: https://go.microsoft.com/fwlink/p/?LinkID=698771 which is the last version that works in Win7), run WPRUI.exe, select CPU Usage and click on Start.
After you captured the hang, click on Save. Wait until WPRUI is finished, open the ETL in WPA, setup and load debug symbols in WPA.
Drag & Drop the CPU Usage (Precise) graph to analyse pane and look for WAIT (µs) max for your process to see that long hang and expand the stack to see where it happens.

Actions needed for app when waking from sleep on OSX

I have a graphics application that occasionally displays incorrectly after a sleep / wake cycle.
I'm wondering if there is something I should do on the Sleep or Wake events. I'm capturing these events already, because I hide the cursor in the app, and when the app wakes the cursor appears and has to be re-hidden. I'm creating my images with [[NSBitmapImageRep alloc ]initWithBitmapDataPlanes:outplanes, doing lots of bit manipulation on multiple images. I display the image full screen. Xcode 7.1, OSX 10.10
The error I get is a shimmering on the display as if my merge routines are using the wrong data.
I was assuming the sleep took a snapshot of all my data, including whatever is on the stack? It's hard to reproduce the problem, but my App is going to be running every day in a public space and uses the scheduler to sleep each night and autowake in the morning.
Should I reinitialise all my variables on a wake?
I can't see anything on the apple docs about actions you should take on these events.
It should not be necessary to worry about this. If it is, that is likely to be either a bug in your app, or a bug in Apple's code. Indeed, the cursor issue you mention sounds like a bug to me, and you should log a bug in Apple's bug reporter about that. Sleep/wake should be entirely transparent for apps that don't have a specific reason to care. You will need to try to pin down the issue you are seeing, somehow, and diagnose it.

directx 11 c++ application in vs 2012 -- full screen crashes after running for a while

Win7 Directx 11 with VS 2012 -- When I let my app run in full screen on my development computer, eventually, the program exits full screen back to windowed, all by itself, and pops up a dialog telling me windows resources are running low. The dialog tells me something about turning off interactive themes or something to that end. When I run the program in release mode on one of our client machines, the app runs fine, does everything it should, but after a while, instead of popping up the dialog about windows resources, I get an exception window with exception 0x40000015 as the error. This only happens if I am in full screen, windowed, it never crashes. Event Viewer shows nothing at all about the crash. Any thoughts?
Thanks in advance. Basically what my app is, is a wrapper graphics library. When it says I am using all the resources, my resource monitor shows that I never went above 20% of memory and the cpu never went above 14%. The 0x40000015 error number is rather general and doesn't exactly point me in any real direction.
This is not related to trying to exit an app in full screen, as that I have the code required to prevent the exception related to that problem.
R
It turned out to be a component issue on the target platform. The ReportLiveDeviceObjects info was helpful and will continue to help down the line.

Resources