Re: function pointers




"Ark Khasin" <akhasin@xxxxxxxxxxxxxxxxxxxx> wrote in message
news:vNhgj.832$xA6.11@xxxxxxxxxxx
"Tom????????????????????????????????" wrote:
The only redudant checks I use in my programs are asserts.
May I suggest that's a very dubious practice.
Debug build crashes predictably; Release build (with NDEBUG #define'd)
either crashes unpredictably or wanders away mysteriously.
Use asserts for debugging and never for user input. On the API level, your
user can be another programmer.
- Ark

what I do depends a lot on context.

usually, I try to detect most cases that are dubious, but still workable,
and try to handle the situation gracefully (very often, this is in finding
an alternate way to do something, or returning some sort of error status).

in some cases, if the problem is particularly serious, very often I will
print some debugging messages and initiate a controlled crash.

even though windows doesn't much like the crashes (when they are unexpected
and I am not running a debugger, causing both crashes and annoying popup
messages), they are good in that they make it a lot easier to crash the
program just where I want it to be (sort of like a semi-permanent
breakpoint), which makes it a lot easier to try to recreate the problem in a
debugger, and then have it crash somewhere where I can easily examine the
state and can try to figure out what has gone wrong.

there are different ways to invoke crashes, but the one I typically use is
this:
*(int *)-1=-1;

on linux, this option works better though, since linux crashes give a
general debugger-usable core dump (sadly absent on windows...).


well, it works at least.



.



Relevant Pages

  • Re: Disappointed
    ... have debugging settings enabled? ... Read through the chapter on kernel debugging in the ... me it crashes within a couple of days. ... 200Mbp and 20 outgoing feeding aprox 200Mbps. ...
    (freebsd-stable)
  • Re: Tcl crashes
    ... If you can get Tcl, Tk, Itcl and whatever extensions you used compiled ... Tcl has some memory debugging ... It is expensive and slows down execution of the app substantially. ... the app always crashes under windows. ...
    (comp.lang.tcl)
  • Re: preventing dos window close upon program termination
    ... While debugging, the call stack certainly serves my purposes, and is far ... Normally, if a program crashes, the debugger will stop and show you ... Seeing all the console outputs is not reliable if the program crashes. ... The console window WILL close when the program ...
    (microsoft.public.vsnet.debugging)
  • Re: VB6 crash upon exit !!
    ... when I stop debugging or try to exit my VB program. ... I noticed it crashes only when I have used winsock at least once before ... Full Compile) to make sure that VB won't stop for compilation errors. ... and use OutputDebugStringwith a debug viewer instead of Debug.Print to ...
    (microsoft.public.vb.general.discussion)
  • Re: Physical memory access from C# in WinCE 6.0
    ... crashes giving the access violation. ... I have been debugging the OS and it crashes exactly in: ... the error message I got in a message box in the OS debugger. ...
    (microsoft.public.windowsce.app.development)