未处理的异常0xC0000008:一个无效的句柄动态重新编译程序规定 [英] Unhandled exception 0xC0000008: An invalid handle was specified in dynamic recompiler
问题描述
在code是MIPS-> ARM动态重编译器。运行recompile_function()多次后,它崩溃低于code的条件条款,尽管它可以较早的功能,运行过程中没有任何问题,运行此行code的。
The code is a MIPS->ARM dynamic recompiler. After many times of running recompile_function(), it crashes at the condition clause of below code, though it can run this line of code without any issue during the earlier function running.
void recompile_function(){
//recompilation code
......
if (out > (u_char *)((u_char *)base_addr + (1 << TARGET_SIZE_2) - MAX_OUTPUT_BLOCK_SIZE - JUMP_TABLE_SIZE))
out = (u_char *)base_addr;
// other code
......
}
变出来是用来编写编译code中的指针。 BASE_ADDR总是指向分配的内存空间的原始起点。变了进展每条指令写入时间为4个字节,而BASE_ADDR保持不变。
Variable out is the pointer used to write the recompiled code. base_addr always points to the original start of the allocated memory space. Variable out progresses 4 bytes each time an instruction is written, while base_addr keeps unchanged.
extern char extra_memory[33554432];
#define BASE_ADDR ((int)(&extra_memory))
void *base_addr;
u_char *out;
void new_dynarec_init()
{
protect_readwrite();
base_addr = ((int)(&extra_memory));
out = (u_char *)base_addr;
}
该错误是在0x7738EC9F(ntdll.dll中)在frontend.exe未处理的异常:0xC0000008:一个无效的句柄指定
The error is "Unhandled exception at 0x7738EC9F (ntdll.dll) in frontend.exe: 0xC0000008: An invalid handle was specified."
这是断层条款指令周围的拆机code。
This is the disassemble code around the faulting clause instruction.
#if NEW_DYNAREC == NEW_DYNAREC_ARM
__clear_cache((void *)beginning, out);
53830242 ldr r1,[r9]
53830246 add r3,r4,r5,lsl #2
5383024A mov r0,r7
5383024C str r3,[r2]
5383024E blx __clear_cache_bugfix (537D19DCh)
//cacheflush((void *)beginning,out,0);
#endif
// If we're within 256K of the end of the buffer,
// start over from the beginning. (Is 256K enough?)
if (out > (u_char *)((u_char *)base_addr + (1 << TARGET_SIZE_2) - MAX_OUTPUT_BLOCK_SIZE - JUMP_TABLE_SIZE))
53830252 mov r2,#0xAA98
53830256 movt r2,#0x5462
5383025A ldr r3,new_recompile_block+0A1E8h (53830550h)
5383025C ldr r4,[r2]
5383025E ldr r2,[r9]
53830262 add r3,r3,r4
53830264 cmp r2,r3
53830266 bls new_recompile_block+9F06h (5383026Eh)
out = (u_char *)base_addr;
53830268 mov r2,r4
5383026A str r4,[r9]
这是调试器提示我就行了。我查了拆机窗口,也道出了此行。更重要的是,如果我选择继续,新的错误会弹出,程序将在功能__report_gsfailure的code线__fastfail崩溃。新的错误是在frontend.exe在0x53831547(mupen64plus.dll)未处理的异常:堆栈饼干仪表code检测到一个基于堆栈的缓冲区溢出。 0x53831546为code线的__fastfail的地址。
It's the line the debugger prompts me. I checked the disassemble window that also points to this line. What's more, if I choose continue, a new error will pop up and the program will crash at the code line "__fastfail" in function __report_gsfailure. The new error is "Unhandled exception at 0x53831547 (mupen64plus.dll) in frontend.exe: Stack cookie instrumentation code detected a stack-based buffer overrun". 0x53831546 is the address of code line "__fastfail".
#pragma warning(push)
#pragma warning(disable: 4100) // unreferenced formal parameter
__declspec(noreturn) void __cdecl __report_gsfailure(GSFAILURE_PARAMETER)
{
5383153C push {r0,r1}
5383153E push {r11,lr}
53831542 mov r11,sp
__fastfail(FAST_FAIL_STACK_COOKIE_CHECK_FAILURE);
53831544 movs r0,#2
53831546 __fastfail
}
// Declare stub for rangecheckfailure, since these occur often enough that the
// code bloat of setting up the parameters hurts performance
__declspec(noreturn) void __cdecl __report_rangecheckfailure()
{
53831548 push {r11,lr}
5383154C mov r11,sp
__report_securityfailure(FAST_FAIL_RANGE_CHECK_FAILURE);
5383154E movs r0,#8
53831550 bl __report_securityfailure (53831558h)
53831554 __debugbreak
寄存器PC = 53831546这样的执行点是__fastfail。
The register PC = 53831546 so the execution point is __fastfail.
推荐答案
该错误是由__clear_cache位于坠毁的条件子句上面造成的。禁用该函数调用固定崩溃。
The error is caused by __clear_cache which is located above the crashed condition clause. Disabling that function call fixed the crash.
这篇关于未处理的异常0xC0000008:一个无效的句柄动态重新编译程序规定的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!