I have a large application, 18000+ lines long. I've been
fighting problems that I can not understand. It seems that
when I move code around, or place a $SEGMENT compiler directive
in a different place, the weirdness will disappear, at least
for a while. I thought all of this was behind me and I could
make code changes at will, without worrying about weird problems.
But now, I have another problem occuring. I'd like to
understand this.
If I add 3 new variables to my large global declarations file,
called "globals.bas", my application crashes before even getting
started (with an error 5 at 393215). It won't even print the
first print at the beginning of the program.
If I comment out these 3 new variables, the program runs.
If I put these 3 new variables in a new file called
"globals2.bas", and $INCLUDE this after the $INCLUDE for
"globals.bas", it crashes.
Now this is what's really weird. If I comment out these 3 new
variables, so that "globals2.bas" is essentially 3 comment lines,
The program will crash as well.
And if I comment out the $INCLUDE "globals2.bas", the program
will run.
The executable file size (call it "Executable A")
when compiling with
$INCLUDE "globals2.bas"
(which is filled with three comment lines) is the same as when
I compile (call this "Executable B") with
'$INCLUDE "globals2.bas"
This is to be expected. The actual compiled statements are the
same. Yet the compiler code which is output is different.
Executable A crashes, and Executable B runs.
When looking at differences between the two executable files,
with a binary file difference analyzer, there are NUMEROUS
differences.
If I try to use the compiler to find address 393215, it can not
find it. Interestingly enough, 393215 in hex is 5FFFF.
I have assumed that I must be executing code inadvertently in one
of my numerous $INCLUDE statements, so I have tried putting a
print "start" between $INCLUDE sections to see if my code at
least gets there, since my print statement at where I THINK
is the beginning of my code does not execute. The print
statement between $INCLUDEs does indeed print before giving
me the error 5. But again, here is some weirdness.
If I put the print after the last include before one particular
$SEGMENT, I get the "start" message, then error 5. If I put
the print after the $SEGMENT statement, Windows tells me I've
executed an illegal instruction and terminates the application.
If I put the print after the next $INCLUDE in the next
$SEGEMENT, the program will run! Since when should a properly
placed PRINT statement fix the ability of an application to run?
Can ANYONE provide me with insight as to what I may be doing
wrong to cause such weirdness? I am baffled. I can not
apply traditional debugging techniques to these problems.
Thanks in advance.
James
------------------
fighting problems that I can not understand. It seems that
when I move code around, or place a $SEGMENT compiler directive
in a different place, the weirdness will disappear, at least
for a while. I thought all of this was behind me and I could
make code changes at will, without worrying about weird problems.
But now, I have another problem occuring. I'd like to
understand this.
If I add 3 new variables to my large global declarations file,
called "globals.bas", my application crashes before even getting
started (with an error 5 at 393215). It won't even print the
first print at the beginning of the program.
If I comment out these 3 new variables, the program runs.
If I put these 3 new variables in a new file called
"globals2.bas", and $INCLUDE this after the $INCLUDE for
"globals.bas", it crashes.
Now this is what's really weird. If I comment out these 3 new
variables, so that "globals2.bas" is essentially 3 comment lines,
The program will crash as well.
And if I comment out the $INCLUDE "globals2.bas", the program
will run.
The executable file size (call it "Executable A")
when compiling with
$INCLUDE "globals2.bas"
(which is filled with three comment lines) is the same as when
I compile (call this "Executable B") with
'$INCLUDE "globals2.bas"
This is to be expected. The actual compiled statements are the
same. Yet the compiler code which is output is different.
Executable A crashes, and Executable B runs.
When looking at differences between the two executable files,
with a binary file difference analyzer, there are NUMEROUS
differences.
If I try to use the compiler to find address 393215, it can not
find it. Interestingly enough, 393215 in hex is 5FFFF.
I have assumed that I must be executing code inadvertently in one
of my numerous $INCLUDE statements, so I have tried putting a
print "start" between $INCLUDE sections to see if my code at
least gets there, since my print statement at where I THINK
is the beginning of my code does not execute. The print
statement between $INCLUDEs does indeed print before giving
me the error 5. But again, here is some weirdness.
If I put the print after the last include before one particular
$SEGMENT, I get the "start" message, then error 5. If I put
the print after the $SEGMENT statement, Windows tells me I've
executed an illegal instruction and terminates the application.
If I put the print after the next $INCLUDE in the next
$SEGEMENT, the program will run! Since when should a properly
placed PRINT statement fix the ability of an application to run?
Can ANYONE provide me with insight as to what I may be doing
wrong to cause such weirdness? I am baffled. I can not
apply traditional debugging techniques to these problems.
Thanks in advance.
James
------------------
Comment