Access violation with tex->getBuffer(0, mip)

Problems building or running the engine, queries about how to use features etc.
Post Reply
User avatar
suny
Greenskin
Posts: 137
Joined: Thu Mar 12, 2020 5:53 pm
x 60

Access violation with tex->getBuffer(0, mip)

Post by suny »

Ogre Version: :?: v1.13.3
Operating System: :?: windows
Render System: :?: dx9c

Depending on a texture size I want to read a particular mipmap to speed up my mouse test, and sometimes it crashes with some users, and I don't know why. I have a Access violation reading location 0x0000000000000038 when getting the buffer.

Is there something I could do to avoid this?

Code: Select all

Ogre::Box imageBox;
int x = tex->getWidth()-1;
int y =  tex->getHeight()-1;	

int mip = 0;
if ((x > 128 || y > 128) && tex->getNumMipmaps() > 2)
	mip = 1;
if ((x>512 || y>512) &&  tex->getNumMipmaps() > 3)
	mip = 2;
if ((x>1024 || y>1024) &&  tex->getNumMipmaps() > 4)
	mip = 3;
Ogre::HardwarePixelBufferSharedPtr buf = tex->getBuffer(0, mip);

S.

loath
Platinum Sponsor
Platinum Sponsor
Posts: 290
Joined: Tue Jan 17, 2012 5:18 am
x 67

Re: Access violation with tex->getBuffer(0, mip)

Post by loath »

Is it possible to post the crash dump? Can you reproduce this and debug builds or just release only?

User avatar
suny
Greenskin
Posts: 137
Joined: Thu Mar 12, 2020 5:53 pm
x 60

Re: Access violation with tex->getBuffer(0, mip)

Post by suny »

I never reproduced this, it seems to only happen to some users (So in Release).

The crashdump:
www.poka.fr/preview/shmupcreator.exe_1. ... 6.mini.dmp

S.

loath
Platinum Sponsor
Platinum Sponsor
Posts: 290
Joined: Tue Jan 17, 2012 5:18 am
x 67

Re: Access violation with tex->getBuffer(0, mip)

Post by loath »

sorry i mean a crash stack unless you have public symbols somewhere ... i looked at the dump but without your symbols / pdb it doesn't show much.

is the crash occurring inside getBuffer () or on the tex pointer?

Code: Select all

0:000> ~0s; .ecxr ; kb
ntdll!NtWaitForMultipleObjects+0x14:
00007ffc`3b4ad894 c3              ret
rax=0000000000000030 rbx=0000020fa59f6c30 rcx=0000020fc10f59c0
rdx=0000000000000000 rsi=00007ff6896a5220 rdi=0000000000000000
rip=00007ff689468969 rsp=000000b83892e760 rbp=000000b83892e860
 r8=0000000000000003  r9=0000020ff5f700e0 r10=0000020ff5f6f220
r11=000000b83892e6f0 r12=0000000000000000 r13=000000000000a7ff
r14=0000020f893fe8f0 r15=0000000000000000
iopl=0         nv up ei pl nz na po nc
cs=0033  ss=002b  ds=002b  es=002b  fs=0053  gs=002b             efl=00010206
ShmupCreator+0x288969:
00007ff6`89468969 4c8b7008        mov     r14,qword ptr [rax+8] ds:00000000`00000038=????????????????
  *** Stack trace for last set context - .thread/.cxr resets it
 # RetAddr               : Args to Child                                                           : Call Site
00 00000000`00000000     : 000000b8`3892e860 00007ff6`896a5220 00000000`00000000 00000000`00000000 : ShmupCreator+0x288969
loath
Platinum Sponsor
Platinum Sponsor
Posts: 290
Joined: Tue Jan 17, 2012 5:18 am
x 67

Re: Access violation with tex->getBuffer(0, mip)

Post by loath »

is it possible to have a texture with 0 mipmaps? i'm not sure what happens if you pass in 0 as the mip level for getBuffer () and have none.
do you have access to the ogre log for the crash? looks like the texture load prints out the mip maps etc. you might be able to recreate the scenario or perhaps look at the tex pointer with symbols loaded.

User avatar
dark_sylinc
OGRE Team Member
OGRE Team Member
Posts: 5292
Joined: Sat Jul 21, 2007 4:55 pm
Location: Buenos Aires, Argentina
x 1278
Contact:

Re: Access violation with tex->getBuffer(0, mip)

Post by dark_sylinc »

loath wrote: Tue Jul 05, 2022 8:50 pm

is it possible to have a texture with 0 mipmaps? i'm not sure what happens if you pass in 0 as the mip level for getBuffer () and have none.

That reminds me of an ellusive GL3 bug where the driver would fail to create the texture (either because it was out of memory or the GPU didn't support the requested resolution / format) and thus Ogre would continue as normal with a warning in Ogre.log or stdio I can't remember, but there were 0 mips loaded.

Hence attempting to access any mip (or some other stuff) would cause the crash.

I don't know if it applies to D3D9 RS though.

User avatar
suny
Greenskin
Posts: 137
Joined: Thu Mar 12, 2020 5:53 pm
x 60

Re: Access violation with tex->getBuffer(0, mip)

Post by suny »

I still have some users crashing, but I don't know who and thus can't ask for ogre.log.

What is weird is that I don't crash at

Code: Select all

int mip = 0;
if ((x > 128 || y > 128) && tex->getNumMipmaps() > 2)
	mip = 1;

So Ogre think that there is a mip map.

Naive question:
Could I add a try / catch in this case?
S.

User avatar
sercero
Bronze Sponsor
Bronze Sponsor
Posts: 449
Joined: Sun Jan 18, 2015 4:20 pm
Location: Buenos Aires, Argentina
x 155

Re: Access violation with tex->getBuffer(0, mip)

Post by sercero »

Aren't there any libraries that you can integrate into the code so that when there is a crash you get some telemetry?

So that people can send crash reports directly to you.

That way you can get the ogre.log and the mail of the use for further inquiries.

Of course you would need a privacy policy and whatnot but this framework would be useful for the future.

User avatar
suny
Greenskin
Posts: 137
Joined: Thu Mar 12, 2020 5:53 pm
x 60

Re: Access violation with tex->getBuffer(0, mip)

Post by suny »

I'm receiving anonymous crash reports, but most of the time they are only mini dumps. I know where the app crash, but I don't have a lot of other clues...
S.

rpgplayerrobin
Gnoll
Posts: 617
Joined: Wed Mar 18, 2009 3:03 am
x 353

Re: Access violation with tex->getBuffer(0, mip)

Post by rpgplayerrobin »

Do you get any idea from the user crash reports of what they tried to do exactly?

Does it happen everytime for them? Or just after they have done something special?

Maybe it is something crazy like resizing the window, minimizing it, moving it to another display and then trying that code.
Or it can be that they enter a fullscreen window somewhere else and that can also cause issues with textures in other applications.
Or it can just be out of memory or something.
It can probably even be their own machines that are bugged, like a hardware issue. Or even just a software update is needed.
It can really be anything if you don't get more information.

Do you have any kind of idea how to reproduce it? In that case I can try it on my machine if the code is available somewhere in an offical application or something.
If I can reproduce it you can easily fix it.

User avatar
dark_sylinc
OGRE Team Member
OGRE Team Member
Posts: 5292
Joined: Sat Jul 21, 2007 4:55 pm
Location: Buenos Aires, Argentina
x 1278
Contact:

Re: Access violation with tex->getBuffer(0, mip)

Post by dark_sylinc »

rpgplayerrobin makes very good points.

Also external SW such as Afterburner MSI or OBS hook into the system and can interfere.

This reminds me a common issue in certain laptops are device removal events coming from Windows literally removing powerful GPUs from being available to consume less power and switch to iGPU.

D3D11 was tuned to handle these events, but it's likely D3D9 RS cannot.

You can use the "force device removal" hotkey to see how well your app handles it.

Listing active processes in your users and finding a common denominator is also a good idea.
Same goes to see if the problem isolates to a specific HW vendor and/or model or driver version.

Some users run REALLY old drivers

Post Reply