Igor Delovski Board Forum Index Igor Delovski Board
My Own Personal Slashdot!
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Error handling & Debugging

 
Post new topic   Reply to topic    Igor Delovski Board Forum Index -> General Programming
General Programming  
Author Message
Ike
Kapetan


Joined: 17 Jun 2006
Posts: 3025
Location: Europe

PostPosted: Sun Sep 10, 2006 4:34 pm    Post subject: Error handling & Debugging Reply with quote

Errors: errno in UNIX programs

"Proper error detection and recovery is often ignored by UNIX®
developers. The lack of exceptions from the C language and the
rudimentary error mechanisms from the standard C library certainly
contribute to this. This article familiarizes you with UNIX error reporting in
the standard C library and (hopefully) encourages you to report and
handle errors in a user-friendly way."
Back to top
View user's profile Send private message
delovski



Joined: 14 Jun 2006
Posts: 3522
Location: Zagreb

PostPosted: Thu Sep 21, 2006 10:47 pm    Post subject: Reply with quote

_matherr in Visual C++

"I want to capture things like logs of negatives, underflow, overflow, etc.
I have an expression evaluator that will evaluate mathematical expressions
(sin, cos, tan, log, atan, etc etc) The problem is to capture the maths
exception when one of these functions is called with a stupid value. "
Back to top
View user's profile Send private message Visit poster's website
delovski



Joined: 14 Jun 2006
Posts: 3522
Location: Zagreb

PostPosted: Wed Sep 27, 2006 6:47 pm    Post subject: Reply with quote

Raymond Chen: IsBadXxxPtr should really be called CrashProgramRandomly

" 'But what should I do, then, if somebody passes me a bad pointer?'

You should crash.

No, really.

In the Win32 programming model, exceptions are truly exceptional. As a
general rule, you shouldn't try to catch them. And even if you decide you
want to catch them, you need to be very careful that you catch exactly
what you want and no more."


... and somewhat related entry by Larry Osterman: Should I
check the parameters to my function?


"But he felt that the API should check all the bogus pointers passed in
and fail with E_POINTER if the pointer passed in didn’t point to valid memory.

This has been a subject of a lot of ongoing discussion over the years
internally here at Microsoft. There are two schools of thought:

School one says 'We shouldn’t crash the application on bogus data.
Crashing is bad. So we should check our parameters and return error
codes if they’re bogus'.

School two says 'GIGO – if the app hands us garbage, then big deal if it
crashes'."



Raymond's blog entry managed to start a mini-avalanche of related
articles! Eric Lippert: Do Not Call IsBadFooPtr, Indeed

"... promptly forgot about it. Raymond Chen’s blog entry today
reminded me of it, because this is the story of how I found out the hard
way that IsBadFooPtr is bad, bad, bad. "


And there's one interesting note: "One of the most basic and important
rules of COM programming is that you never, ever, EVER change an interface
without changing its GUID. Or, to put it another way, you simply never
change an interface; if you need to, you create an entirely new interface."


Last edited by delovski on Thu Sep 28, 2006 11:58 am; edited 2 times in total
Back to top
View user's profile Send private message Visit poster's website
XNote
Kapetan


Joined: 16 Jun 2006
Posts: 532

PostPosted: Thu Sep 28, 2006 12:51 am    Post subject: Reply with quote

Michael Hunter's blog: The Braidy Tester,
subtitled "Making developers cry since 1995"

"I am a Test Technical Lead, which means I set the technical direction
of my team: how do we automate our testing, what our test automation
infrastructure looks like, and how do we plan, prioritize, schedule, and
build that infrastructure."


Michael wrote an entire series of blog entries for DDJ titled "You are not
done yet"
and there's a list of links at the Coding Horror. Obligatory!
Back to top
View user's profile Send private message
delovski



Joined: 14 Jun 2006
Posts: 3522
Location: Zagreb

PostPosted: Thu Sep 28, 2006 8:22 pm    Post subject: Reply with quote

Debugging Multithreaded and Realtime Application on WIndows

"My immediate guess is that somewhere inside of the debugger, it'd doing
something like a WaitForMultipleObjects, which is limited to waiting on
64 handles at a time, and it's just not planning for having 500 threads."
Back to top
View user's profile Send private message Visit poster's website
delovski



Joined: 14 Jun 2006
Posts: 3522
Location: Zagreb

PostPosted: Sat Oct 14, 2006 3:50 pm    Post subject: Reply with quote

Dev Shed: Exception handling in C

"I would advice you to log aggressively. Create many layers of logs. In
the most detailed, log the actual function which is currently being executed."

...
"The Dr. Watson information is also logged to a file. You can find out where
it is by running drwtsn32.exe from the Run menu item or a command line."
Back to top
View user's profile Send private message Visit poster's website
delovski



Joined: 14 Jun 2006
Posts: 3522
Location: Zagreb

PostPosted: Wed Oct 18, 2006 6:41 pm    Post subject: Reply with quote

Google Groups: writing to a file prior to system crash

> Is there any way to guarantee that before my function returns, anything
> written to the hard drive is Actually on the hard drive?

http://www.sysinternals.com/Utilities/Sync.html

"I'm not entirely sure how he did it, but a quick check with
Dependency Viewer suggests looking at FlushFileBuffers.  From
what MSDN says, if you use CreateFile to get a handle to the
volume, you can flush the buffers for the whole disk."
Back to top
View user's profile Send private message Visit poster's website
delovski



Joined: 14 Jun 2006
Posts: 3522
Location: Zagreb

PostPosted: Sat Oct 21, 2006 8:49 pm    Post subject: Reply with quote

LandlordMax’s Most Challenging Bug

"This is probably the most challenging bug I’ve encountered simply
because it was absolutely unobvious what the issue was, there was no
way to track it down in the code, and there is no real, or obvious, solution
to it."
Back to top
View user's profile Send private message Visit poster's website
delovski



Joined: 14 Jun 2006
Posts: 3522
Location: Zagreb

PostPosted: Mon Oct 23, 2006 11:44 am    Post subject: Reply with quote

JoS: When is an exception an exception

"Not to mention the fact that throwing exception can be quite expensive.
He seems to think by catching and throwing the exceptions back to the caller
he doesn't have to write codes to verify 2 and 3 anymore. Any opinions?"
Back to top
View user's profile Send private message Visit poster's website
delovski



Joined: 14 Jun 2006
Posts: 3522
Location: Zagreb

PostPosted: Fri Nov 03, 2006 5:05 pm    Post subject: Reply with quote

RC: How do I convert an HRESULT to a Win32 error code?

"Sometimes, when I import data from a scanner, I get the error "The
directory cannot be removed." What does this mean?"
Back to top
View user's profile Send private message Visit poster's website
delovski



Joined: 14 Jun 2006
Posts: 3522
Location: Zagreb

PostPosted: Thu Nov 23, 2006 7:33 pm    Post subject: Reply with quote

JoS: C newbie question #2: Error handling

"Whatever the choice is for your own code, the best idea is to use it
consistently. Since error conditions are usually given upward through the
calling hierarchy of the functions, you will curse it sooner or later, whatever
your choice was, when you have more complex functions in the higher
levels with nested call-chains of lower level functions, with each possibly
returning an error condition."
Back to top
View user's profile Send private message Visit poster's website
delovski



Joined: 14 Jun 2006
Posts: 3522
Location: Zagreb

PostPosted: Fri Dec 01, 2006 5:57 pm    Post subject: Reply with quote

Slashdot: Practical Software Testing Resources?

"I've been a software engineer by profession for a few years and a
programming enthusiast for much longer. As my experience has increased,
so has the size of the projects that I have had to work on. My software
testing method involves trying to do everything I can think of that the end
user might try to do. Hopefully, this will break the application if there is a
bug within my code. The current project that I am working on involves
numerous tiers within a smart client environment. Trial and error testing is
no longer sufficient — there is simply too much that could happen.

Searching the Internet for software testing resources provides an abundant
amount of information but it's often quite philosophical and verbose. What
are some practical resources that Slashdot readers use for testing your
software projects?"
Back to top
View user's profile Send private message Visit poster's website
Ike
Kapetan


Joined: 17 Jun 2006
Posts: 3025
Location: Europe

PostPosted: Tue Jan 02, 2007 6:42 pm    Post subject: Reply with quote

TechNet: DebugView for Windows v4.63
by Mark Russinovich, published: November 1, 2006

"DebugView is an application that lets you monitor debug output on your
local system, or any computer on the network that you can reach via TCP/IP.
It is capable of displaying both kernel-mode and Win32 debug output, so
you don't need a debugger to catch the debug output your applications or
device drivers generate, nor do you need to modify your applications or
drivers to use non-standard debug output APIs."
Back to top
View user's profile Send private message
XNote
Kapetan


Joined: 16 Jun 2006
Posts: 532

PostPosted: Thu Jan 18, 2007 10:04 pm    Post subject: Reply with quote

John Robbins: Want to Review a Debugging Book?

"From the new title, you can see that I'll be adding coverage for the new
testing and performance tools in VS.NET 2005. I've wanted to write more
about those areas of debugging for a while. To address the "too hard"
problem, I'm adding a huge section that covers all sorts of common and not
so common scenarios people run into and how to get started fixing them."
Back to top
View user's profile Send private message
delovski



Joined: 14 Jun 2006
Posts: 3522
Location: Zagreb

PostPosted: Tue Jan 23, 2007 5:54 pm    Post subject: Reply with quote

RC: Non-psychic debugging: If you can't find something, make sure you're looking in the right place

"You can stare at this code for ages and completely overlook that the wrong
window handle is being passed to GetDlgItem and SetWindowLongPtr."
Back to top
View user's profile Send private message Visit poster's website
Ike
Kapetan


Joined: 17 Jun 2006
Posts: 3025
Location: Europe

PostPosted: Tue Jan 30, 2007 8:08 pm    Post subject: Reply with quote

RC: Unusual uses for a ball-point pen: Breaking into the debugger

"You inserted the tip of the pen at the very end of an open slot (the end
nearest the back of the computer) and slowly dragged it towards the front
of the computer until it shorted the nearest pair of pins.

If you had the Windows 95 debugger connected to the system (known as
WDEB386), it caught the NMI and broke into the debugger."
Back to top
View user's profile Send private message
delovski



Joined: 14 Jun 2006
Posts: 3522
Location: Zagreb

PostPosted: Sat Mar 03, 2007 12:48 am    Post subject: Reply with quote

Adrian McCarthy: Phantom Bug

"Instead of working on new features for the Ray Tracer, I spent last night
and part of this morning chasing a phantom bug. The cause was quite
surprising and could happen in your Windows programs, so I thought I’d
post the solution to help you avoid wasting a couple hours like I did."
Back to top
View user's profile Send private message Visit poster's website
delovski



Joined: 14 Jun 2006
Posts: 3522
Location: Zagreb

PostPosted: Sat Mar 10, 2007 1:06 am    Post subject: Reply with quote

Deduce application type

"In my Windows application I have the ASSERT function, which evaluates an
expression and, once the expression evaluates to false, displays an appropriate
error message and aborts the program.

This ASSERT function sits in a separate library underneath the applicatin layer
and therefore known nothing about the latter. However it should somehow
know whether the application calling it is GUI or console in order to know
where to display the error message"
Back to top
View user's profile Send private message Visit poster's website
delovski



Joined: 14 Jun 2006
Posts: 3522
Location: Zagreb

PostPosted: Sat Mar 10, 2007 3:16 pm    Post subject: Reply with quote

JoS: How to deal with an ungraspable bug

"Now I have a job in which the customer keeps telling me that the program
doesn't work on his machine and all machines he tries it on. Always the same
error message, for which googling doesn't show up anything relevant, no
further details, I cannot reproduce it here..."
Back to top
View user's profile Send private message Visit poster's website
Ike
Kapetan


Joined: 17 Jun 2006
Posts: 3025
Location: Europe

PostPosted: Fri May 04, 2007 5:17 pm    Post subject: Reply with quote

Exceptions and Error Codes, by Kyle Wilson

"As game developers, we are the heirs to a vast body of common
wisdom holding that exception handling overhead is too expensive
for high-performance games, and that error codes are the only
acceptable mechanism for propagating errors in game code. What
should we believe?"
Back to top
View user's profile Send private message
delovski



Joined: 14 Jun 2006
Posts: 3522
Location: Zagreb

PostPosted: Mon Jul 02, 2007 4:50 pm    Post subject: Reply with quote

Joe Hewitt - Firebug for iPhone

"Trying to debug web pages on my iPhone transported me back to a dark
place I hadn't been in some time: The Land of alert() Debugging! Within the
first few hours I had sent my phone into its first infinite modal loop, from
which the only escape was to power down the phone and reboot it. While
waiting for the reboot I pined for Firebug and my best friends console.log()
and the command line."
Back to top
View user's profile Send private message Visit poster's website
delovski



Joined: 14 Jun 2006
Posts: 3522
Location: Zagreb

PostPosted: Wed Aug 01, 2007 11:32 pm    Post subject: Reply with quote

adc: Finding Memory Leaks

"Apple provides the MallocDebug application and leaks command-line tool for
automatically tracking down memory leaks. You can also track down leaks
manually using other analysis tools, but that task falls under the category of
finding memory problems in general and is covered in “Examining Memory
Allocation Patterns...” The following sections describe the MallocDebug and
leaks tools and show you how to use them to track down memory leaks."
Back to top
View user's profile Send private message Visit poster's website
Ike
Kapetan


Joined: 17 Jun 2006
Posts: 3025
Location: Europe

PostPosted: Tue Jul 22, 2008 2:19 pm    Post subject: Reply with quote

Xcode-users - Error codes

"As of Leopard, MacErrors.h is no longer informative. Instead, you have to
use the new Core Foundation Error functions to retrieve a descriptive
string for a particular error code associated with an error domain."
Back to top
View user's profile Send private message
Ike
Kapetan


Joined: 17 Jun 2006
Posts: 3025
Location: Europe

PostPosted: Fri Aug 29, 2008 9:16 pm    Post subject: Reply with quote

RC: What possible use are those extra bits in kernel handles? Part 2:
Overcoming limited expressiveness


"Okay, so it turns out that (TRUE, HANDLE) is only 1 + 30 = 31 bits of informa-
tion, and (FALSE, HRESULT) is only 1 + 31 = 32 bits of information. We can fit
them inside a single 32-bit value after all!

If the bit is clear, then the operation succeeded and the entire value is the
handle, relying on the fact that valid handles always have the bottom two bits
clear. On the other hand, if the bottom bit is set, then we have an error code,
and the remaining 31 bits give us the significant bits of the HRESULT."
Back to top
View user's profile Send private message
Ike
Kapetan


Joined: 17 Jun 2006
Posts: 3025
Location: Europe

PostPosted: Tue Sep 02, 2008 7:54 pm    Post subject: Reply with quote

msdn - Message Compiler

"The Microsoft Message Compiler (MC) is a tool for creating messages that
an application or dynamic-link library (DLL) needs. Its input is a text file that
defines the messages. The message file format makes it easy to support
multiple languages in the same image file.

This tool is available in Visual Studio and the Platform SDK.

To use a message text file in your application, you must include it in a resource
script (.rc) file. First, use MC to convert the message text file into a binary file
suitable for inclusion in the .rc file. Then, use the resource compiler to place
the messages into the resource table for the application."
Back to top
View user's profile Send private message
XNote
Kapetan


Joined: 16 Jun 2006
Posts: 532

PostPosted: Thu Sep 18, 2008 7:34 pm    Post subject: Reply with quote

reddit - A compile time assert() hack for C

"C99 doesn't require support for "sizeof" in preprocessor conditionals and gcc
for example doesn't support it. So we can't do something like:
#if (sizeof(my_struct)!=512)
for example. This prompted me into seeking a more general solution of getting
the compiler to check constant expressions, and I came up with this macro to
support compile time assertions."
Back to top
View user's profile Send private message
delovski



Joined: 14 Jun 2006
Posts: 3522
Location: Zagreb

PostPosted: Mon Oct 13, 2008 12:02 am    Post subject: Reply with quote

Apple: Introduction to Error Handling Programming Guide For Cocoa

"Cocoa offers developers programmatic tools for these tasks: the NSError
class in Foundation and new methods and mechanisms in the Application Kit
to support error handling in applications. An NSError object encapsulates
information specific to an error, including the domain (subsystem) originating
the error and the localized strings to present in an error alert."


And some more details: Exceptions and Errors

"The expectation is that the developer will catch these kinds of errors during
testing and address them before shipping the application; thus the application
should not need to handle the exceptions at runtime. If an exception is raised
and no part of the application catches it, the top-level default handler typically
catches and reports the exception and execution then continues."


MacDevCenter - Understanding Exceptions and Handlers in Cocoa

CocoaDev - ExceptionHandling
Back to top
View user's profile Send private message Visit poster's website
Ike
Kapetan


Joined: 17 Jun 2006
Posts: 3025
Location: Europe

PostPosted: Sun Apr 12, 2009 4:52 pm    Post subject: Reply with quote

MF - XCode - how to "see" an exception that is thrown

"Yes, if I press "Continue" a few times, eventually a friendlier error message
appears in the console telling me an entity could not be found - in one of my
bindings I used "Cars" instead of "Car"."
Back to top
View user's profile Send private message
delovski



Joined: 14 Jun 2006
Posts: 3522
Location: Zagreb

PostPosted: Tue Mar 30, 2010 9:50 pm    Post subject: Reply with quote

SO - What are best practices for error handling when writing an
API for the iphone


"We are writing an API for iphone developers and we don't know what the
best practice is for exception handling. We looked into NSError, standard
POSIX way, NSException..."
Back to top
View user's profile Send private message Visit poster's website
Ike
Kapetan


Joined: 17 Jun 2006
Posts: 3025
Location: Europe

PostPosted: Wed Jan 26, 2011 6:06 pm    Post subject: Reply with quote

so - Memory leak detection tools in XCode

"There is one specifically called 'Leaks' and like a previous poster said, the
easiest way to run it is straight from Xcode: run -> Start with Performance
Tool -> Leaks. It seems very good at detecting memory leaks, and was e-
asy for a Non-C Head like me to figure out."
Back to top
View user's profile Send private message
Ike
Kapetan


Joined: 17 Jun 2006
Posts: 3025
Location: Europe

PostPosted: Wed Jan 26, 2011 10:35 pm    Post subject: Reply with quote

ksplice.com - 8 gdb tricks you should know

"Despite its age, gdb remains an amazingly versatile and flexible tool, and
mastering it can save you huge amounts of time when trying to debug prob-
lems in your code. In this post, I'll share 10 tips and tricks for using GDB to
debug most efficiently."
Back to top
View user's profile Send private message
delovski



Joined: 14 Jun 2006
Posts: 3522
Location: Zagreb

PostPosted: Tue May 14, 2013 10:38 pm    Post subject: Reply with quote

reddit - Bet You Didn't Know The Xcode Debugger Could Do That

"For people that are looking for it: Video & Presentation slides"
Back to top
View user's profile Send private message Visit poster's website
delovski



Joined: 14 Jun 2006
Posts: 3522
Location: Zagreb

PostPosted: Fri Sep 27, 2013 5:58 pm    Post subject: Reply with quote

JabSoft I/O - Are buffer-overflows solved yet? A historical tale.

"So, after a few decades of existence, can we finally put this behind us? Is
the overflow defeated yet? It turns out, this answer is not straight-forward.
The buffer-overflow is a particularly nasty beast, and despite our best efforts
it can still rear its ugly head. The problems can be surprisingly subtle, so to
answer our question, we must understand these complications."
Back to top
View user's profile Send private message Visit poster's website
Ike
Kapetan


Joined: 17 Jun 2006
Posts: 3025
Location: Europe

PostPosted: Wed Oct 25, 2017 9:50 pm    Post subject: Reply with quote

http://www.codersnotes.com/notes/something-rotten-in-the-core/

Something Rotten In The Core

So much of our software world now is filled with wrappers -- programs that don't actually do the thing themselves, but 'outsource' their work to other programs. It's a stack of layers, and it's not a nice clean stack. I remember something Jeff Roberts once said to me -- the layers grind against each other, and you can feel each one chipping bits away as they collide.
Back to top
View user's profile Send private message
Ike
Kapetan


Joined: 17 Jun 2006
Posts: 3025
Location: Europe

PostPosted: Mon Dec 04, 2017 10:24 pm    Post subject: Reply with quote

medium.com - Unit-Tests in Objective-C

"Understanding the whole state of the app and action we are trying to test,
depends on our ability to name tests. In general we suck doing so. An alter-
native are frameworks based on RSpec. They add syntactic sugar to our tests
and might just make the difference of searching 2 hours understanding the
test, or fixing the problem."
Back to top
View user's profile Send private message
delovski



Joined: 14 Jun 2006
Posts: 3522
Location: Zagreb

PostPosted: Mon Dec 17, 2018 6:45 pm    Post subject: Reply with quote

r - Inherited an App: Freezes after being backgrounded, but doesn't
crash! How do I debug?!


"... start by looking for observers for UIApplication.willResignActiveNotification
and didBecomeActiveNotification. These can be used to call functions when the
app pauses/resumes. They can be defined individually in each view controller
or in the App Delegate."
Back to top
View user's profile Send private message Visit poster's website
Ike
Kapetan


Joined: 17 Jun 2006
Posts: 3025
Location: Europe

PostPosted: Thu Dec 17, 2020 6:11 pm    Post subject: Reply with quote

r - A minimal and easy-to-use C testing framework, in plain C with no dependencies

"ihct is a minimal C unit-testing framework. Intended for light unit testing,
and keeping the user interface logical and light. Looking for more features,
so please give any suggestions."
Back to top
View user's profile Send private message
Ike
Kapetan


Joined: 17 Jun 2006
Posts: 3025
Location: Europe

PostPosted: Mon Sep 11, 2023 1:58 pm    Post subject: Reply with quote

adc - Diagnosing memory, thread, and crash issues early

"Identifying potential issues during development saves testing time later and
improves the stability of your code. Xcode provides several runtime tools to
identify potential issues in your code:

Address Sanitizer -- The ASan tool identifies potential memory-related
corruption issues.

Thread Sanitizer -- The TSan tool detects race conditions between threads.

Main Thread Checker -- This tool verifies that system APIs that must run on
the main thread actually do run on that thread.

Undefined Behavior Sanitizer -- The UBSan tool detects divide-by-zero
errors, attempts to access memory using a misaligned pointer, and other
undefined behaviors."
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    Igor Delovski Board Forum Index -> General Programming All times are GMT + 1 Hour
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Delovski.hr
Powered by php-B.B. © 2001, 2005 php-B.B. Group