I have a program that compiles fine and makes a 653K EXE
file. When I run the program on NT 4 Service Pack 6, or Windows 98, or
Windows 95, or a Windows 2000 machine the program crashes with a page
fault in Kernel32.dll, which is a very odd place for a page fault. . .
The machine code at the crash point always involves trying use data at
memory address [ebx] and the register ebx always contains a 0 that came off the stack.
It appears that a value of 0 is being passed to Kernel32.dll instead of a good memory address.
I am making these three calls to the Kernel32.dll:
DECLARE FUNCTION GetShortPathName LIB "KERNEL32.DLL" ALIAS "GetShortPathNameA" (lpszLongPath AS ASCIIZ, lpszShortPath AS ASCIIZ, BYVAL cchBuffer AS LONG) AS LONG
DECLARE FUNCTION GetCommandLine LIB "KERNEL32.DLL" ALIAS "GetCommandLineA" () AS DWORD
DECLARE FUNCTION CopyFile LIB "KERNEL32.DLL" ALIAS "CopyFileA" (lpExistingFileName AS ASCIIZ, lpNewFileName AS ASCIIZ, BYVAL bFailIfExists AS LONG) AS LONG
. . . and the crash sometimes is near the point CopyFile is used . . .
I am pretty sure these calls are not the cause of the problem.
When I try to find the point that the program
crashes by inserting message boxes the crash jumps to another spot
in the program. It seems to be always near areas where external
DLL's are being called or global arrays are being redimmed, but I am
not 100% sure. If I touch the source the crash spot jumps. If I run
the EXE more than once the crash is in the same spot, the error only jumps
after a new compile after changing the source slightly. So, it is
not acting anything like a normal GFP fault that is very easy to pen point
with messages boxes or a log file. Those normally do not jump at all and are
always in my EXE and DLL files and not the Kernel32.dll.
If I comment out just 300 lines of source the problem will only hit
NT machines (Service pack 4 and 6). The Windows 95, 98 and 2000 machines are
okay or at least seem to be okay, but I do not trust a program that crashes on NT but not 98.
Commenting out around 1000 lines of source anywere in the
program caused the Kernel32.dll crash to vanish on all systems.
To get around this problem I had to move a large piece of code to a DLL
and out of the main EXE. The main EXE has a size of 572K now.
I wonder what is going on?
Tim
------------------
file. When I run the program on NT 4 Service Pack 6, or Windows 98, or
Windows 95, or a Windows 2000 machine the program crashes with a page
fault in Kernel32.dll, which is a very odd place for a page fault. . .
The machine code at the crash point always involves trying use data at
memory address [ebx] and the register ebx always contains a 0 that came off the stack.
It appears that a value of 0 is being passed to Kernel32.dll instead of a good memory address.
I am making these three calls to the Kernel32.dll:
DECLARE FUNCTION GetShortPathName LIB "KERNEL32.DLL" ALIAS "GetShortPathNameA" (lpszLongPath AS ASCIIZ, lpszShortPath AS ASCIIZ, BYVAL cchBuffer AS LONG) AS LONG
DECLARE FUNCTION GetCommandLine LIB "KERNEL32.DLL" ALIAS "GetCommandLineA" () AS DWORD
DECLARE FUNCTION CopyFile LIB "KERNEL32.DLL" ALIAS "CopyFileA" (lpExistingFileName AS ASCIIZ, lpNewFileName AS ASCIIZ, BYVAL bFailIfExists AS LONG) AS LONG
. . . and the crash sometimes is near the point CopyFile is used . . .
I am pretty sure these calls are not the cause of the problem.
When I try to find the point that the program
crashes by inserting message boxes the crash jumps to another spot
in the program. It seems to be always near areas where external
DLL's are being called or global arrays are being redimmed, but I am
not 100% sure. If I touch the source the crash spot jumps. If I run
the EXE more than once the crash is in the same spot, the error only jumps
after a new compile after changing the source slightly. So, it is
not acting anything like a normal GFP fault that is very easy to pen point
with messages boxes or a log file. Those normally do not jump at all and are
always in my EXE and DLL files and not the Kernel32.dll.
If I comment out just 300 lines of source the problem will only hit
NT machines (Service pack 4 and 6). The Windows 95, 98 and 2000 machines are
okay or at least seem to be okay, but I do not trust a program that crashes on NT but not 98.
Commenting out around 1000 lines of source anywere in the
program caused the Kernel32.dll crash to vanish on all systems.
To get around this problem I had to move a large piece of code to a DLL
and out of the main EXE. The main EXE has a size of 572K now.
I wonder what is going on?
Tim
------------------
Comment