Jump to content
  • Advertisement
Sign in to follow this  
godsenddeath

really weird seg fault

This topic is 3667 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

I was working on splitting my terrain into cullable sub grids, and I noticed that I had forgotten to release the Vertex Buffer in the subgrid's destructor, so I added vb->Release() to the destructor, as well as zeroing the LPDIRECT3DVERTEXBUFFER9 pointer in the constructor, but this started causing a seg fault in the destructor for some reason, so I commented the lines out this was the only change I made, now during the Render() method, the vb seg faults, which is weird, even more weird is that in the .callstack method of teh vb, it has a message sayinf that to enable a call stack, i have to edit the registry any thoughts?

Share this post


Link to post
Share on other sites
Advertisement
to add more, even though all i did was add a few lines, and then comment them out, the reason it's faulting is that even though CreateVertexBuffer() returns S_OK, it's creating a bad pointer <bad_ptr>


HRESULT hr = device->CreateVertexBuffer(VertexList.size() * sizeof(PNTVertex),D3DUSAGE_DYNAMIC|D3DUSAGE_WRITEONLY,0,D3DPOOL_SYSTEMMEM,&vb,0);
hr = vb->Lock(0,0,(void**)&pVoid,D3DLOCK_DISCARD);
memcpy(pVoid,&VertexList.front(),sizeof(PNTVertex) * VertexList.size());
hr = vb->Unlock();

Share this post


Link to post
Share on other sites
Have you tried doing a clean rebuild? CreateVertexBuffer() will never return a bad pointer; I'd first try Release()ing the pointer immediately after CreateVertexBuffer(), just so you can be sure that the pointer is valid, and then see at what point it becomes impossible to Release() the VB without crashing.

My guesses are you're either Release()ing the VB elsewhere, or the class containing the VB pointer is invalid (Has already been deleted or something similar).

You could also try creating a minimalist example that shows this behaviour, and posting the code here.

Share this post


Link to post
Share on other sites
The code you pasted isn't checking the return value of CreateVertexBuffer() for error. How do you know the call even succeeded? Same for the Lock() call.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!