Sign in to follow this  

D3DDevice-Present(...) makes app crash

This topic is 4838 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hey guys, I was asking the same question again a few days before but still no one had an answer. Perhaps some pictures can bring some light. The app runs fine and everything is rendered as it should. But after closing the app, the error message "invalid pipe state" ( WinErrCode 230 ) appears and the debugger kicks in telling me there was some trouble with "GetClientRect" and "BitBlt" and stops at the debug breakpoint in NTDLL.DLL Here is my workspace view Here is the modules window Finally, the call stack Does it have something to do with the "Cannot create hardware index buffer" message ? I recently changed from an older Radeon to a R9800 Pro on Catalyst 4.9 The function leading to the crash is: D3DDevice->Present( NULL, NULL, hWnd, NULL ); Before, someone told me it could be an invalid window handle but I tested a lot and I am pretty sure the handle is valid. Not to forget: I have downloaded some source code from the web. Some of the programmes bring exactly the same error. Some don't. Also, the error message disappeares when building against the DX Release-runtime. Maybe someone can help because that damn breakpoint is annoying. Bye, Leoric Edited by Coder: Images too large to be inline [Edited by - Coder on September 16, 2004 3:16:36 AM]

Share this post


Link to post
Share on other sites
Quote:
D3DDevice->Present( NULL, NULL, hWnd, NULL );


Try putting NULL where you have hWnd, I don't think the hWnd is neccesary. Also, what is the HRESULT of that function?

Share this post


Link to post
Share on other sites
Putting NULL in for hWnd doesn't have the slightest effect due to the fact that the hDeviceWindow member of the D3DPRESENT_PARAMETERS is used, which represents the same window handle.

I tested the HRESULT with if( FAILED( hr ) ) return false;
It returns true.

As I mentioned, the programme works fine. It's after hitting the EXIT-button that the error occurs.

Bye,
Leoric

Share this post


Link to post
Share on other sites
The error output suggests that this break (it's not really an error - the release mode of D3D should not cause any crash) occurs due to memory issues.

Make sure to free all D3D resources before exiting the app.
Also unchecking the "Break On Errors" checkbox in DXDiag should prevent this 'crash' from happening.


Share this post


Link to post
Share on other sites
I use the MMGR memory manager and it says "Congratulations. No memory leaks found". I really carefully release any Com-Object.
Given the fact that apps written by other people produce the same error, I don't think it's me being too lazy to release my D3D objects.

And decreasing the debug level isn't really what I want. It's like closing your eyes. The world doesn't change, you just don't see it anymore. And I want to be aware of any error there is.

It seems like I will have to live with it.

Bye,
Leoric

Share this post


Link to post
Share on other sites
You're forgetting to release a DX object. MMGR doesn't track those, the DX debug runtime does, and it's telling you that you're forgetting something. Either that or you're trashing some memory somewhere.

Try commenting out til it goes away and you might be able to narrow it down.

If other peoples' apps cause the same error maybe your DX install is messed up. I really can't think of why it would happen. Maybe some people can send you their apps and you can confirm that it happens.

Share this post


Link to post
Share on other sites
Quote:
Original post by Leoric
I use the MMGR memory manager and it says "Congratulations. No memory leaks found". I really carefully release any Com-Object.
Given the fact that apps written by other people produce the same error, I don't think it's me being too lazy to release my D3D objects.


Have you run DxDiag? Do the same errors happen when they run? What about the SDK samples? You can download numerous samples at my site (www.drunkenhyena.com), do they have the same problem?

If none of the above have the problem then it's pretty likely that the problem is your code. If they don't, then it's likely your setup. Try upgrading your drivers.

Share this post


Link to post
Share on other sites
It sounds like you are still calling your render function after the window has been destroyed. You might try setting a bool on WM_CLOSE and checking the bool before your render call.

Share this post


Link to post
Share on other sites
Quote:
Original post by Leoric
And decreasing the debug level isn't really what I want. It's like closing your eyes. The world doesn't change, you just don't see it anymore.

You'd be surprised ho many commercial titles won't run anymore if you set D3D to its max. debug level and enable 'break on error'[rolleyes]...
Most of these errors aren't even critical (e.g. the debug runtime is able to identify the problem and labels it a "warning" rather than an error).

If you have the desire to write a clean app (which is A Good Thing™[smile]), then the debug output clearly states that there are some unreleased objects. This might be due to a bad installation as others stated, but still it could be your fault.

To track down things like that I'd suggest commenting out parts of your code until the error doesn't occur. Then re-enable until it occurs and you'll find the reason for it.

Good luck,
Pat


Share this post


Link to post
Share on other sites
Quote:
Original post by Dave Hunt
It sounds like you are still calling your render function after the window has been destroyed. You might try setting a bool on WM_CLOSE and checking the bool before your render call.


I'm pretty sure this is exactly the problem. I was having the same problem for a while...I would quit and It would say it tried to present after I released the device. So like he said set a bool that controls your game loop and turn it off when you quit.

while(done == false) {
//Game Loop
}

void CleanUp() {//Fictional clean up function
//Release everything
done = true;
}

Share this post


Link to post
Share on other sites
Hey guys,

I fixed the memory leak. It was an LPDIRECT3DINDEXBUFFER9 not being released from a class destructor. You're right, MMGR didn't see it.

I tried some tutorials over at www.codesampler.com
App crashes on exit with debug breakpoint in ntdll.dll :-(
Maybe the guys @ Codesampler are as lazy as me *laugh*

The render function isn't called after the window is destroyed. Only if Render() returns false or I hit ESC, the main loop ends. And because the window is the first thing my app creates, it is the last thing my app destroys. So the D3DDevice is released before the window is destroyed. I also did
if( IsWindow( hWnd ) ) Render();
else break;
in my main loop. No errors.

By the way: The Gunmetal benchmark crashes 3 out of 5 times when running with the dx debug runtimes at max level. I also had a 3DMark03 crash now and then.

I will now reinstall my DX9.0c SDK and also reinstall Catalyst 4.3 and see what happens.

Bye for now,
Leoric

Share this post


Link to post
Share on other sites
I recently bought a R9800Pro and went from 4.3 to 4.9 - since then, madness reigns on my system.

I did some benchmarks to compare the 4.3 & 4.9 performance. 4.3 is faster in some benchmarks. Especially ShaderMark, which sees the 4.3 ahead around 50 fps in some tests.

Bye,
Leoric

Share this post


Link to post
Share on other sites
Quote:
Original post by Leoric
(snip)

The app runs fine and everything is rendered as it should. But after closing the app, the error message "invalid pipe state" ( WinErrCode 230 ) appears and the debugger kicks in telling me there was some trouble with "GetClientRect" and "BitBlt" and stops at the debug breakpoint in NTDLL.DLL

(snip)

The function leading to the crash is:
D3DDevice->Present( NULL, NULL, hWnd, NULL );
Before, someone told me it could be an invalid window handle but I tested a lot and I am pretty sure the handle is valid.

(snip)


It still appears that Present is being called after the window is closed.

Share this post


Link to post
Share on other sites
I wonder how this should happen ? These are the last lines of code:


while( !g_bEndApp )
{ HandleMessages();
if( FAILED( RenderScene()) )
break;
}

ReleaseCOM();
ReleaseWindow();

exit( 1 );



As you can see, Present() is only called inside the RenderScene()-function. The window is destroyed outside the mainloop. In addition, the DX-Objects are released before the window is destroyed. I destroy any objects in reverse order of creation.

Bye,
Leoric

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
The WM_CLOSE/WM_DESTROY messages will be picked up and processed inside HandleMessages(). By the time HandleMessages() returns from handling a WM_DESTROY, the window handle is no longer valid.

Share this post


Link to post
Share on other sites
Quote:
Original post by Anonymous Poster
The WM_CLOSE/WM_DESTROY messages will be picked up and processed inside HandleMessages(). By the time HandleMessages() returns from handling a WM_DESTROY, the window handle is no longer valid.


Oops. That was me.

Share this post


Link to post
Share on other sites
But what part of my code is supposed to post the WM_QUIT / WM_CLOSE message. Hitting the ESC-key makes g_bEndApp = true.
When g_bEndApp is true, the HWND is still valid, isn't it ? No rendering will happen after g_bEndApp has gone true. So, next thing is to delete any DX-objects. After deleting the D3D-devices, the window is still valid.

See ya,
Leoric

Share this post


Link to post
Share on other sites

This topic is 4838 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

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