Re: 请教一个Access Violation的问题

C/C++本地代码调试

请教一个Access Violation的问题


烈火 2014-09-05, 01:52 上午
最近在编写一个视频采集的软件,使用设备提供的SDK获取位图图像,获取图像的函数声明如下:

bool GetImageData(void * buffer);

现在发现在调用这个函数的时候的经常出现Access Violation的情况(但也不是每次都出现),调试信息如下

(ae0.b80): Access violation - code c0000005 (!!! second chance !!!)
*** ERROR: Symbol file could not be found.  Defaulted to export symbols for D:\F50 SDK\AVerCamSDK\bin\AVerCamSdk_SA.dll - 
eax=0abe0020 ebx=0863ff08 ecx=00300000 edx=00000000 esi=0abe0020 edi=07710020
eip=62989051 esp=0863fee8 ebp=0863ff30 iopl=0         nv up ei pl nz na po nc
cs=001b  ss=0023  ds=0023  es=0023  fs=003b  gs=0000             efl=00000202
AVerCamSdk_SA!averCamStartup+0x772d:
62989051 f3a4            rep movs byte ptr es:[edi],byte ptr [esi]

出错的指令地址是在SDK提供的Dll里面,其中edi保存的就是传入函数中的buffer地址,esi应该是sdk使用的地址。

分别查看这两个地址:

0:008> !address 0abe0020
Usage:                  Heap
Base Address:           0abe0000
End Address:            0aee1000
Region Size:            00301000
State:                  00001000 MEM_COMMIT
Protect:                00000004 PAGE_READWRITE
Type:                   00020000 MEM_PRIVATE
Allocation Base:        0abe0000
Allocation Protect:     00000004 PAGE_READWRITE
More info:              heap owning the address: !heap 0x41a0000
More info:              heap large/virtual block
More info:              heap entry containing the address: !heap -x 0xabe0020


0:008> !address 7710020
Usage:                  Heap
Base Address:           07710000
End Address:            07a11000
Region Size:            00301000
State:                  00001000 MEM_COMMIT
Protect:                00000004 PAGE_READWRITE
Type:                   00020000 MEM_PRIVATE
Allocation Base:        07710000
Allocation Protect:     00000004 PAGE_READWRITE
More info:              heap owning the address: !heap 0x41a0000
More info:              heap large/virtual block
More info:              heap entry containing the address: !heap -x 0x7710020

看起来似乎没什么问题,从ecx上看,rep movs byte访问的范围是0x300000,也没有越界访问,为什么会报AccessViolation异常呢?

SDK附带的sample就没有出现这个问题,不同的是sample是在主线程里面使用定时器进行访问,每次调用后都会把buffer删除掉。而我是在一个工作线程里面调用这个函数,buffer也是固定的。不过感觉这个应该和发生异常没有关系吧。

Re: 请教一个Access Violation的问题


格蠹老雷 2014-09-05, 15:36 下午
圆刚的捕捉卡,激起很多回忆啊 :-)

如需帮忙,发完整的dump来

Re: 请教一个Access Violation的问题


烈火 2014-09-30, 22:41 下午
真是惭愧,居然一晃就到月底了。
那天后来再看看SDK,改成使用回调的方式,就再也没有发生上面的问题了。
奉上后来在客户机上作的一次dump,地址http://url.cn/OvbLOD ,麻烦雷老师拨冗指教

Powered by Community Server Powered by CnForums.Net