什么是“BUS_ADRALN - 无效的地址对齐”错误意味着什么? [英] what does "BUS_ADRALN - Invalid address alignment" error means?

查看:3759
本文介绍了什么是“BUS_ADRALN - 无效的地址对齐”错误意味着什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们在HPUX上,我的代码是在C ++中。
我们在函数调用的可执行文件中得到BUS_ADRALN - 无效的地址对齐。
此错误是什么意思?
相同的函数工作很多次,然后突然它提供核心转储。
在GDB当我尝试打印对象值,它说不在上下文。
任何线索在哪里检查?

We are on HPUX and my code is in C++. We are getting "BUS_ADRALN - Invalid address alignment" in our executable on a function call. What does this error means? Same function is working many times then suddenly its giving core dump. in GDB when i try to print the object values it says not in context. Any clue where to check?

感谢在前进。

推荐答案

您遇到了数据对齐问题。这可能是由于尝试读取或写入某种错误的指针。

You are having a data alignment problem. This is likely caused by trying to read or write through a bad pointer of some kind.

数据对齐问题是指针指向的地址不是'对齐。例如,一些架构(例如旧的Cray 2)要求从存储器读取除单个字符之外的任何其他任何尝试都通过指针发生,其中指针值的最后3位为0.如果最后一个3位为1,硬件将产生对齐错误,这将导致您看到的那种问题。

A data alignment problem is when the address a pointer is pointing at isn't 'aligned' properly. For example, some architectures (the old Cray 2 for example) require that any attempt to read anything other than a single character from memory only occur through a pointer in which the last 3 bits of the pointer's value are 0. If any of the last 3 bits are 1, the hardware will generate an alignment fault which will result in the kind of problem you're seeing.

大多数体系结构并不那么严格,所需的对齐取决于所访问的确切类型。例如,32位整数可能只需要指针的最后2位为0,但是64位浮点数可能需要最后3位为0.

Most architectures are not nearly so strict, and frequently the required alignment depends on the exact type being accessed. For example, a 32 bit integer might require only the last 2 bits of the pointer to be 0, but a 64 bit float might require the last 3 bits to be 0.

对齐问题通常由引起SEGFAULT或分段故障的相同种类的问题引起。通常是未初始化的指针。但是它可能是由一个坏的内存分配器引起的,该内存分配器没有以正确的对齐方式返回指针,或者在指针不是正确类型的情况下通过指针的运算结果。

Alignment problems are usually caused by the same kinds of problems that would cause a SEGFAULT or segmentation fault. Usually a pointer that isn't initialized. But it could be caused by a bad memory allocator that isn't returning pointers with the proper alignment, or by the result of pointer arithmetic on the pointer when it isn't of the correct type.

malloc 和/或 operator new 的系统实现几乎肯定是正确的,在它目前做之前崩溃的方式。所以我认为坏的内存分配器是最不可能的树去咆哮。我首先检查一个未初始化的指针,然后检查错误的指针运算。

The system implementation of malloc and/or operator new are almost certainly correct or your program would be crashing way before it currently does. So I think the bad memory allocator is the least likely tree to go barking up. I would check first for an uninitialized pointer and then bad pointer arithmetic.

这篇关于什么是“BUS_ADRALN - 无效的地址对齐”错误意味着什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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