Jump to content

  • Log In with Google      Sign In   
  • Create Account

Strange DirectX error(debugger is unreliable in this case)


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
4 replies to this topic

#1 mrheisenberg   Members   -  Reputation: 356

Like
0Likes
Like

Posted 27 March 2013 - 08:01 PM

I'm calling

 

IDXGIOutput* output;
adapter->EnumOutputs(0, &output);
DXGIOutput outputInterface = DXGIOutput(output);
 

 

 

 

adapter is a DXGIAdapter* that I create with EnumAdapters1 from the factory object, it gives me no problems, I get the description and it properly gives me the GPU name when I take its DXGI_ADAPTER_DESC1.
DXGIOutput is just a thin wrapper that contains an IDXGIOutput* and has a SafeRelease(obj) macro used in it's destructor to release the contained IDXGIOutput*.This is the macro:
#define SafeRelease(obj) {if(obj){(obj)->Release();(obj)=nullptr;}}It's just the standart SafeRelease used across most tutorials, but It kept telling me this when SafeRelease was called:

Unhandled exception at 0x00150138 in Rendering.exe: 0xC0000005: Access violation executing location 0x00150138. 

 

since I was only using DXGIOutput outputInterface temporarily, once it got killed at the end of the function and it's destructor got called.

So I change it to:
#define SafeRelease(obj) {if(obj){(obj)->Release();}}
And now it stopped giving me the error.However, on the call stack it says:

  <Unknown function> Unknown

  [Frames below may be incorrect and/or missing]
 
I linked to Microsoft symbol server just in case, but that didn't fix it the [Frames below may be incorrect and/or missing] issue.
So after I fixed the problem with the destructor, the line above it(adapter->EnumOutputs(0, &output);) started to give me an

Unhandled exception at 0x7728A4DE (ntdll.dll) in Rendering.exe: 0xC0000005: Access violation reading location 0xFEEEFEF6.


And on the top of the call stack there's:
 

ntdll.dll!<Unknown function> Unknown
  [Frames below may be incorrect and/or missing, no symbols loaded for ntdll.dll]
  dxgi.dll!<Unknown function> Unknown
  dxgi.dll!<Unknown function> Unknown
  dxgi.dll!<Unknown function> Unknown
  dxgi.dll!<Unknown function> Unknown
 
All if this is really confusing, changing the destructor of an object can't interfere with something that happens before it's called o_O unless the frames really are not in that order, but in that case I have no idea what can be done.Has anyone ever had this problem?It says in MSDN, that the symbol files are included in Windows 7 by default, and even so I tried with the Microsoft symbol server.

 

 



Sponsor:

#2 Jason Z   Crossbones+   -  Reputation: 5062

Like
0Likes
Like

Posted 27 March 2013 - 08:13 PM

If you are using the XXX1 functions, then you should be sure to use the equivalent interfaces.  For example, here is my code to do something similar to what you posted:

// Create a factory to enumerate all of the hardware in the system.

	IDXGIFactory1* pFactory = 0;
	hr = CreateDXGIFactory1( __uuidof(IDXGIFactory), (void**)(&pFactory) );


	// Enumerate all of the adapters in the current system.  This includes all
	// adapters, even the ones that don't support the ID3D11Device interface.

	IDXGIAdapter1* pCurrentAdapter;
	std::vector<DXGIAdapter*> vAdapters;
	std::vector<DXGIOutput*> vOutputs;

	while( pFactory->EnumAdapters1( vAdapters.size(), &pCurrentAdapter ) != DXGI_ERROR_NOT_FOUND )
	{
		vAdapters.push_back( new DXGIAdapter( pCurrentAdapter ) );

		DXGI_ADAPTER_DESC1 desc;
		pCurrentAdapter->GetDesc1( &desc );

		Log::Get().Write( desc.Description );
	}

Notice that the interfaces are all the updated versions - please try this and see if the issue is resolved.



#3 mrheisenberg   Members   -  Reputation: 356

Like
1Likes
Like

Posted 27 March 2013 - 08:26 PM

Yes, I use the updated ones everywhere, however I don't understand this:
 

/ Create a factory to enumerate all of the hardware in the system.

    IDXGIFactory1* pFactory = 0;
    hr = CreateDXGIFactory1( __uuidof(IDXGIFactory), (void**)(&pFactory) );

Shouldn't it be IDXGIFactory1? I'm using IDXGIFactory1, maybe that's the issue?
It also worries me that the SafeRelease macro causes a crash, even if I use 0 instead of nullptr, could be a hint at the problem.

 


on a side note - I just now notice GameDev has colors for DirectX in the code tags lol


Edited by mrheisenberg, 27 March 2013 - 08:35 PM.


#4 Jason Z   Crossbones+   -  Reputation: 5062

Like
0Likes
Like

Posted 27 March 2013 - 08:49 PM

Good catch!  Maybe I should follow my own advice then, eh? :)

 

I updated it and recompiled, and there was not issue in either case (before and after the change).  But you are right about the safe release - it should be fool proof.  Do you use that macro in other parts of your program?  Perhaps there is some minor miscue in the macro itself.  Here is the version that is used in Hieroglyph:

 

#define SAFE_RELEASE( x ) {if(x){(x)->Release();(x)=NULL;}}

 

This looks the same to me as your solution.  Perhaps you could try to manually expand the macro and step through it to find out if there is a value there or not?



#5 mrheisenberg   Members   -  Reputation: 356

Like
1Likes
Like

Posted 28 March 2013 - 05:37 AM

ok I expanded it and same thing happens, it crashes on Release(), but when I remove the line afterwards that sets it to 0/NULL the other error appears.There's

<Unknown function>

Unknown
at the top of the call stack, so I guess there's something wrong in the COM?I don't think I initialized it wrong tho, just used 
EnumOutputs, I check the HRESULT and it's ok

edit: I tried to use IDXGIOutput1 too instead of IDXGIOutput, but I EnumOutputs() doesn't take IDXGIOutput1 as an argument, it wants an IDXGIOutput, or is IDXGIOutput1 a special case and used in a different way?

I check breakpoint by breakpoint the pointer addresses, all of the IDXGI objects seem to be getting created with valid addresses(they're not 
0x00000000 or anything similar)

Ok I fixed it, DXGIOutput outputInterface = DXGIOutput(output); should have been DXGIOutput* outputInterface = new DXGIOutput(output); otherwise it gets destroyed in the end of the frame and then I do adapterOutputs.Add(&outputInterface); I was adding a pointer to an already destroyed object (facepalm).


Edited by mrheisenberg, 28 March 2013 - 10:36 AM.





Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS