什么是"对准陷阱"错误的手段? [英] What does an "alignment trap" error means?

查看:106
本文介绍了什么是"对准陷阱"错误的手段?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的一个朋友是有一个很大的问题,尝试调试code,它开始呈现出对齐陷阱的错误。该问题发生在一个全局结构由特定的功能进行访问。

One of my friends is having a big problem trying to debug a code that started showing "alignment trap" errors. The problem happens when a global structure is accessed by a specific function.

在网络上经过一番研究,但仍不清楚是什么做一个定位陷阱指或。可能有人给出具有特别注意什么通常会导致对齐陷阱,以及如何通常是可以解决这个问题(不仅仅是关于如何使用调试器方面,而且本身的问题)解释?

After some research on the web, it still not clear what does an "alignment trap" means or is. Could someone give an explanation having special attention to what usually causes alignment traps and how usually one would solve the problem (not just in terms on how to use a debugger, but also the problem itself)?

这在C code所有做过的ARM处理器(OMAP L138)与嵌入式Linux。

This all done in C code in an ARM processor (OMAP L138) with Embedded Linux.

注意:我没有试图让这个答案的特定错误的解决方案建议,但是,因为这个问题标题所暗示的,什么是定位陷阱错误表示理解。这就是为什么我不打算把源$ C ​​$ C等。

NOTE: I'm not trying to get an error-specific solution suggestion with this answer, but, as the question title suggests, the understanding of what an "alignment trap" error means. This is why I don't plan to put a source code or the like.

推荐答案

这是操作系统和处理器特定的(和的 ABI 的具体太)。

It is operating system and processor specific (and ABI specific too).

您有一些内存损坏,或内存泄漏缓冲区溢出,等等......,或者你解引用一些不好的指针(未初始化,或计算错误) - 例如:一个指向双击这是不是8(或多个,在某些架构中,一个指向 INT 这是不是4的倍数),或者你跳转到一些无效的地址(如一个坏的函数指针)。

You have some memory corruption, or memory leak or buffer overflow, etc..., or you are dereferencing some bad pointer (either uninitialized, or computed wrongly) - e.g. a pointer to double which is not a multiple of 8 (or, on some architectures, a pointer to int which is not multiple of 4), or perhaps you are jumping to some invalid address (e.g. to a bad function pointer).

在Linux上,我建议用的gcc -Wall -g 编译和使用调试器( GDB )和的valgrind 。你可能有兴趣使用 -fsanitize =地址 -fsanitize =未定义编译标志(用GCC 4.9)。他们俩仪(所以修改)产生code。

On Linux, I would suggest to compile with gcc -Wall -g and to use the debugger (gdb) and valgrind. You might be interested in using -fsanitize=address or -fsanitize=undefined compilation flags (with GCC 4.9). They both instrument (so modify) the generated code.

阅读未定义行为。你肯定有一些。

这篇关于什么是"对准陷阱"错误的手段?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆