|
-
Jun 15th, 2011, 03:03 PM
#1
Thread Starter
Junior Member
[RESOLVED] Crash on Exit
I have a legacy vb6 app that crashes on exit - both as an executable and in the IDE. I am currently unloading the forms (except the frmmain) in form_unload, releasing all the adodb recordsets, setting all the boundcollections = nothing, I have attempted to SetErrorMode SEM_NOGPFAULTERRORBOX in the form_terminate event and that has not stopped the error from occurring. I have also checked for subclasses being instantiated in my code and found none. I have checked into the components from outside MS that are used - they are the Componentone flexgrid 8 spelling 8 and componentOne sizer control. An extensive web and forum search has not turned up any known problems similar to mine for these controls. The issue does not seem to occur if I shut down the program before actually doing anything. However loading the bound controls seems to be near where the problem is rooted, in spite of repeatedly stepping with the debugger it seems that the start of the problem "moves around". The problem occurs with the programmatic exit, the "X" and the IDE "end" control
The error message is
The instruction at "0x77d042b8" referenced memory at "0x055c9028". The memory could not be "Read". The title in the error box is a tool tip (differing at different times) from inside my app
-
Jun 15th, 2011, 06:01 PM
#2
Re: Crash on Exit
most likely, subclassing prob...
put msgboxes in between your Unload lines to see where it reaches before the crash.. so you isolate the prob
_____________________________________________________________________
----If this post has helped you. Please take time to Rate it.
----If you've solved your problem, then please mark it as RESOLVED from Thread Tools.

-
Jun 16th, 2011, 07:01 AM
#3
Re: Crash on Exit
Put break pointers 'n each of these event handlers, then do F8 when execution stops - this way you can at least identify which line causes crash.
Code:
Private Sub Form_Load()
End Sub
Private Sub Form_QueryUnload(Cancel As Integer, UnloadMode As Integer)
End Sub
Private Sub Form_Terminate()
End Sub
-
Jun 16th, 2011, 08:35 AM
#4
Thread Starter
Junior Member
Re: Crash on Exit
I have put breaks when stepping through the code - the app crashes on the exit sub line at the Form_Unload event, I realized that I should have included some other information with my original post. I was very tired and frustrated when I made it and sorry it was so difficult to read.
Now
1) I do have the latest service pack (6) installed, and the latest builds of the components
2) doing a debug in my VS2010 ide (which is on the same server) I got a very long stack dump beginning with OLEAUT32.dll, I updated that DLL but found no change
3) I am actually running (and working on) the program through a remote desktop connection. The program crashes on my desktop as well as on the users terminal server connections.
4) The OS I am running under is Windows Server 2003
5) the code I am running is
Code:
Private Sub Form_Unload(Cancel As Integer)
Set rsChild = Nothing
Set rsCaseFile = Nothing
' many similar record sets closing
ys.CloseConnection
Set ys = Nothing
UnloadAllForms (Me.Name)
' closeing bound collections
Set bndChild = Nothing
Set bndAuth = Nothing
' more bound collections closed
' i had added the next two lines but it made no difference
frmmain.close
Set frmMain = nothing
end sub
Public Sub UnloadAllForms(Optional FormToIgnore As String = "")
Dim f As Form
For Each f In Forms
If Not f Is Nothing Then
If f.Name <> FormToIgnore Then
Unload f
Set f = Nothing
End If
End If
Next f
End Sub
6) I have added a "getout" routine in the start up module on the hope that will allow the form object to close cleanly, the dba has the test server down at the moment and I have not been able to test it yet
Thank you all so much for your help
-
Jun 16th, 2011, 08:46 AM
#5
Re: Crash on Exit
frmmain.close
Set frmMain = nothing
The above you don't need!!
_____________________________________________________________________
----If this post has helped you. Please take time to Rate it.
----If you've solved your problem, then please mark it as RESOLVED from Thread Tools.

-
Jun 16th, 2011, 02:46 PM
#6
Re: Crash on Exit
If the Recordsets are ADODB.Recordsets, you might want to try this instead of just setting them to Nothing - I have a vague memory of having problems a long time ago when setting recordsets to Nothing without closing them first:
Code:
If Not rsChild Is Nothing Then
If rsChild.State = adStateOpen Then
rsChild.Close
End If
Set rsChild = Nothing
End If
Also, what are bndChild and bndAuth? Does it help to move them before the UnloadAllForms call?
Last edited by jpbro; Jun 17th, 2011 at 12:58 PM.
Reason: Typo
-
Jun 17th, 2011, 08:16 AM
#7
Thread Starter
Junior Member
Re: Crash on Exit
Okay, you can call me dim - I really dont understand what the code is doing well enough to insert it in my code.
and
is there some way I can enumerate recordsets similar to how forms can be done
Code:
dim f as form
for each f in forms
' do some things
next f
thank you for the assistance
-
Jun 17th, 2011, 08:54 AM
#8
Re: Crash on Exit
Are you saying you don't even know how many public recordset object you have? Well, if that's the case you may add each of them to public collection object every you instantiate new recordset - collection can be destroyed upon exiting (loop through collection items, destroy each and then destroy collection itself).
Anyway, it sounds like you have a seroius flaw in your program so maybe it's a perfect time to revisit it.
-
Jun 17th, 2011, 09:06 AM
#9
Thread Starter
Junior Member
Re: Crash on Exit
No but I have some 15 applications that share this problem, and each one might have 20 or more record sets with different names in it, so if I could figure out one close routine that could work for all of them it would be a real time saver.
Also the code is complex enough (and totally and completely undocumented) that one cannot be sure what recordsets would be open. The company is working like crazy to replace all this mess but I pulled the short straw and get to support it until we can replace it
-
Jun 17th, 2011, 09:18 AM
#10
Re: Crash on Exit
But you have fixed number of object variables (adodb.recordset type in this case) so why can't you reset them all to Nothing befoire exiting?
Also, why do even need that many all the time? Like I said it's design flaw and it's common too as many programmers don't think "memory" in advance.
-
Jun 17th, 2011, 12:14 PM
#11
Thread Starter
Junior Member
Re: Crash on Exit
It appears that the bug is dead, the kill was in 10 parts
(and @Rhinobull you can see your work in here)
1) very carefully disposing of all objects
2) confirming that each recordset was closed before it was set to nothing
3) closing each form from the last forms close event
4) set the last form .visible = false then called a timer for 1 second
5) added a getout call to the bottom of the last forms unload event
6) put the getout in a module
7) added
vb Code:
[code] Private Declare Function SetErrorMode Lib "kernel32" ( _ ByVal wMode As Long) As Long Private Const SEM_FAILCRITICALERRORS = &H1 Private Const SEM_NOGPFAULTERRORBOX = &H2 Private Const SEM_NOOPENFILEERRORBOX = &H8000& [/code]
to the declarations in that module
8) called that declaration with
vb Code:
[code] SetErrorMode SEM_NOGPFAULTERRORBOX [/code]
at the start of the getout sub
9) confirmed that the last open form was closed
10) included this code at the bottom of the getout sub to make sure it could close
vb Code:
[code] Dim tstart As Date tstart = TimeValue(Now()) Dim i As Integer i = 0 Do While (DateAdd("s", 3, tstart)) > TimeValue(Now()) For i = 0 To 1000 i = i + 1 Next i = 0[/code]
Code:
Loop
' endtask("PLacements")
End
that last part was sorta the equivalent of driving wooden stake into its heart
thank you all for the help you have given me - I'll try and pay it back when I can
-
Jun 17th, 2011, 12:14 PM
#12
Member
Re: Crash on Exit
First: Try to unload all Available Add-ins. From VB6 >> Add-Ins >> Add-In Manager... (unload All available add-ins).
Second: Simply put CommonDialog (COMDLG32.OCX) without code in your application (main form when you close button X) and try to recompile.
Open your application and try to exit. Crash?
Sorry for my english, because I am not an english teacher. Have a nice day. everybody.
-
Jun 17th, 2011, 04:42 PM
#13
Re: Crash on Exit
 Originally Posted by IronHead83
I have put breaks when stepping through the code - the app crashes on the exit sub line at the Form_Unload event, I realized that I should have included some other information with my original post. I was very tired and frustrated when I made it and sorry it was so difficult to read.
Now
1) I do have the latest service pack (6) installed, and the latest builds of the components
2) doing a debug in my VS2010 ide (which is on the same server) I got a very long stack dump beginning with OLEAUT32.dll, I updated that DLL but found no change
3) I am actually running (and working on) the program through a remote desktop connection. The program crashes on my desktop as well as on the users terminal server connections.
4) The OS I am running under is Windows Server 2003
5) the code I am running is
Code:
Private Sub Form_Unload(Cancel As Integer)
Set rsChild = Nothing
Set rsCaseFile = Nothing
' many similar record sets closing
ys.CloseConnection
Set ys = Nothing
UnloadAllForms (Me.Name)
' closeing bound collections
Set bndChild = Nothing
Set bndAuth = Nothing
' more bound collections closed
' i had added the next two lines but it made no difference
frmmain.close
Set frmMain = nothing
end sub
Public Sub UnloadAllForms(Optional FormToIgnore As String = "")
Dim f As Form
For Each f In Forms
If Not f Is Nothing Then
If f.Name <> FormToIgnore Then
Unload f
Set f = Nothing
End If
End If
Next f
End Sub
6) I have added a "getout" routine in the start up module on the hope that will allow the form object to close cleanly, the dba has the test server down at the moment and I have not been able to test it yet
Thank you all so much for your help
 Originally Posted by some1uk03
frmmain.close
Set frmMain = nothing
The above you don't need!!
@IronHead83: I suspect that that's not your actual code because if it were, 'nothing' would be capitalized. Also there is no 'Close' method associated with forms so perhaps you meant unload.
@some1uk03: If the code is
Unload frmMain
Set frmMain = Nothing
then you should set frmMain to Nothing because if you don't, Private and Public variables in the form will retain their values.
-
Jun 18th, 2011, 09:52 PM
#14
PowerPoster
Re: Crash on Exit
Try doing this source code, when you are trying to exit the whole application from running...
Code:
Public Sub Form_Unload(Cancel As Integer)
Cancel = 1
MsgBox Debug
End Sub
I have a huge free products range, of computer software in which you can download using any kind of 64-Bit Web Browser. Also there is coming a Social Networking section that I am making on my Website...
|Ambra Productions Inc. | The Black Sun Society | The Black Shield | Ambra College | Church of the Black Sun | Ambra Productions Inc's Homepage | Boomtick Venues: Ambar Nightclub, Jack Rabbit Slim's, Villa Nightclub and Lucy's Love Shack | Pasta Ambra | Fish Feast Company | Wallet Wizard | Ambrose Liquor | Ambar Tavern | Ambra University | Ambra Cheese |
Do you wish to do unpaid work for me??? If so, the PM me on this Forum, and then we can get to work, programming for the future of computers go by the name of ThEiMp. This is my ghost writers name. Also my nickname, means that I am: The Imperial of the Technology Industry, so then to make it really short, I just then wrote: The Imp, which is where I get the nickname from...
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|