Windows CE 线程中的 ARM 非法指令/访问冲突 (C++)

发布于 2024-10-24 01:41:32 字数 1663 浏览 3 评论 0原文

我有一个程序,其中包含一个作为 wxThread 的派生类实现的线程。有时,该程序会因非法指令或访问冲突而崩溃,但总是在线程执行的代码中的某个地方崩溃。

我什至尝试删除该线程并将其替换为一个简单的 Win32 线程,如下所示:

DWORD WINAPI LoggerThread::winthread(void* arg) {
  while (true) { Sleep(2000); }
}

它仍然会间歇性地因 Sleep(2000) 行上的访问冲突而崩溃,但几乎总是在大约 30 秒后崩溃。

最近,它在 wxThread 类调用的静态函数上因非法指令(更具体地说,未定义的指令)而崩溃:

void* LoggerThread::Entry() {
while(true) {
    if (queue->size() > 0) {

        SOCKET sd = LoggerThread::Init(); /* Crash on this line */ 
            /* ....... */
        }
    }
}

控制台的输出如下:

未定义指令:Thread=8e823ac4 Proc=8c329400 'Opcode.exe' 未定义指令:Thread=8c69663c Proc=8c329400 'Opcode.exe'

AKY=00004001 PC=800003f8(???+0x800003f8) RA=006492bc(Opcode.exe+0x006392bc) BVA=​​05ffed24 >FSR=000000f5

AKY=00004001 PC=003ade44(Opcode.exe+0x0039de44) RA=004cc784(Opcode.exe+0x004bc784) >BVA=05ffed24 FSR=000000f5

数据中止:Thread=8e823ac4 Proc=8c329400 'Opcode.exe'

AKY=00004001 PC=80188d03(NK.EXE+0x00008d03) RA=80000059(???+0x80000059) BVA=​​1e07807b >FSR=000000f3

Opcode.exe 中 0x003ade44 处未处理的异常:0xC000001D:非法指令。

线程“public: static unsigned long __cdecl wxThreadInternal::WinThreadStart(void *)”>(0x2fb5e2c6) 已退出,代码为 -1073741795 (0xc000001d)。

Opcode.exe 中 0x80188d02 处未处理的异常:0x80000002:数据类型未对齐。

该项目是VC++(Visual Studio 2005),我也尝试过使用Windows Mobile 5.0 SDK、Standard SDK和Pocket PC 2003 SDK进行编译。我一直在 MC55 和 MC3090 上测试我的代码,两者的做法相同,但我认为也许 MC55 崩溃得更快。

值得注意的是,如果我将源代码编译为 Win32 程序(它是基于 wxWidgets 的),那么它可以正常工作。

谁能给我一个想法,我可以去哪里看?

I have a program which contains a thread implemented as a derived class of wxThread. Sometimes this program crashes with either illegal instructions or access violations but always somewhere in the code executed by the thread.

I have even tried to remove the thread and replace it with a trivial Win32 thread that looks like this:

DWORD WINAPI LoggerThread::winthread(void* arg) {
  while (true) { Sleep(2000); }
}

And it still crashes with an access violation on the Sleep(2000) line intermittently, but almost always after around 30 seconds.

Most recently, it crashes with illegal instructions (more specifically, undefined instructions), on a static function which the wxThread class calls:

void* LoggerThread::Entry() {
while(true) {
    if (queue->size() > 0) {

        SOCKET sd = LoggerThread::Init(); /* Crash on this line */ 
            /* ....... */
        }
    }
}

The output from the console is the following:

Undefined Instruction: Thread=8e823ac4 Proc=8c329400 'Opcode.exe'
Undefined Instruction: Thread=8c69663c Proc=8c329400 'Opcode.exe'

AKY=00004001 PC=800003f8(???+0x800003f8) RA=006492bc(Opcode.exe+0x006392bc) BVA=05ffed24 >FSR=000000f5

AKY=00004001 PC=003ade44(Opcode.exe+0x0039de44) RA=004cc784(Opcode.exe+0x004bc784) >BVA=05ffed24 FSR=000000f5

Data Abort: Thread=8e823ac4 Proc=8c329400 'Opcode.exe'

AKY=00004001 PC=80188d03(NK.EXE+0x00008d03) RA=80000059(???+0x80000059) BVA=1e07807b >FSR=000000f3

Unhandled exception at 0x003ade44 in Opcode.exe: 0xC000001D: Illegal Instruction.

The thread 'public: static unsigned long __cdecl wxThreadInternal::WinThreadStart(void *)' >(0x2fb5e2c6) has exited with code -1073741795 (0xc000001d).

Unhandled exception at 0x80188d02 in Opcode.exe: 0x80000002: Datatype misalignment.

The project is VC++ (Visual Studio 2005), and I have also tried compiling with the Windows Mobile 5.0 SDK, the Standard SDK, and the Pocket PC 2003 SDK. I have been testing my code on the MC55 and the MC3090, both do the same, but I think perhaps the MC55 is quicker to crash.

It is worthy to note that if I compile my source as a Win32 program (it is wxWidgets based) it works without any issues.

Could anyone give me an idea of where I could look?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

南城追梦 2024-10-31 01:41:32

我对 wxWidgets 一无所知,但我可能会首先查看这个定义:

DWORD WINAPI LoggerThread::winthread(void*)

根据您的控制台输出,wxThreadInternal::WinThreadStart 是

__cdecl

WINAPI 在 ARM 上指定了什么调用约定?也许WINAPI指定

__stdcall

抱歉,格式很时髦:)

I don't know anything about wxWidgets, but I'd probably start by looking at this definition:

DWORD WINAPI LoggerThread::winthread(void*)

According to your console output, wxThreadInternal::WinThreadStart is

__cdecl

What calling convention does WINAPI specify on ARM? Maybe WINAPI specifies

__stdcall?

Sorry for the funky formatting :)

天荒地未老 2024-10-31 01:41:32

问题解决了!事实证明,wxWidgets 与标准 SDK 不兼容。我之前切换到 Windows Mobile SDK 5.0 进行检查,但碰巧存在另一个运行时问题,导致该构建无法按预期工作。我给其他人的建议是确保您不要将标准 SDK 用于带有 wxWidgets 的 WinCE 应用程序。一开始它可能看起来有效,但你最终会像我一样陷入这个陷阱......谢谢大家

Problem solved! It turned out that wxWidgets is not compatible with the Standard SDK. I switched over to Windows Mobile SDK 5.0 before to check but there happened to be another runtime issue that stopped that build from working as expected. Advice I have to others is make sure you do NOT use the Standard SDK for your WinCE app with wxWidgets. It may appear to work at first, but you will eventually fall into this trap like I did... Thanks all

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文