当前位置: 技术问答>linux和unix
求助:unix下内存对齐问题的解决
来源: 互联网 发布时间:2016-08-26
本文导语: 今天编写了一个TUXEDO服务,结果测试的时候出现了core文件。 调试的信息如下 [开发]247$gdb CommM core HP gdb 5.5.2 for HP Itanium (32 or 64 bit) and target HP-UX 11.2x. Copyright 1986 - 2001 Free Software Foundation, Inc. Hewlett-Packa...
今天编写了一个TUXEDO服务,结果测试的时候出现了core文件。
调试的信息如下
[开发]247$gdb CommM core
HP gdb 5.5.2 for HP Itanium (32 or 64 bit) and target HP-UX 11.2x.
Copyright 1986 - 2001 Free Software Foundation, Inc.
Hewlett-Packard Wildebeest 5.5.2 (based on GDB) is covered by the
GNU General Public License. Type "show copying" to see the conditions to
change it and/or distribute copies. Type "show warranty" for warranty/support.
..
Core was generated by `CommM'.
Program terminated with signal 10, Bus error.
BUS_ADRALN - Invalid address alignment
#0 0xc000000000379b40:0 in tree_delete+0x20 () from /usr/lib/hpux64/libc.so.1
(gdb) where
#0 0xc000000000379b40:0 in tree_delete+0x20 () from /usr/lib/hpux64/libc.so.1
#1 0xc000000000374fa0:0 in real_free+0x600 () from /usr/lib/hpux64/libc.so.1
#2 0xc00000000037fcf0:0 in free+0x170 () from /usr/lib/hpux64/libc.so.1
#3 0xc00000000413f520:0 in _e_mem_bfree () at gpbuf.c:399
#4 0xc000000003cc6210:0 in _tmfmsg_free () at tcm.c:3141
#5 0xc000000003bce890:0 in _tpfree_internal () at buffer.c:532
#6 0xc000000003bce300:0 in tpfree () at buffer.c:452
#7 0x400000000001d780:0 in connection_del (srv=0x600000000011e130,
con=0x6000000000927bf0) at connection.c:133
#8 0x400000000001dcd0:0 in connection_close (srv=0x600000000011e130,
con=0x6000000000927bf0) at connection.c:158
#9 0x4000000000025830:0 in connection_handle_fdevent (s=0x600000000011e130,
context=0x6000000000927bf0, revents=1) at connection.c:562
#10 0x4000000000021fc0:0 in ConnThreadApp (p=0x600000000011e130)
at connection.c:374
#11 0xc0000000000f6ec0:0 in __pthread_bound_body+0x190 ()
from /usr/lib/hpux64/libpthread.so.1
(gdb)
出现了这种问题该如何改啊?
我想知道 出错的原因是什么?谢谢~~
调试的信息如下
[开发]247$gdb CommM core
HP gdb 5.5.2 for HP Itanium (32 or 64 bit) and target HP-UX 11.2x.
Copyright 1986 - 2001 Free Software Foundation, Inc.
Hewlett-Packard Wildebeest 5.5.2 (based on GDB) is covered by the
GNU General Public License. Type "show copying" to see the conditions to
change it and/or distribute copies. Type "show warranty" for warranty/support.
..
Core was generated by `CommM'.
Program terminated with signal 10, Bus error.
BUS_ADRALN - Invalid address alignment
#0 0xc000000000379b40:0 in tree_delete+0x20 () from /usr/lib/hpux64/libc.so.1
(gdb) where
#0 0xc000000000379b40:0 in tree_delete+0x20 () from /usr/lib/hpux64/libc.so.1
#1 0xc000000000374fa0:0 in real_free+0x600 () from /usr/lib/hpux64/libc.so.1
#2 0xc00000000037fcf0:0 in free+0x170 () from /usr/lib/hpux64/libc.so.1
#3 0xc00000000413f520:0 in _e_mem_bfree () at gpbuf.c:399
#4 0xc000000003cc6210:0 in _tmfmsg_free () at tcm.c:3141
#5 0xc000000003bce890:0 in _tpfree_internal () at buffer.c:532
#6 0xc000000003bce300:0 in tpfree () at buffer.c:452
#7 0x400000000001d780:0 in connection_del (srv=0x600000000011e130,
con=0x6000000000927bf0) at connection.c:133
#8 0x400000000001dcd0:0 in connection_close (srv=0x600000000011e130,
con=0x6000000000927bf0) at connection.c:158
#9 0x4000000000025830:0 in connection_handle_fdevent (s=0x600000000011e130,
context=0x6000000000927bf0, revents=1) at connection.c:562
#10 0x4000000000021fc0:0 in ConnThreadApp (p=0x600000000011e130)
at connection.c:374
#11 0xc0000000000f6ec0:0 in __pthread_bound_body+0x190 ()
from /usr/lib/hpux64/libpthread.so.1
(gdb)
出现了这种问题该如何改啊?
我想知道 出错的原因是什么?谢谢~~
|
SIGBUS
一般是内存对齐的问题。
检查是否有不适当的强制类型转换比如:
char buf[64];
int *p;
p = (int *)&buf[1];
*p = 1;
这类代码在WINDOWS没有任何问题,但是在要求内存对齐的机器上,收到信号SIGBUS
一般是内存对齐的问题。
检查是否有不适当的强制类型转换比如:
char buf[64];
int *p;
p = (int *)&buf[1];
*p = 1;
这类代码在WINDOWS没有任何问题,但是在要求内存对齐的机器上,收到信号SIGBUS
|
的确比较头疼 ,帮顶
|
路过,顺便学习之
|
友情帮顶 学习