I have an error occurring in the machine code for a release that I wrote [duplicate] - objective-c

I've got an app that gets information from a SOAP web service and I want to display the results in a UITableView.
I had a previous version of this app and I'm creating a new version to basically clean things up and get rid of a bunch of legacy code that's deprecated and no longer used.
In the previous version, this worked well. In the new version, not so much.
Basically, the current scenario is returning 3 strings that I'm trying to use as the basis for the data in my UITableView.
I'm struggling with this issue because it's so stinkin' hard to track down EXC_BAD_ACCESS errors!
(Parenthetically, if someone has a way to make the debug experience more like Visual Studio, I'd love to hear it! It's so frustrating to not have any idea which line caused the error, and also to not be able to look through my local variables at the time of the crash to see what's what. I've already added in the exception breakpoint, but that doesn't seem to do much.)
Anyway, the line that's causing the error APPEARS to be:
return [[self Libraries] count];
It occurs in tableView:numberOfRowsInSection:.
The error message I get APPEARS to reference a string that should be stored in the NSMutableArray [self Libraries].
What's going on here?
I'm using ARC, so shouldn't all of my memory management be correctly handled?
I don't have any manual release statements in my code ANYWHERE!
Please help me fix this!

Set NSZombieEnabled, MallocStackLogging, and guard malloc in the debugger. Then, when your App crashes, type this in the gdb console:
(gdb) info malloc-history 0x543216
Replace 0x543216 with the address of the object that caused the crash, and you will get a much more useful stack trace and it should help you pinpoint the exact line in your code that is causing the problem.
See this article for more detailed instructions.

ARC relies on the Apple standard/recommended naming practices. Check that you are not violating any of them.
Just for starters, if "Libraries" is an instance there are are naming issues.

OK, so I feel a little bit silly, but I've got two production machines. On one of them, I had installed a copy of Xcode 4.2 beta alongside the final, production copy. I forgot to uninstall the beta copy and was using it to run my code. As soon as I cleared that up and ran my code against the final, released Xcode 4.2, all works fine again.
As I mentioned to Jonathan Grynspan above, I DO understand Obj-C memory management. For some reason, I was getting a retain/release/release (performed by ARC), and that bug is remedied in the final version.
Thanks for the help in tracking this down! At least I got a definitive answer to WHY the problem existed!

Related

Debugging EXC_BAD_ACCESS

I've not worked on this project in quite some time.. When I left it some time in the iOS 8s it ran just fine, however.. on the latest XCode I'm getting many inconsistent EXC_BAD_ACCESS crashes. Now afaik it's requiring a deallocated object. However, the error is lacking where to look. This is quite a big project and like I say, the errors are inconsistent.
I've tried enabling zombie objects, as well as passing it as a starting parameter. However, this is leading me to no joy. I'm expecting something in the debug console with zombies enabled, is this right?
If anyone has any tips on how to find an easier way to debug this, as opposed to tinkering with everything and hoping it works..
EXC_BAD_ACCESS just means that your app is trying to access an invalid memory address. While it is oft caused be a deallocated object, that isn't always the case.
When the app crashes, there should be a crash log or backtrace. Post it as that'll provide clues.
Lovely; a crash entirely in framework code. Seeing as how it is SceneKit that is crashing, I would suggest replacing any graphic assets with new ones and see if that fixes it (even if it doesn't look right). Then check to make sure all of your geometries and layouts are correct.
Have you tried adding a global Exception or Symbolic breakpoint? Those usually help me 99% of the time when I encounter issues without any sort of backtrace.

Patching executable to avoid crashing

I have got a minigame.exe which crashes at some point inside the game. It does not show any error message and it just says Not Responding. I am using Win 7. I want to identify the crashing point and try to fix the games problem. I think the problem might be caused due to a specific DLL imported by the executable. However, I have no clue about how to find out that specific assembly line and try to patch the executable with OllyDBG.
With the information given, this answer would need a full tutorial style, which is considered as too broad for this site. But the first step, finding out what type of crash it is and where it occurs can be explained.
I'll use WinDbg as the debugger, since I'm not familiar with OllyDbg. It is is part of the Debugging Tools for Windows and it's freely available. Install the versions, x64 or x86, that matches minigame.exe.
Start WinDbg, use the correct bitness
Run minigame.exe under WinDbg (File/Open executable). It will stop at the initial breakpoint.
Set up the symbols, at least .symfix c:\debug\symbols and .reload. This will download information needed to construct the callstack.
Continue running the application with g
Reproduce the issue / wait until it crashes
When WinDbg stops,
create a crash dump with .dump /ma c:\debug\minigame.dmp so you can analyze it later, e.g. for asking questions here, so that you needn't reproduce the bug again.
get information about the exception with .exr -1
switch to the thread that caused the exception with ~#s
look at the callstack with k
Now you should have a better understanding of the crash, perhaps enough to apply a patch, maybe not. At least it's a better starting point for further exploration.

System.Runtime.Remoting.RemotingException on Windows store app

I'm a new on windows 8 store app development, I got annoying problem with this IDE first time after I installed it, everything works well but on the time I got this exception event there are no error on my code. I always got it with different number of exception but the message is completely same. Here are the picture :
what should I do to fix this thing?? I need your help, thanks
I received the same exception after updating to VS 13 Update 3. This solution worked for me:
Go to C:\Users\{user}\AppData\Local\Microsoft\VisualStudio\12.0\Designer\ShadowCache and delete all the contents in that folder.
Source: https://connect.microsoft.com/VisualStudio/feedback/details/797072/designer-crashes-in-visual-studio-2013-with-system-runtime-remoting-remotingexception
Try running Blend as an administrator. It sounds a bit like this issue.
If you are building a Windows 8 Store application, keep in mind that the System.Runtime.Remoting APIs are not available in WinRT. See MSDN for a listing of all the .NET APIs that are supported here: http://msdn.microsoft.com/en-us/library/windows/apps/br230232.aspx.
Try removing the remoting code and see if this resolves the problem.
I ran into this same issue when I started using a static object variable, where the object loaded images from resource. Somehow this tripped up Blend (perhaps garbage collection with static variables was getting confused).
To fix it I just moved that static object variable inside my Application class as a non-static member and accessed it via a public accessor function.
UPDATE - I also ran into this when one of my DependencyObject implementations was causing a stack overflow, updating one property when another changes and vice versa... Look for stack overflows.
Hope this helps someone!
I had this, right now. The reproducible cause was a crash of the Display-Driver triggered by my code. As this might only be the Display-Drivers fault, it might just needs fixing in the Display-Driver - for the meantime you can try to find the location causing the Display-Driver to crash and do a workaround. But the Display-Driver should not crash, whatever you throw at it. I see strange colours and splits in your screenshots. So I assume something makes your Display-Driver crash also.
I have been receiving the same error after updating Microsoft Visual Studio 2013 to Update 3
Designer works with a new project but removing the code in old projects does not work.
Deleting all folders in C:\Users{user}\AppData\Local\Microsoft\VisualStudio\12.0\Designer\ShadowCache worked for me...
The workaround posted by #pcnThird doesn't work anymore. The issue was resolved in Update 1 and subsequently in the latest Visual Studio 2013 Update 3.

EXC_BAD_ACCESS Problem

I've been running into an EXC_BAD_ACCESS bug and have been racking my brain trying to figure out the solution. I believe I know the issue but I can't narrow down the line that it's happening on and the debug log isn't helping me. I've embedded the crash log below. If anybody could help me figure out how to track things down I'd be extremely grateful! I have turned on NSZombieEnabled but that is not giving me any additional information.
text is better than a screenshot, but I think I can read that screen.
the crash is in your code at 0x1000. You'll want to sybolicate that: Symbolicating iPhone App Crash Reports
the frames in libobjc are most likely because you are passing a bogus pointer to objc_msgSend(); something that looks enough like a pointer that objc tries to poke at the garbage value is if it were an object.
this isn't necessary an over-release problem; could just be a trashed pointer / trashed memory.
You can probably disassemble the binary and figure out what symbols is that the address listed. Or something pretty close. otool is your friend. nm might be, too. But... proper symbolication is far superior.
while debugging set NZombieEnabled.It will helf you hunt down the probem.atleast why its crashing(on which object).

Random Crashing and weird console output

I wrote an entire app, and I was just about to submit it to the app store, and in my final testing, I went back and added a few releases to ensure proper memory management was observed. And since then, I keep getting these random crashes. I've tried removing some or all of the release calls, I've tried retaining objects. I cleaned the project. I used NSZombieEnabled and that also is not helping. All this to not avail.
Most of the time, the console says provides no help. Usually the app loads, I put NSLogs in viewDidLoad, viewDidAppear, and viewWillAppear, and they all show up in the console, then it crashes.
Sometimes I also get EXC_BAD_ACCESS (and I know what that means). But its occurring randomly. So this doesn't make sense to me. Thanks for any help possible. I've written this whole app, and spent months on it. So I'm really stuck. Thank you.
Have you tried Build --> Analyze? It will search your code for leaks and other useful things you might have missed. Try that and see if it finds anything for you.
I agree with Rudy. It sounds like you're releasing something that is still in use. I would go back to the version that was working and start adding the releases one at a time til it causes the crash. Slow but effective debugging.
When you say that you "sometimes" get EXC_BAD_ACCESS, what do you get the rest of the time? Where does the crash stack indicate you're crashing? What messages do you get?
Random crashes usually indicate a timing problem. A common cause is accessing things on multiple threads. Are you? It can also mean timing differences based on network traffic.
Make sure the console doesn't indicate an exception rather than a memory violation. Usually there's something in the console that will be useful.