Conttamination of string by unrelated part of a program, in another program, the result is perfect
Summary
A piece of code that displays a string presents garbage, identical code running as stub is correct.
System Information
- Operating system: Windows 10 Pro release H20
- Processor architecture: Ia64
- Compiler version: 3.2.0 and 3.2.2 (just updated Lazarus install with compiler change from .0, problem is the same) Problem occurs whether run after compile in Lazarus or from the Dos command line.
- Device: Lenovo desktop PC, 8M memory, 100GB disk space remaining
Steps to reproduce
- Run Errtest errtest.pas program, works perfectly.
- Run Noisy noisy.pas program, misbehavior occurs. The segment of code that does this is identical in both programs.
Example Project
Errtest is the "stripped down" (but not by much) test bed containing just the code needed to construct the date display and elapsed time calculations.
What is the current bug behavior?
First string showing starting time as day, date and time displays fine Second string showing completion time is corrupted with "Stuttering"
What is the expected (correct) behavior?
Exactly what Errtest does
Relevant logs and/or screenshots
Output from Errtest:
C:\Users\Paul\Documents\Programming\Pascal\Noisy>errtest
Started: Sunday Decenber 5, 2021 21:06:01
Wait a while, then press Enter:
Process ended: Sunday Decenber 5, 2021 21:06:04
Process took 3.84 seconds.
Press Enter:
Output from noisy:
C:\Users\Paul\Documents\Programming\Pascal\Noisy>noisy
Noisy: Program to tag source code, Ver. 0.1
Copyright 2021 Paul Robinson - Released under GPL ver. 2
Started: Sunday Decenber 5, 2021 21:05:33
Wait a while, then press Enter:
Process completed: Sunday Decenber 055, 212021 202121:05:35
Process took 2.403 seconds.
Press Enter:
Files Attached:
Possible fixes
I have two choices at this point. Copy things one at a time from Noisy into Errtest until I discover what causes the behavior. Since the first time the date is created for display, it's right, and no intervening code occurs (except a readln) and in one case it works perfectly, and the other doesn't,
I figure one of two things.
- There is a compiler bug (which I think is more likely) or,
- In some amazing fashion, I've screwed the pooch so badly that code I wrote that isn't even executed is able to corrupt another part of a program.
And if I have done that, I haven't the slightest idea how.
I mean, I can just use the standard date and time routines to construct a date-and-time string. But this behavior is so weird, it has puzzled and intrigued me.
Paul
Paul Robinson paul@paul-robinson.us "The lessons of hisstory teach us - if they teach us anything - that nobody learns the lessons that history teaches us."