Skip to main content
gamedev.net
🔒 Locked

Odd class behavior?

Started by ms291052 2 replies 550+ views
Original Post
ms291052
ms291052
I recently began modifying some of the classes in my app to be a bit more logical and hierarchical. However, after modifying some of the class definitions and everything, the code compiled, and had no errors that I could find. At runtime, however, all of a sudden I''m getting loads of System.NullReferenceException errors as well as a bunch of ASSERTs (which I didn''t use at all). The NullRefExceptions are occuring in stupid places including one line that just says if(m_bReady). Does anyone have any idea how to fix this? P.S. If it matters at all, I have two classes that I modified called THING and MESH. THING has a mesh member, and also stores bounding spheres, position, velocity, etc. The change I made was moving the three variables that stored the LPD3DXMesh data from the THING class to the MESH class. The only three variables I moved were WORD* m_Indices, MODELVERTEX* m_Vertices, and D3DXPLANE m_Faces.
brassfish89
brassfish89
Sounds like data corruption (ie overwriting arrays, using delete''d pointers, etc). Check every single array/stl container/pointer in your program and make sure you aren''t doing anything you shouldn''t be doing to them. Running it through a debugger and setting watchpoints should help, too.

--------
"Hey, what about those baggy pants you kids are wearin'' these days? Aren''t they hip and cool and poppin'' fresh?"-Peter Griffin
"Everytime I see an M followed by a dollar sign I just say "oh god" and go to the next post."-Neurokaotix
the D programming language|google|msdn|XLib reference manual
ms291052
ms291052
Well the debug output doesn't seem to be that useful. It tells me that apparently an Index Buffer failed to be created, that I have a NullReferenceException, and that I have memory leaks big time. The problem is that it doesn't tell me where in the code these problems are, since I don't know how to tell which variables are stored at which memory locations. If it means anything to anyone else, here's what the debugger spits out:


Direct3D9: (INFO) :Failed to create driver indexbuffer
First-chance exception at 0x0044aec9 in target.exe: 0xC0000005: Access violation reading location 0xffffffff.
An unhandled exception of type 'System.NullReferenceException' occurred in target.exe

Additional information: Object reference not set to an instance of an object.

'target.exe': Loaded 'C:\WINDOWS\system32\ntdll.dll', No symbols loaded.
'target.exe': Loaded 'C:\WINDOWS\system32\mscoree.dll', No symbols loaded.
'target.exe': Loaded 'C:\WINDOWS\system32\kernel32.dll', No symbols loaded.
'target.exe': Loaded 'C:\WINDOWS\system32\advapi32.dll', No symbols loaded.
'target.exe': Loaded 'C:\WINDOWS\system32\rpcrt4.dll', No symbols loaded.
'target.exe': Loaded 'C:\WINDOWS\system32\d3dx9d.dll', No symbols loaded.
'target.exe': Loaded 'C:\WINDOWS\system32\msvcrt.dll', No symbols loaded.
'target.exe': Loaded 'C:\WINDOWS\system32\user32.dll', No symbols loaded.
'target.exe': Loaded 'C:\WINDOWS\system32\gdi32.dll', No symbols loaded.
'target.exe': Loaded 'C:\WINDOWS\system32\d3d9.dll', No symbols loaded.
'target.exe': Loaded 'C:\WINDOWS\system32\d3d8thk.dll', No symbols loaded.
'target.exe': Loaded 'C:\WINDOWS\system32\version.dll', No symbols loaded.
'target.exe': Loaded 'C:\WINDOWS\system32\winmm.dll', No symbols loaded.
'target.exe': Loaded 'C:\WINDOWS\system32\imm32.dll', No symbols loaded.
'target.exe': Loaded 'C:\WINDOWS\system32\lpk.dll', No symbols loaded.
'target.exe': Loaded 'C:\WINDOWS\system32\usp10.dll', No symbols loaded.
'target.exe': Loaded 'C:\WINDOWS\system32\SHLWAPI.DLL', No symbols loaded.
'target.exe': Loaded 'C:\WINDOWS\Microsoft.NET\Framework\v1.0.3705\mscorwks.dll', No symbols loaded.
'target.exe': Loaded 'C:\WINDOWS\Microsoft.NET\Framework\v1.0.3705\msvcr70.dll', No symbols loaded.
'target.exe': Loaded 'C:\WINDOWS\Microsoft.NET\Framework\v1.0.3705\fusion.dll', No symbols loaded.
'target.exe': Loaded 'C:\WINDOWS\system32\shell32.dll', No symbols loaded.
'target.exe': Loaded 'C:\WINDOWS\WinSxS\x86_Microsoft.Windows.Common-Controls_6595b64144ccf1df_6.0.10.0_x-ww_f7fb5805\comctl32.dll', No symbols loaded.
'target.exe': Loaded 'C:\WINDOWS\system32\comctl32.dll', No symbols loaded.
'target.exe': Loaded 'C:\WINDOWS\Microsoft.NET\Framework\v1.0.3705\mscorlib.dll', No symbols loaded.
'target.exe': Loaded 'C:\WINDOWS\system32\ole32.dll', No symbols loaded.
'target.exe': Loaded 'C:\WINDOWS\Microsoft.NET\Framework\v1.0.3705\diasymreader.dll', No symbols loaded.
'DefaultDomain': Loaded 'c:\windows\microsoft.net\framework\v1.0.3705\mscorlib.dll', No symbols loaded.
'target.exe': Loaded 'C:\WINDOWS\Microsoft.NET\Framework\v1.0.3705\mscorsn.dll', No symbols loaded.
'target.exe': Loaded 'C:\WINDOWS\Microsoft.NET\Framework\v1.0.3705\mscorjit.dll', No symbols loaded.
'target': Loaded 'd:\My Documents\Austin\programming\Target Game\Target Game IV\Debug\target.exe', Symbols loaded.
'target.exe': Loaded 'C:\WINDOWS\system32\uxtheme.dll', No symbols loaded.
'target.exe': Loaded 'C:\WINDOWS\system32\MSCTF.dll', No symbols loaded.
'target.exe': Loaded 'C:\WINDOWS\system32\MSCTFIME.IME', No symbols loaded.
'target.exe': Loaded 'C:\WINDOWS\system32\d3d9d.dll', No symbols loaded.
Direct3D9: (INFO) :Pentium Pro CPU features (fcomi, cmov) detected

Direct3D9: (INFO) :dwCPUFamily = 15, dwCPUFeatures = 3

Direct3D9: (INFO) :szCPUString = GenuineIntel

Direct3D9: (INFO) :Direct3D9 Debug Runtime selected.
Direct3D9: (INFO) :======================= Hal SWVP device selected

Direct3D9: (INFO) :HalDevice Driver Style 9

Direct3D9: (INFO) :Failed to create driver indexbuffer
'Direct3D HAL (SWVP) Device 1': Attached to debug monitor.
'target.exe': Loaded 'C:\WINDOWS\system32\d3dxof.dll', No symbols loaded.
D3DX: (INFO) Using SSE2 Instructions
'target.exe': Loaded 'C:\WINDOWS\system32\MSIMTF.dll', No symbols loaded.
'target.exe': Loaded 'C:\WINDOWS\system32\mslbui.dll', No symbols loaded.
'target.exe': Loaded 'C:\WINDOWS\system32\oleaut32.dll', No symbols loaded.
'target.exe': Loaded 'D:\Program Files\McAfee\McAfee VirusScan\Wbhook32.dll', No symbols loaded.
'target.exe': Loaded 'D:\Program Files\McAfee\McAfee VirusScan\Res00\WbhkRes.dll', No symbols loaded.
First-chance exception at 0x0044aec9 in target.exe: 0xC0000005: Access violation reading location 0xffffffff.
An unhandled exception of type 'System.NullReferenceException' occurred in target.exe

Additional information: Object reference not set to an instance of an object.

Direct3D9: (INFO) :MemFini!
Direct3D9: (ERROR) :Memory still allocated! Alloc count = 536
Direct3D9: (ERROR) :Current Process (pid) = 000009dc
Direct3D9: (ERROR) :Memory Address: 003654b4 lAllocID=1 dwSize=000047f8, ReturnAddr=039d3796 (pid=000009dc)
Direct3D9: (ERROR) :Memory Address: 0036b414 lAllocID=9 dwSize=00000bd0, ReturnAddr=039ce1e9 (pid=000009dc)
Direct3D9: (ERROR) :Memory Address: 0036306c lAllocID=10 dwSize=00000008, ReturnAddr=039ce289 (pid=000009dc)
Direct3D9: (ERROR) :Memory Address: 0036c01c lAllocID=11 dwSize=00000140, ReturnAddr=039d2f45 (pid=000009dc)
Direct3D9: (ERROR) :Memory Address: 0036c194 lAllocID=20 dwSize=000006bc, ReturnAddr=039df12f (pid=000009dc)
Direct3D9: (ERROR) :Memory Address: 00369ce4 lAllocID=22 dwSize=00001008, ReturnAddr=039d478b (pid=000009dc)
Direct3D9: (ERROR) :Memory Address: 0036302c lAllocID=24 dwSize=00000008, ReturnAddr=039d48bc (pid=000009dc)
Direct3D9: (ERROR) :Memory Address: 03b90064 lAllocID=26 dwSize=00003500, ReturnAddr=039d3796 (pid=000009dc)
Direct3D9: (ERROR) :Memory Address: 0036ad24 lAllocID=27 dwSize=00000198, ReturnAddr=039d3796 (pid=000009dc)
Direct3D9: (ERROR) :Memory Address: 00362cdc lAllocID=28 dwSize=00000030, ReturnAddr=039d3796 (pid=000009dc)
Direct3D9: (ERROR) :Memory Address: 03b9359c lAllocID=29 dwSize=00001020, ReturnAddr=039d3796 (pid=000009dc)
Direct3D9: (ERROR) :Total Memory Unfreed From Current Process = 45764 bytes
D3DX: MEMORY LEAKS DETECTED: 28 allocations unfreed (15137 bytes)



[edited by - ms291052 on January 3, 2004 2:11:24 PM]
psykr
psykr
quote:
First-chance exception at 0x0044aec9 in target.exe: 0xC0000005: Access violation reading location 0xffffffff.
From personal experience, I know that 0xC0000005 means you''re dereferencing an invalid pointer (I wonder if there''s some kind of standard/guide for these odd errors..), and your debug output says that the error is that you''re dereferencing a pointer that''s 0xffffffff, or -1. Most likely one of your functions returns -1 as an error code instead of a pointer, and you''re dereferencing the pointer instead of checking the error code.
quote:
Additional information: Object reference not set to an instance of an object.
This probably means that you have an object reference declared but not initialized.

Then again, it seems like you''re using .NET, which I know nothing about. It may be some problem with the framework, and not your code (i.e. you''re using it wrong)

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.