The issue is not "is it going to break [eventually or otherwise] as much
as “can we reproduce this behavior in a recent compilation?” Suppose the
recompilation creates a different packing of segments, as already
described. the biggest problem is not the sudden introduction of a
failing behavior as much as the sudden disappearance of one, making it
difficult or impossible to isolate the cause.
Back in the 1980s, we had a policy for developers that I put in place: if
someone gets a memory-damage bug, the configuration is frozen at that
point. No more checkins of code are permitted in that development branch.
This allowed the person searching for the bug to be able to reproduce it
at will (single-threaded code is highly deterministic) without, say, some
new-and-different allocation pattern to mask the bug (example: a dangling
pointer that now results in “damage” to freespace that does not corrupt
the allocator headers). And the priority was “if you see a storage-damage
bug, everything, including your current development path, STOPS until that
bug is found and fixed”.
Sometimes this worked entirely too well. I was the most “intuitive”
debugger of storage damage bugs, so after a day or so of thrashing about,
someone would say, “Let’s see what Joe can do” and the bug would land on
my desk. Mostly, I could find and fix it in under a day. Although there
was once a 72-hour marathon where two of us would hand the bug and a
status report to the other every ten hours or so. (Ultimately, it turned
out to be my bug, a <= when it should have been a <).
We had formalized this idea in our Hydra operating system, with a concept
known as a “blind process” that could not query date or time, the idea
being to be able to force bitwise-identical behavior. Unfortunately, we
couldn’t freeze the file system, so could not guarantee that the input
bits were identical; the problem in its general case became so intractable
that the feature was never implemented.
I was once presented a hand-calligraphed scroll, showing a fish (floundef)
spearing a giant cockroach, from one of the compiler groups for finding,
in 17 hours, a bug the team had worked on for a week. It was
seventh-level damage before it caused an actual failure.
For all the various rants about C++ coding, I have found that I get
essentially zero occurrences of storage damage bugs using C++.
But in this case, of disabling date/time macros, I am in complete
agreement with the decision. As in “been there, done that”.
joe
>
> Nondeterminism is bad. Imagine two source files use TIME. If they
> happen to be compiled at the same second, they’ll wind up with the same
> string, so the identical strings will get coalesced into the .cdata
> section. But if
> one file is compiled a second later, the strings will be different, so
> will go into
> separate parts of the .cdata section. The presence of these extra 9
> bytes of
> data will cause the linker to pack the cdata section differently, which
> might
> cause the entire section to round up to an another page, which causes
> other
> sections to move around. And then the code that references the data
> changes too – what might have been a near address could now be a far
> address, requiring a longer processor instruction, increasing the size
> of the
> routine. The larger function exceeds the optimizers limit for inlining,
> and the
> routine is no longer inlined, causing other routines to be restructured
> as
> register pressure decreases…
>
That doesn’t sound any different to any other change that you might make
to your code though. The fact that you have a chance of getting a “fast”
or “slow” build basically at random shouldn’t make any difference in terms
of overall execution time, and if it does matter and 9 bytes is the
difference between the two then you’re doing it wrong and it was going to
break eventually anyway.
James
NTDEV is sponsored by OSR
For our schedule of WDF, WDM, debugging and other seminars visit:
http://www.osr.com/seminars
To unsubscribe, visit the List Server section of OSR Online at
http://www.osronline.com/page.cfm?name=ListServer