I have a problem that's driving me crazy!!!
I have a vb6 app with various custom controls. One of them is the CommandBar
control from vbAccelerator. The app hooks into the clipboard notification
queue so that it knows what's being copied and pasted. All controls that I
use (apart from the CommandBar) have 2 distinct error handling functions:
1. SetUnhandledExceptionFilter
2. Log writing
The 2nd method simply writes to a text file in places where I add the
function and always in the error handling routine most functions. It is the
first method that capture the Access Violation Exception.
The problem has 2 symptons:
1. App just crashes with no error message
2. App enters into a loop where it displays the exception error and it looks
like the source is in the CommandBar control (the messagebox title says so!)
I've used the CommandBar control a gazillion times and I never had problems
with it. It is only this combination that is causing the error. I have to
add the control itself doesn't handle errors at all (or maybe in a couple of
places only), and there's quite a few lines of code. Problem is that I can't
run it the IDE as it won't work, so compiling everything and running the
app.
Before I start adding Logwrite functions in each and every function of the
control, is there a way to geenrate more information on the exception, such
as the function (and/or line) that is causing it. Can I create a pdb file
that can be used with some sort of tool to help me trace the exception
source? Are there such tools available?
Help!!
Ivan
I had similar problem many times, and it was usualy bad pointer.
there is some error in your code with pointer some pointer is pointing to memory not owned by your process!
you have next API's
Public Declare Function IsBadCodePtr Lib "kernel32" (ByRef lpFarProc As Any) As Long
Public Declare Function IsBadReadPtr Lib "kernel32" (ByRef lp As Any, ByVal ucb As Long) As Long
Public Declare Function IsBadStringPtr Lib "kernel32" (ByRef lpStr As Any, ByVal ucb As Long) As Long
Public Declare Function IsBadWritePtr Lib "kernel32" (ByRef lp As Any, ByVal ucb As Long) As Long
you can use them to verify exact point where your problem has occured, but it might not be in place you said, it could be at some
other point for example, you have made clipboard notification, for clipboard to send you an event he must call some memory address
in you application but if that address does not belong to your process it will likely crash (I asume that that is a problem) or
something similar check if you have any hooks or other notifications.
I am interested how did you implement SetUnhandledExceptionFilter, could you paste us some code?
[SolarAngel]
"Ivan Debono" <ivan...@hotmail.com> wrote in message news:eErAp$euFHA...@TK2MSFTNGP09.phx.gbl...
| Processed by 'SolarAngel-yVBProxy Ver:1.03.0100' contact yvbp...@www.yu for more information!
If the crash is caused by a custom control, you will have to compile that
with debug info as well, otherwise, VC++ will not show you the source line
where the error occurred in the custom control. If this happens, the line
highlighted in your code is a property or method call to that custom
control.
"Ivan Debono" <ivan...@hotmail.com> wrote in message
news:eErAp$euFHA...@TK2MSFTNGP09.phx.gbl...
Here's the code. This is the basic function that I used to further improve
my own but it gets you started.
'In a form (Form)
Private Sub Form_Load()
'Make sure all unhandled errors are caught by our procedure
SetUnhandledExceptionFilter AddressOf MyExceptionHandler
'Raise an unhandled exception
RaiseException 0, 0, 0, 0
End Sub
Private Sub Form_Unload(Cancel As Integer)
'Remove the hook
SetUnhandledExceptionFilter ByVal 0&
End Sub
'In a Module
Public Const EXCEPTION_CONTINUE_EXECUTION = -1
Public Const EXCEPTION_CONTINUE_SEARCH = 0
Public Const EXCEPTION_MAXIMUM_PARAMETERS = 15
Public Type CONTEXT
FltF0 As Double
FltF1 As Double
FltF2 As Double
FltF3 As Double
FltF4 As Double
FltF5 As Double
FltF6 As Double
FltF7 As Double
FltF8 As Double
FltF9 As Double
FltF10 As Double
FltF11 As Double
FltF12 As Double
FltF13 As Double
FltF14 As Double
FltF15 As Double
FltF16 As Double
FltF17 As Double
FltF18 As Double
FltF19 As Double
FltF20 As Double
FltF21 As Double
FltF22 As Double
FltF23 As Double
FltF24 As Double
FltF25 As Double
FltF26 As Double
FltF27 As Double
FltF28 As Double
FltF29 As Double
FltF30 As Double
FltF31 As Double
IntV0 As Double
IntT0 As Double
IntT1 As Double
IntT2 As Double
IntT3 As Double
IntT4 As Double
IntT5 As Double
IntT6 As Double
IntT7 As Double
IntS0 As Double
IntS1 As Double
IntS2 As Double
IntS3 As Double
IntS4 As Double
IntS5 As Double
IntFp As Double
IntA0 As Double
IntA1 As Double
IntA2 As Double
IntA3 As Double
IntA4 As Double
IntA5 As Double
IntT8 As Double
IntT9 As Double
IntT10 As Double
IntT11 As Double
IntRa As Double
IntT12 As Double
IntAt As Double
IntGp As Double
IntSp As Double
IntZero As Double
Fpcr As Double
SoftFpcr As Double
Fir As Double
Psr As Long
ContextFlags As Long
Fill(4) As Long
End Type
Public Type EXCEPTION_RECORD
ExceptionCode As Long
ExceptionFlags As Long
pExceptionRecord As Long ' Pointer to an EXCEPTION_RECORD structure
ExceptionAddress As Long
NumberParameters As Long
ExceptionInformation(EXCEPTION_MAXIMUM_PARAMETERS - 1) As Long
End Type
Public Type EXCEPTION_POINTERS
pExceptionRecord As EXCEPTION_RECORD
ContextRecord As CONTEXT
End Type
Public Enum EFaultRepRetVal
frrvOk = 0
frrvOkManifest = 1
frrvOkQueued = 2
frrvErr = 3
frrvErrNoDW = 4
frrvErrTimeout = 5
frrvLaunchDebugger = 6
frrvOkHeadless = 7
End Enum
Public Declare Function ReportFault Lib "Faultrep" (pep As
EXCEPTION_POINTERS, ByVal dwMode As Long) As EFaultRepRetVal
Public Declare Sub RaiseException Lib "kernel32" (ByVal dwExceptionCode As
Long, ByVal dwExceptionFlags As Long, ByVal nNumberOfArguments As Long,
lpArguments As Long)
Public Declare Function SetUnhandledExceptionFilter Lib "kernel32" (ByVal
lpTopLevelExceptionFilter As Long) As Long
Public Function MyExceptionHandler(lpEP As EXCEPTION_POINTERS) As Long
'Show the WindowsXP Error Reporting dialog
ReportFault lpEP, 0
'Continue execution
MyExceptionHandler = EXCEPTION_CONTINUE_EXECUTION
End Function
"[SolarAngel]" <not-for-mail> schrieb im Newsbeitrag
news:%2303MPcg...@TK2MSFTNGP12.phx.gbl...
Ivan
"Someone" <nob...@cox.net> schrieb im Newsbeitrag
news:njtWe.36391$ct5.22700@fed1read04...
Yes. Go to Tools|Debug Process, select your process and click Attach, and
then select Native. You could View the call stack by going to
Debug|Windows|Call Stack. Debug|Exception lets you control what happens when
an exception occurs. By default, it breaks in the debugger for Access
Violation and most unhandled Win32 Exceptions.
I forgot to mention in my last email that when you are viewing VB6 source
code, you could right click on a line and select "Go to Disassembly". This
works in both VC 6.0 and .Net 2003, just tested both.
"Ivan Debono" <ivan...@hotmail.com> wrote in message
news:%23kxvLqo...@TK2MSFTNGP10.phx.gbl...
Does the disassembly show the assembly code or the vb code?
Ivan
"Someone" <nob...@cox.net> schrieb im Newsbeitrag
news:z%uWe.38080$ct5.27777@fed1read04...
If you have the PDB file, it shows both in mixed mode, if you don't have it,
it shows the assembly only.
"Ivan Debono" <ivan...@hotmail.com> wrote in message
news:OXLEJzpu...@TK2MSFTNGP12.phx.gbl...
Ivan
"Someone" <nob...@cox.net> schrieb im Newsbeitrag
news:wJAWe.42238$ct5.40294@fed1read04...
When I close the app, I get a messagebox with an exclamation icon that says:
Runtime error '0'. The app ends normally though.
I've checked my source code, and there's no such messagebox that's being
displayed. The eventviewer shows nothing too.
Is there a way to locate the error source for this bug?
Thanks,
Ivan
"Someone" <nob...@cox.net> schrieb im Newsbeitrag
news:wJAWe.42238$ct5.40294@fed1read04...
When the dialog appears, don't click it. Go to Debug|Break, and look at the
Call Stack. It may not point to a source code line though.
Some people have found anomalies in the Err object. One way to reduce them
is setting everything that you set a reference to; to Nothing in
Form_Unload. Use Erase <Dynamic array name>, to release memory used by
dynamic arrays...
"Ivan Debono" <ivan...@hotmail.com> wrote in message
news:OzQ1iy0u...@TK2MSFTNGP09.phx.gbl...
Apart from that I'm very environment-friendly and I take care of my garbage
collection !!
Ivan
"Someone" <nob...@cox.net> schrieb im Newsbeitrag
news:dvVWe.42306$ct5.41922@fed1read04...
http://www.mztools.com/v3/mztools3.htm
"Ivan Debono" <ivan...@hotmail.com> wrote in message
news:eA7HqO5u...@TK2MSFTNGP14.phx.gbl...
Ivan
"Someone" <nob...@cox.net> schrieb im Newsbeitrag
news:13WWe.42313$ct5.16273@fed1read04...
OS: WIN2K SP2 (with some patches)
MSVB6.0 SP5 ED
MSVC++ 6.0 ED
What could be the problem with my Visual C++?
[SolarAngel]
"Someone" <nob...@cox.net> wrote in message news:njtWe.36391$ct5.22700@fed1read04...
"[SolarAngel]" <not-for-mail> wrote in message
news:eoXSl9Rv...@TK2MSFTNGP09.phx.gbl...
But I have success debuging VBProjects:
Open MSVC, close workspace, add EXE file (creating new workspace), and start EXE from the inside of MSVC, he will capture all
exceptions and I can debug as you have mentioned before.
[SolarAngel]
"Someone" <nob...@cox.net> wrote in message news:ilzXe.43226$ct5.31593@fed1read04...