简体   繁体   English

C ++代码交叉编译到ARM,运行时崩溃

[英]C++ code cross compiling to ARM, runtime crash

I'm fixing a bug about android multimedia framework lower c++ lib. 我正在修复有关android多媒体框架下层c ++ lib的错误。 When the code running to following position system goto crash. 当代码运行到以下位置时,系统将崩溃。

if (((*pChar) >= _T('a')) && ((*pChar) <= _T('z'))) {
    nFrameTime++;
}

nFrameTime is int type;
pChar is wchar_t* type;

But when i modify the code to: 但是当我将代码修改为:

if (((*pChar) >= _T('a')) || ((*pChar) <= _T('z'))) {
    nFrameTime++;
}

Everything is OK. 一切都好。 I do not care about using "&&" or "||", I only want to know why that go to crash. 我不在乎使用“ &&”或“ ||”,我只想知道为什么会崩溃。 Anybody can give me some suggestions? 有人可以给我一些建议吗?

Most likely pChar isn't pointing at valid data. pChar很可能没有指向有效数据。 That's the only thing in there that could really cause a crash (compiler bugs excepted). 那是唯一真正可能导致崩溃的东西(编译器错误除外)。

The real mystery is why the changed version isn't crashing. 真正的奥秘在于,更改后的版本不会崩溃。

As to the answer to my question, it could be that when you change the code it modifies things just enough that the garbage in pChar happens to point to a valid memory location. 关于我的问题的答案,可能是当您更改代码时,它修改的内容恰好足以使pChar中的垃圾恰好指向有效的内存位置。 Another possibility, as Ben Voigt pointed out in the comments, is that the check is being optimized away in the second version, because any value at all of *pChar will cause it to be true . 正如Ben Voigt在评论中指出的那样,另一种可能性是在第二个版本中对检查进行了优化,因为所有*pChar任何值都将使它成为true

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM