B
Big Mike
Hi,
I've been investigating a 'System.NullReferenceException' for about a
week but have not got anywhere with my investigation- I need some
guidance from more experienced .NETers!
My App is .NET 1.1 , built using VS 2003 on XP SP3.
I have not found the exact reproduction criteria for the crash as it
appears to be tranisient. The crash occurs when my GUI app removes a
panel from the parent display container, but it does *not* occur
everytime. The panel being removed contains a few buttons and
ListView components (which is mentioned in the call stack when the
crash is captured). My App uses a Stack to 'push' new panels on top
of app, so they become visible, and then will pop the panels off of
the stack to make the panel underneath visible again.
eg, a button on panel A causes Panel B to be displayed over Panel A.
A button on Panel B causes Panel C to be displayed on top of panel B.
Panel C is 'closed' and Panel B is visible again. Panel B is closed
and Panel A is visibile again
I currently use AutoHotkey to perform the same mouse clicks over and
over again, but with a random time between them, in order to force
this issue. Usually, the issue occurs within 5 or 10 mins. I am
moving in to Panels B and C and back to A every 15 to 30 seconds, but
the issue has also occured after 5 minutes of *no* user activity in
Panel C, (then the panel is automatically closed and we return to
Panel A (through Panel B).
The crash (visually) occurs when Panel B is closed and we return to
panel A. but the crash (i believe) is caused by something in Panel C -
there are no ListView, or indeed any real functionality in Panel B.
When I pop off a panel, a reference is maintined to it as
'oldTopPanel' until another panel is popped of. so in my case, Panel C
finally looses all references to it when we drop back to Panel A from
B.
The actual error is reported in VS 2003 as follows...
A first chance exception of type 'System.NullReferenceException'
occurred in system.windows.forms.dll
Additional information: Object reference not set to an instance of
an object.
the call stack at this time looks like- (Word-wrap may make this look
nasty)
system.windows.forms.dll!
System.Windows.Forms.ListView.ListViewItemCollection.get_Item(int
displayIndex = 0x97) + 0x147 bytes
system.windows.forms.dll!
System.Windows.Forms.ListView.ListViewItemCollection.CopyTo
(System.Array dest = {System.Array}, int index = 0x97) + 0x30 bytes
system.windows.forms.dll!
System.Windows.Forms.ListView.OnHandleDestroyed(System.EventArgs e =
{System.EventArgs}) + 0x12f bytes
system.windows.forms.dll!System.Windows.Forms.Control.WmDestroy
(System.Windows.Forms.Message m = {System.Windows.Forms.Message}) +
0x19 bytes
system.windows.forms.dll!System.Windows.Forms.Control.WndProc
(System.Windows.Forms.Message m = {System.Windows.Forms.Message}) +
0x3ce bytes
system.windows.forms.dll!System.Windows.Forms.ListView.WndProc
(System.Windows.Forms.Message m = {System.Windows.Forms.Message}) +
0x3ce bytes
system.windows.forms.dll!ControlNativeWindow.OnMessage
(System.Windows.Forms.Message m = {System.Windows.Forms.Message}) +
0x13 bytes
system.windows.forms.dll!ControlNativeWindow.WndProc
(System.Windows.Forms.Message m = {System.Windows.Forms.Message}) +
0xda bytes
system.windows.forms.dll!
System.Windows.Forms.NativeWindow.DebuggableCallback(int hWnd =
0x160978, int msg = 0x2, int wparam = 0x0, int lparam = 0x0) + 0x3d
bytes
user32.dll!_InternalCallWinProc@20() + 0x28
user32.dll!_UserCallWinProcCheckWow@32() + 0xb7
user32.dll!_DispatchClientMessage@20() + 0x4d
user32.dll!___fnDWORD@4() + 0x24
ntdll.dll!KiUserCallbackDispatcher() + 0x13
user32.dll!_DispatchMessageW@4() + 0xf
system.windows.forms.dll!
System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods
+IMsoComponentManager.FPushMessageLoop(int dwComponentID = 0x1, int
reason = 0xffffffff, int pvLoopData = 0x0) + 0x349 bytes
system.windows.forms.dll!ThreadContext.RunMessageLoopInner(int reason
= 0xffffffff, System.Windows.Forms.ApplicationContext context =
{System.Windows.Forms.ApplicationContext}) + 0x1f5 bytes
system.windows.forms.dll!ThreadContext.RunMessageLoop(int reason =
0xffffffff, System.Windows.Forms.ApplicationContext context =
{System.Windows.Forms.ApplicationContext}) + 0x50 bytes
system.windows.forms.dll!System.Windows.Forms.Application.Run
(System.Windows.Forms.Form mainForm = {LMU.formMainScreen}) + 0x34
bytes
At this point, I have already dropped out of the Application::Run ();
code (line 88 below), where my APPs gui is launched and onto the next
executable line, 96.
81: formMainScreen *mainForm;
82: try
83: {
84: Application::EnableVisualStyles ();
85: // Application::Run (new frmMain);
86:
87: mainForm = new formMainScreen;
88: Application::Run (mainForm); << GUI
launched here
89:
90: // ... and wait until UI is closed
91:
92:
93: // Signal to main() that the UI thread has terminated (or, at
least, is about to),
94: // allowing main() to terminate also
95:
96: m_ThreadRunning = false;
97: }
98: catch (System::Exception *e)
99: {
100: Exceptions::CException_::ReportException (e);
101: Exceptions::CException_::ReportExceptionToScreen (e);
102:
103: m_ThreadRunning = false;
104: }
What caught me by surprise here is that VS did not break *before* the
null reference access occured as it should do in a 'first-chance'
exception, but after it- the app has already suffered from the
exception! This means that I do not know where the null reference
access is. Q? is this indicitive of managed or unmanaged code?
Also, the call stack looks incorrect in that the code at line 96 of
App.exe does *not* call the functions above it! I don't know how
much of this callstack I can trust. If I can trust the stack, then it
looks like the functions in the stack are part of the framework that
stem from the Application::Run () on line#88. Can anyone else glean
any info from the callstack?
I have a user activated button on Panel C that causes an update to a
ListView component and if I comment out this UpdateDisplay()
functionality, then the issue does not appear to manifest (App as
running for 12 +hours with AHK script running). But the UpdateDisplay
() is one-shot, ie, it does not create a thread to do stuff later- it
does stuff there and then. and of course the issue can occur many
many seconds after this button is clicked.
I have added code to verify that each pointer used in the UpdateDisplay
() is valid before using it, but still crash. I have tried using
DebugDiag to capture the crash at the correct point, and although the
crash is captured, the callstack is different (but I couldn't locate
debug symbols for system.windows.forms.dll,
system_windows_forms_7b810000+100301 058ff7c8 00000000
01702924
system_windows_forms_7b810000+621a0 00000002 058ff784
7b8232c0
system_windows_forms_7b810000+23aa0 00000000 01702924
058ff808
system_windows_forms_7b810000+132c0 004c0a34 00000002
058ff7c8
user32!DefWindowProcW+57 00000002 0021c500 00000000
user32!DefWindowProcW+6b 058ff81c 00000000 01702a74
system_windows_forms_7b810000+56577 00120bb8 00000002
00000000
user32!GetDC+6d 05335d36 00120bb8 00000002
user32!GetDC+14f 00214718 05335d36 00120bb8
user32!DefWindowProcW+180 00822c80 00000002 00000000
user32!DefWindowProcW+1cc 058ff95c 00000018 00822c80
ntdll!KiUserCallbackDispatcher+13 058ffa50 00000000
058ffa84
user32!DispatchMessageW+f 01c5ebd0 01c5dc40 ffffffff
system_windows_forms_7b810000+1df5a 00000000 ffffffff
01c5e234
system_windows_forms_7b810000+1daca 016b780c 01c3c230
01c5e1f4
system_windows_forms_7b810000+1d7e5 016b780c 00000000
01c3c230
system_windows_forms_7b810000+41884 058ffc4c 791dce2f
058ffb88
mscorwks!GetCompileInfo+1001 058ffb88 00000000
058ffb60
mscorwks!GetCompileInfo+18a3 00bca8cb 79b7c000
058ffc78
mscorwks!GetCompileInfo+2de1 79bca8cb 79b7c000
79b93e78
mscorwks!GetCompileInfo+2e4f 058ffd74 0021c500
791b3360
mscorwks!ReleaseFusionInterfaces+41075 058ffd94 001d6cb0
792ea484
mscorwks!ReleaseFusionInterfaces+41144 001d6cb0 00000000
804fb572
mscorwks!Ordinal17+10c4 0021c6b8 00000000 001fea20
kernel32!GetModuleFileNameA+1ba 791c9453 0021c6b8
00000000
I have also tried using CBD/winDbg without luck- both seemed to
present similar responses and call stacks as VS 2003.
I'm coming to the end of things I can try to find the cause of this
issue- Do any of you have any ideas as to how I can proceed with this
investigation. If you need more info then please ask.
Thanks for your interest!
I've been investigating a 'System.NullReferenceException' for about a
week but have not got anywhere with my investigation- I need some
guidance from more experienced .NETers!
My App is .NET 1.1 , built using VS 2003 on XP SP3.
I have not found the exact reproduction criteria for the crash as it
appears to be tranisient. The crash occurs when my GUI app removes a
panel from the parent display container, but it does *not* occur
everytime. The panel being removed contains a few buttons and
ListView components (which is mentioned in the call stack when the
crash is captured). My App uses a Stack to 'push' new panels on top
of app, so they become visible, and then will pop the panels off of
the stack to make the panel underneath visible again.
eg, a button on panel A causes Panel B to be displayed over Panel A.
A button on Panel B causes Panel C to be displayed on top of panel B.
Panel C is 'closed' and Panel B is visible again. Panel B is closed
and Panel A is visibile again
I currently use AutoHotkey to perform the same mouse clicks over and
over again, but with a random time between them, in order to force
this issue. Usually, the issue occurs within 5 or 10 mins. I am
moving in to Panels B and C and back to A every 15 to 30 seconds, but
the issue has also occured after 5 minutes of *no* user activity in
Panel C, (then the panel is automatically closed and we return to
Panel A (through Panel B).
The crash (visually) occurs when Panel B is closed and we return to
panel A. but the crash (i believe) is caused by something in Panel C -
there are no ListView, or indeed any real functionality in Panel B.
When I pop off a panel, a reference is maintined to it as
'oldTopPanel' until another panel is popped of. so in my case, Panel C
finally looses all references to it when we drop back to Panel A from
B.
The actual error is reported in VS 2003 as follows...
A first chance exception of type 'System.NullReferenceException'
occurred in system.windows.forms.dll
Additional information: Object reference not set to an instance of
an object.
the call stack at this time looks like- (Word-wrap may make this look
nasty)
system.windows.forms.dll!
System.Windows.Forms.ListView.ListViewItemCollection.get_Item(int
displayIndex = 0x97) + 0x147 bytes
system.windows.forms.dll!
System.Windows.Forms.ListView.ListViewItemCollection.CopyTo
(System.Array dest = {System.Array}, int index = 0x97) + 0x30 bytes
system.windows.forms.dll!
System.Windows.Forms.ListView.OnHandleDestroyed(System.EventArgs e =
{System.EventArgs}) + 0x12f bytes
system.windows.forms.dll!System.Windows.Forms.Control.WmDestroy
(System.Windows.Forms.Message m = {System.Windows.Forms.Message}) +
0x19 bytes
system.windows.forms.dll!System.Windows.Forms.Control.WndProc
(System.Windows.Forms.Message m = {System.Windows.Forms.Message}) +
0x3ce bytes
system.windows.forms.dll!System.Windows.Forms.ListView.WndProc
(System.Windows.Forms.Message m = {System.Windows.Forms.Message}) +
0x3ce bytes
system.windows.forms.dll!ControlNativeWindow.OnMessage
(System.Windows.Forms.Message m = {System.Windows.Forms.Message}) +
0x13 bytes
system.windows.forms.dll!ControlNativeWindow.WndProc
(System.Windows.Forms.Message m = {System.Windows.Forms.Message}) +
0xda bytes
system.windows.forms.dll!
System.Windows.Forms.NativeWindow.DebuggableCallback(int hWnd =
0x160978, int msg = 0x2, int wparam = 0x0, int lparam = 0x0) + 0x3d
bytes
user32.dll!_InternalCallWinProc@20() + 0x28
user32.dll!_UserCallWinProcCheckWow@32() + 0xb7
user32.dll!_DispatchClientMessage@20() + 0x4d
user32.dll!___fnDWORD@4() + 0x24
ntdll.dll!KiUserCallbackDispatcher() + 0x13
user32.dll!_DispatchMessageW@4() + 0xf
system.windows.forms.dll!
System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods
+IMsoComponentManager.FPushMessageLoop(int dwComponentID = 0x1, int
reason = 0xffffffff, int pvLoopData = 0x0) + 0x349 bytes
system.windows.forms.dll!ThreadContext.RunMessageLoopInner(int reason
= 0xffffffff, System.Windows.Forms.ApplicationContext context =
{System.Windows.Forms.ApplicationContext}) + 0x1f5 bytes
system.windows.forms.dll!ThreadContext.RunMessageLoop(int reason =
0xffffffff, System.Windows.Forms.ApplicationContext context =
{System.Windows.Forms.ApplicationContext}) + 0x50 bytes
system.windows.forms.dll!System.Windows.Forms.Application.Run
(System.Windows.Forms.Form mainForm = {LMU.formMainScreen}) + 0x34
bytes
APP.exe!CUIControl.UIThread() Line 96 C++
At this point, I have already dropped out of the Application::Run ();
code (line 88 below), where my APPs gui is launched and onto the next
executable line, 96.
81: formMainScreen *mainForm;
82: try
83: {
84: Application::EnableVisualStyles ();
85: // Application::Run (new frmMain);
86:
87: mainForm = new formMainScreen;
88: Application::Run (mainForm); << GUI
launched here
89:
90: // ... and wait until UI is closed
91:
92:
93: // Signal to main() that the UI thread has terminated (or, at
least, is about to),
94: // allowing main() to terminate also
95:
96: m_ThreadRunning = false;
97: }
98: catch (System::Exception *e)
99: {
100: Exceptions::CException_::ReportException (e);
101: Exceptions::CException_::ReportExceptionToScreen (e);
102:
103: m_ThreadRunning = false;
104: }
What caught me by surprise here is that VS did not break *before* the
null reference access occured as it should do in a 'first-chance'
exception, but after it- the app has already suffered from the
exception! This means that I do not know where the null reference
access is. Q? is this indicitive of managed or unmanaged code?
Also, the call stack looks incorrect in that the code at line 96 of
App.exe does *not* call the functions above it! I don't know how
much of this callstack I can trust. If I can trust the stack, then it
looks like the functions in the stack are part of the framework that
stem from the Application::Run () on line#88. Can anyone else glean
any info from the callstack?
I have a user activated button on Panel C that causes an update to a
ListView component and if I comment out this UpdateDisplay()
functionality, then the issue does not appear to manifest (App as
running for 12 +hours with AHK script running). But the UpdateDisplay
() is one-shot, ie, it does not create a thread to do stuff later- it
does stuff there and then. and of course the issue can occur many
many seconds after this button is clicked.
I have added code to verify that each pointer used in the UpdateDisplay
() is valid before using it, but still crash. I have tried using
DebugDiag to capture the crash at the correct point, and although the
crash is captured, the callstack is different (but I couldn't locate
debug symbols for system.windows.forms.dll,
system_windows_forms_7b810000+100301 058ff7c8 00000000
01702924
system_windows_forms_7b810000+621a0 00000002 058ff784
7b8232c0
system_windows_forms_7b810000+23aa0 00000000 01702924
058ff808
system_windows_forms_7b810000+132c0 004c0a34 00000002
058ff7c8
user32!DefWindowProcW+57 00000002 0021c500 00000000
user32!DefWindowProcW+6b 058ff81c 00000000 01702a74
system_windows_forms_7b810000+56577 00120bb8 00000002
00000000
user32!GetDC+6d 05335d36 00120bb8 00000002
user32!GetDC+14f 00214718 05335d36 00120bb8
user32!DefWindowProcW+180 00822c80 00000002 00000000
user32!DefWindowProcW+1cc 058ff95c 00000018 00822c80
ntdll!KiUserCallbackDispatcher+13 058ffa50 00000000
058ffa84
user32!DispatchMessageW+f 01c5ebd0 01c5dc40 ffffffff
system_windows_forms_7b810000+1df5a 00000000 ffffffff
01c5e234
system_windows_forms_7b810000+1daca 016b780c 01c3c230
01c5e1f4
system_windows_forms_7b810000+1d7e5 016b780c 00000000
01c3c230
system_windows_forms_7b810000+41884 058ffc4c 791dce2f
058ffb88
mscorwks!GetCompileInfo+1001 058ffb88 00000000
058ffb60
mscorwks!GetCompileInfo+18a3 00bca8cb 79b7c000
058ffc78
mscorwks!GetCompileInfo+2de1 79bca8cb 79b7c000
79b93e78
mscorwks!GetCompileInfo+2e4f 058ffd74 0021c500
791b3360
mscorwks!ReleaseFusionInterfaces+41075 058ffd94 001d6cb0
792ea484
mscorwks!ReleaseFusionInterfaces+41144 001d6cb0 00000000
804fb572
mscorwks!Ordinal17+10c4 0021c6b8 00000000 001fea20
kernel32!GetModuleFileNameA+1ba 791c9453 0021c6b8
00000000
I have also tried using CBD/winDbg without luck- both seemed to
present similar responses and call stacks as VS 2003.
I'm coming to the end of things I can try to find the cause of this
issue- Do any of you have any ideas as to how I can proceed with this
investigation. If you need more info then please ask.
Thanks for your interest!