Click here to Skip to main content
15,889,462 members

The Weird and The Wonderful

   

The Weird and The Wonderful forum is a place to post Coding Horrors, Worst Practices, and the occasional flash of brilliance.

We all come across code that simply boggles the mind. Lazy kludges, embarrassing mistakes, horrid workarounds and developers just not quite getting it. And then somedays we come across - or write - the truly sublime.

Post your Best, your worst, and your most interesting. But please - no programming questions . This forum is purely for amusement and discussions on code snippets. All actual programming questions will be removed.

 
GeneralRe: Thats why i hate c++ Pin
KP Lee27-Apr-12 14:24
KP Lee27-Apr-12 14:24 
GeneralRe: Thats why i hate c++ Pin
Jörgen Andersson24-Apr-12 11:42
professionalJörgen Andersson24-Apr-12 11:42 
GeneralRe: Thats why i hate c++ Pin
Gary Huck27-Apr-12 3:45
Gary Huck27-Apr-12 3:45 
GeneralRe: Thats why i hate c++ Pin
Mohibur Rashid24-Apr-12 17:28
professionalMohibur Rashid24-Apr-12 17:28 
GeneralRe: Thats why i hate c++ Pin
CDP180225-Apr-12 4:06
CDP180225-Apr-12 4:06 
GeneralRe: Thats why i hate c++ Pin
Mohibur Rashid25-Apr-12 4:34
professionalMohibur Rashid25-Apr-12 4:34 
GeneralRe: Thats why i hate c++ Pin
CDP180226-Apr-12 21:23
CDP180226-Apr-12 21:23 
GeneralRe: Thats why i hate c++ Pin
Mike Winiberg26-Apr-12 20:49
professionalMike Winiberg26-Apr-12 20:49 
That's happened to me a few times (occasionally with C++ Builder too!). In each case it has been a variation on:

Different memory (especially heap space) allocations between the debug and live environment (even on the same machine). Debugger initialising memory to something sensible, thus hiding an uninitialised variable somewhere in my code, debugger locating the program in a different area of physical memory, thus avoiding a faulty patch of RAM that - by coincidence - wasn't used by the OS normally either, and so on

In other words, this type of problem is almost always memory related in some way, or possibly due to uninitialised use of a physical device or internal queue in some that way the debugger covers up when it sets up the debug environment.

One technique that can sometimes help catch this is to use a remote debugging session run from a second machine - often the remote debug stub will not do as much pre-execution setup as an integrated debugger, thus leaving the problem undisturbed, or at least different.

I remember one particular problem porting a program from C++ builder to Linux, where the C++ Builder program loader initialised class memory to 0 before starting the program, whereas GNU C++ didn't - took me a while to spot that, as the program only failed when loaded without gdb (which placed it in an area of memory that was, by chance, all 0s!)

Oh, happy days...

8)
GeneralRe: Thats why i hate c++ Pin
Michael Kingsford Gray27-Apr-12 2:45
Michael Kingsford Gray27-Apr-12 2:45 
GeneralRe: Thats why i hate c++ PinPopular
Pranit Kothari26-Apr-12 18:38
Pranit Kothari26-Apr-12 18:38 
GeneralRe: Thats why i hate c++ Pin
wcsystems28-Apr-12 7:21
wcsystems28-Apr-12 7:21 
GeneralRe: Thats why i hate c++ Pin
code_junkie27-Apr-12 5:02
code_junkie27-Apr-12 5:02 
GeneralRe: Thats why i hate c++ Pin
KP Lee27-Apr-12 13:59
KP Lee27-Apr-12 13:59 
GeneralRe: Thats why i hate c++ Pin
Florin Jurcovici27-Apr-12 8:50
Florin Jurcovici27-Apr-12 8:50 
GeneralRe: Thats why i hate c++ Pin
Gerry Schmitz27-Apr-12 11:45
mveGerry Schmitz27-Apr-12 11:45 
GeneralRe: Thats why i hate c++ Pin
giuchici29-Apr-12 6:36
giuchici29-Apr-12 6:36 
GeneralQuick Nap PinPopular
Pascal Ganaye23-Apr-12 4:18
Pascal Ganaye23-Apr-12 4:18 
GeneralRe: Quick Nap Pin
CDP180223-Apr-12 4:30
CDP180223-Apr-12 4:30 
GeneralRe: Quick Nap Pin
Jörgen Andersson23-Apr-12 23:35
professionalJörgen Andersson23-Apr-12 23:35 
GeneralRe: Quick Nap Pin
Steve Burchett4-May-12 18:00
Steve Burchett4-May-12 18:00 
GeneralRe: Quick Nap Pin
Pete O'Hanlon23-Apr-12 4:32
mvePete O'Hanlon23-Apr-12 4:32 
GeneralRe: Quick Nap Pin
OriginalGriff23-Apr-12 4:36
mveOriginalGriff23-Apr-12 4:36 
GeneralRe: Quick Nap Pin
CDP180223-Apr-12 4:38
CDP180223-Apr-12 4:38 
GeneralRe: Quick Nap Pin
aureliosjr23-Apr-12 22:46
aureliosjr23-Apr-12 22:46 
GeneralRe: Quick Nap Pin
krsmichael27-Apr-12 6:58
krsmichael27-Apr-12 6:58 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.