Sign in to follow this  
HeroOfSpielburg

[MDX] Can't pass Direct3DCreate9 with Debug version of D3D9

Recommended Posts

Hello everyone, This hasn't always been the case, but recently something has happened to prevent me from using the Debug version of Direct3D 9. Initially I had the problem with the April 2007 SDK, but now I'm on June 2007 SDK and still having the same problem. If I set the version to Retail in the DX Control Panel, things run fine, but set it to Debug and I tank at my call to Direct3DCreate9(D3D_SDK_VERSION), even if it's the first line in my program. Normally I would expect this to return NULL if it wasn't going to work, not cause an exception somewhere inside. The dialog box that appears displays: "Windows has triggered a breakpoint in GameD.exe. This may be due to a corruption of the heap, and indicates a bug in GameD.exe or any of the DLLs it has loaded. The output window may have more diagnostic information." There's nothing fishy in my output pane (aside from the usual dozens of DLL loads including d3dx9_34.dll). It ends with...
Direct3D9: :====> ENTER: DLLMAIN(0f49e6e0): Process Attach: 00000260, tid=00000d64
Direct3D9: :====> EXIT: DLLMAIN(0f49e6e0): Process Attach: 00000260
Direct3D9: (INFO) :Direct3D9 Debug Runtime selected.
Windows has triggered a breakpoint in GameD.exe.

This may be due to a corruption of the heap, and indicates a bug in GameD.exe or any of the DLLs it has loaded.

And here's the front end of text from PIX on the same error...
PIX Logfile created at: 18:29:26

Frame 000001 ....PRE: Frame(1)
Trigger 'Program Start' fired
Frame 000001 ........PRE: Direct3DCreate9(32)
Direct3D9: :====> ENTER: DLLMAIN(1221e6e0): Process Attach: 0000068c, tid=00000890
Direct3D9: :====> EXIT: DLLMAIN(1221e6e0): Process Attach: 0000068c
Direct3D9: (INFO) :Direct3D9 Debug Runtime selected.
An unhandled exception occurred.
Frame 000001 ............PRE: CreateProcessW(0x0012CE30, 0x001F9C18, <unknown type 182>, <unknown type 182>, TRUE, 0x00000000, NULL, NULL, <unknown type 184>, <unknown type 185>)
Frame 000001 ............POST: <TRUE> CreateProcessW(0x0012CE30, 0x001F9C18, <unknown type 182>, <unknown type 182>, TRUE, 0x00000000, NULL, NULL, <unknown type 184>, <unknown type 185>)
Direct3D9: :====> ENTER: DLLMAIN(1221e6e0): Process Detach 0000068c, tid=00000890

I've looked around on the boards and haven't found anything yet. Unfortunately, not being able to run the Debug version is preventing me from debugging a lot of other problems. If it's relevant I'm using a GeForce 6600. If anyone has an idea as to why this is happening, I'd be much obliged. Thanks.

Share this post


Link to post
Share on other sites
Thank you for the reply.

My network's been down for a couple days, sorry for the delay.

The break happens right on the line where I call Direct3DCreate9, but the call stack is much deeper...


ntdll.dll!7c941230()
[Frames below may be incorrect and/or missing, no symbols loaded for ntdll.dll]
d3d9d.dll!0f3fed3d()
d3d9d.dll!0f3fe4cb()
d3d9d.dll!0f3fe59b()
ntdll.dll!7c94d592()
advapi32.dll!77d86bcc()
d3d9d.dll!0f3fe440()
d3d9d.dll!0f3f2db4()
ntdll.dll!7c950895()
ntdll.dll!7c959a9c()
ntdll.dll!7c959b3f()
ntdll.dll!7c959aeb()
kernel32.dll!7c80e3dc()
kernel32.dll!7c801be6()
kernel32.dll!7c801bf6()
ntdll.dll!7c959aeb()
ntdll.dll!7c959ba0()
kernel32.dll!7c80adde()
kernel32.dll!7c80adf0()
d3d9.dll!4b68af2e()
ntdll.dll!7c959b3f()
ntdll.dll!7c959aeb()
ntdll.dll!7c959b3f()
ntdll.dll!7c959aeb()
ntdll.dll!7c959d27()
> GameD.exe!Form::InitEditForm(gcroot<Form::EditForm ^> GameForm={...}, HWND__ * hWnd=0x0002086a, const char * const pstrRoot=0x001f17c0) Line 441 C++
[Managed to Native Transition]
GameD.exe!Form::EditForm::EditForm() Line 78 C++



Does this make any sense?

Share this post


Link to post
Share on other sites
I think Evil Steve was asking for a code snippet rather than a call stack, which indeed might prove more useful in tracking down the exception [smile]

From the looks of it you're using C++/CLI, so I'm not sure this applies to your problem. You seem to be missing a lot of spew from the D3D debug runtimes though, so you might want to try enabling unmanaged debugging on your project property sheet (debug section) or getting debugview (see my sig) to make sure you're getting all error messages.


As a wild guess, it looks like you're setting up the D3D9 from the constructor of your EditForm (calling InitEditForm from the constructor). When the constructor is called, a form object typically isn't (and hasn't been) visible yet, so the window handle might be invalid and causing you this headache. The way most MDX folks go about this is by hooking the Form.Load event for initialization, which is called after the native window has been created and ensures you have a valid window handle.

Hope this helps :)

Share this post


Link to post
Share on other sites
Thanks for the suggestions!~ I will check unmanaged debugging in my project.

As for the setup of D3D, it normally happens after the form is set up and what not, but as a test I thought that putting it at the top of my application and seeing it fail there would be a lot more stable test. Your question does give me some ideas though; I'll next just try making a .net app from scratch with the wizard and throw in the Direct3DCreate9 there, so it's as native as environment as possible, and see if I get the same behavior.

Thanks for now, I appreciate it!

Share this post


Link to post
Share on other sites
A couple more suggestions:
* Set up VS to use the MS Symbol Server. That way you'll get some actual info from your callstacks
* Turn up the D3D debugging level all the way
* Check if you get the same behavior for HAL and REF devices

Share this post


Link to post
Share on other sites
Thanks for the help! I've set up VisualStudio to use the Windows Symbol Server. I've also extremely slimmed down the problem-space in noticing that the same crash happens with the CreateDevice sample from the DirectX SDK. ^^;; So I guess this isn't a managed problem, just a DirectX problem in general on my system.

Now, as before, I get Windows breakpoint triggered inside of Direct3DCreate9...

if( NULL == ( g_pD3D = Direct3DCreate9( D3D_SDK_VERSION ) ) )

I can't step in here, that triggers the breakpoint.

Here is the callstack with additional symbols loaded...


ntdll.dll!_DbgBreakPoint@0()
d3d9d.dll!00beed3d()
[Frames below may be incorrect and/or missing, no symbols loaded for d3d9d.dll]
d3d9d.dll!00bee4cb()
d3d9d.dll!00bee59b()
ntdll.dll!_ZwClose@4() + 0xc bytes
advapi32.dll!_BaseRegCloseKeyInternal@4() + 0x49 bytes
d3d9d.dll!00be2db4()
ntdll.dll!_RtlImageDirectoryEntryToData@16() + 0x3f bytes
ntdll.dll!_LdrpGetProcedureAddress@20() + 0xe7 bytes
ntdll.dll!_LdrGetProcedureAddress@16() + 0x18 bytes
kernel32.dll!_GetProcAddress@8() + 0x3e bytes
0012fdc0()
ntdll.dll!_RtlpImageNtHeader@4() + 0x4a bytes
user32.dll!__CreateWindowEx@52() + 0xb1 bytes
user32.dll!_CreateWindowExW@48() + 0x33 bytes
> CreateDevice.exe!wWinMain(HINSTANCE__ * hInst=0x00400000, HINSTANCE__ * __formal=0x00000000, HINSTANCE__ * __formal=0x00000000, HINSTANCE__ * __formal=0x00000000) Line 155 + 0x2f bytes C++
CreateDevice.exe!__tmainCRTStartup() Line 324 + 0x35 bytes C
CreateDevice.exe!wWinMainCRTStartup() Line 196 C
kernel32.dll!_BaseProcessStart@4() + 0x23 bytes




Since this seems to be a problem with creating the Api itself, I don't think it's a HAL versus REF problem, I'm not even getting to the device creation, the actual API can't initialize. What's strange though is that if I put a breakpoint right before the Direct3DCreate9 function, I get there ok and the call stack looks all right, but when I try to get past that function, the call stack seems to change and the above call stack is displayed as a result... as if I failed on CreateWindowEx, which I already cleared previously... does this mean the stack was corrupted during the D3D initialization??

Again, the output window is sparse in terms of debug messages...


'CreateDevice.exe': Loaded 'D:\CreateDevice\Debug\CreateDevice.exe', Symbols loaded.
'CreateDevice.exe': Loaded 'C:\WINDOWS\system32\ntdll.dll', Symbols loaded (source information stripped).
'CreateDevice.exe': Loaded 'C:\WINDOWS\system32\kernel32.dll', Symbols loaded (source information stripped).
'CreateDevice.exe': Loaded 'C:\WINDOWS\system32\d3d9.dll', Symbols loaded (source information stripped).
'CreateDevice.exe': Loaded 'C:\WINDOWS\system32\d3d8thk.dll', Symbols loaded (source information stripped).
'CreateDevice.exe': Loaded 'C:\WINDOWS\system32\gdi32.dll', Symbols loaded (source information stripped).
'CreateDevice.exe': Loaded 'C:\WINDOWS\system32\user32.dll', Symbols loaded (source information stripped).
'CreateDevice.exe': Loaded 'C:\WINDOWS\system32\msvcrt.dll', Symbols loaded (source information stripped).
'CreateDevice.exe': Loaded 'C:\WINDOWS\system32\advapi32.dll', Symbols loaded (source information stripped).
'CreateDevice.exe': Loaded 'C:\WINDOWS\system32\rpcrt4.dll', Symbols loaded (source information stripped).
'CreateDevice.exe': Loaded 'C:\WINDOWS\system32\version.dll', Symbols loaded (source information stripped).
'CreateDevice.exe': Loaded 'C:\WINDOWS\system32\winmm.dll', Symbols loaded (source information stripped).
'CreateDevice.exe': Loaded 'C:\WINDOWS\system32\imm32.dll', Symbols loaded (source information stripped).
'CreateDevice.exe': Loaded 'C:\WINDOWS\system32\lpk.dll', Symbols loaded (source information stripped).
'CreateDevice.exe': Loaded 'C:\WINDOWS\system32\usp10.dll', Symbols loaded (source information stripped).
'CreateDevice.exe': Loaded 'C:\WINDOWS\system32\MSCTF.dll', Symbols loaded (source information stripped).
'CreateDevice.exe': Loaded 'C:\WINDOWS\system32\MSCTFIME.IME', Symbols loaded (source information stripped).
'CreateDevice.exe': Loaded 'C:\WINDOWS\system32\ole32.dll', Symbols loaded (source information stripped).
'CreateDevice.exe': Loaded 'C:\WINDOWS\system32\IMJP9.IME', No symbols loaded.
'CreateDevice.exe': Loaded 'C:\WINDOWS\system32\shell32.dll', Symbols loaded (source information stripped).
'CreateDevice.exe': Loaded 'C:\WINDOWS\system32\shlwapi.dll', Symbols loaded (source information stripped).
'CreateDevice.exe': Loaded 'C:\WINDOWS\system32\IMJP9K.DLL', No symbols loaded.
'CreateDevice.exe': Loaded 'C:\WINDOWS\system32\oleaut32.dll', Symbols loaded (source information stripped).
'CreateDevice.exe': Loaded 'C:\WINDOWS\WinSxS\x86_Microsoft.Windows.Common-Controls_6595b64144ccf1df_6.0.2600.2982_x-ww_ac3f9c03\comctl32.dll', Symbols loaded (source information stripped).
'CreateDevice.exe': Loaded 'C:\WINDOWS\system32\uxtheme.dll', Symbols loaded (source information stripped).
'CreateDevice.exe': Loaded 'C:\WINDOWS\system32\d3d9d.dll', No symbols loaded.
'CreateDevice.exe': Loaded 'C:\WINDOWS\system32\d3dx9d_33.dll', No symbols loaded.
Direct3D9: :====> ENTER: DLLMAIN(00bee6e0): Process Attach: 00000e94, tid=00000764
Direct3D9: :====> EXIT: DLLMAIN(00bee6e0): Process Attach: 00000e94
Direct3D9: (INFO) :Direct3D9 Debug Runtime selected.
Windows has triggered a breakpoint in CreateDevice.exe.

This may be due to a corruption of the heap, and indicates a bug in CreateDevice.exe or any of the DLLs it has loaded.




To confirm, my Debug Output level for D3D is all the way right at "More", and I've selected "Use Debug Version of Direct3D 9", "Maximum Validation", "Enable Shader Debugging", "Break on D3D9 Error", "Enable Hardware Acceleration". However, toggling all of these checkboxes off and on has no effect.

Should I repost this over in a more general D3D forum, perhaps? :
Thanks for the help!!

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this