关于Unix下的core dump错误,请高手明示Unix下C/C++程序中的注意事项

x1001 2003-05-28 01:28:27
公司给A、B、C、D四地市开发的程序,程序代码一样,但程序在A市前2天一运行就出现:
Unaligned access pid=78996 <billing> va=0x140104004 pc=0x120011640 ra=0x120014ce4 inst=0xa4310000
Unaligned access pid=78996 <billing> va=0x14010400c pc=0x120011654 ra=0x120014ce4 inst=0xa4b10008
Unaligned access pid=78996 <billing> va=0x14010544c pc=0x120014cf4 ra=0x120014ce4 inst=0xa58c1448
Memory fault(coredump)
的错误,我调整代码无计于事,今天突然怀疑起硬件的原因,是某一块的内存有问题,因为主机上,主要就跑这个程序,每次启动,OS给它同样的一个内存布局,所以,我这次,就先运行一个别的占内存较大的程序,再启动公司的这个程序,真不然,程序现在又在跑了。
但我觉得有点解释不过去,我对C/C++语言比较熟,但对系统我确实不是很熟,所以请高手提示一下,要是能总结一下Unix下C/C++程序中的一些特别应当注意事项,真是感谢了。
希望我这贴子能抛砖引玉。
...全文
37 6 打赏 收藏 转发到动态 举报
写回复
用AI写文章
6 条回复
切换为时间正序
请发表友善的回复…
发表回复
rjren 2003-06-22
  • 打赏
  • 举报
回复
you can try man uac. (Unaligned Access Message Control)
Maybe it will be useful for you.

......

DESCRIPTION

Most complex instruction set computers (CISC) can access unaligned data but
only at a significantly reduced speed. Most reduced instruction set com-
puters (RISC) do not attempt to handle unaligned accesses. Instead, they
generate an unaligned access trap and let the operating system handle the
fault.

The default action for the operating system when an unaligned access fault
occurs is to fix the unaligned access fault and then display a warning
message informing the user process that an unaligned access fault has
occurred. The warning message has the following form: "Unaligned access
pid=nnn <prog_name> va=virtual_addr pc=pc_addr". If you want to change the
code to prevent the unaligned access faults from occurring in the future,
the warning message gives you the information you need to locate the code
causing a fault. (See the Programmer's Guide for details on the causes and
effects of misaligned data.)

In addition, the default action for the operating system is to not deliver
a SIGBUS signal to the parent process when an unaligned access fault
occurs.
......
x1001 2003-06-02
  • 打赏
  • 举报
回复
看来没有吸引到众多高手的眼球,也没吸引到众多高手的言论。结贴。
pupu1234 2003-05-30
  • 打赏
  • 举报
回复
我也遇到过同样的情况,不过没有生成core文件
只是有Unaligned access pid=78996 <billing> va=0x140104004 pc=0x120011640 ra=0x120014ce4 inst=0xa4310000
Unaligned access pid=78996 <billing> va=0x14010400c pc=0x120011654 ra=0x120014ce4 inst=0xa4b10008
Unaligned access pid=78996 <billing> va=0x14010544c pc=0x120014cf4 ra=0x120014ce4 inst=0xa58c1448
等的字样
但结果还是理想的,我也想知道为什么
gz
x1001 2003-05-29
  • 打赏
  • 举报
回复
发这个贴子,在Unix下我觉得缺小经验,我很想听高手总结或主持一下。
主机是Tru Unix64 OS,在前面几次,有这样几个现象:
1。在开发过程中,应客户要求,我们加了模块,其中有类函数返回为bool型,在主模块中调用,会经常发生core dump 现象,我把界面都改为int型,发现又没问题。
2.这个系统是在原有产品上开发出来的,原先的产品主要是C的写法,后来,我来负责这个项目时,因我在测试时,没发现什么问题,就大量使用了STL,到现在,我发觉在我的模块里,用STL没问题,但如果表现界面也使用STL的话,从而在主模块里必须STL的话,也会core dump出来,所以新加模块的表现界面也要是C的方式,与原主模块一致。
这2个问题不知各位有可指正的地方?
linaxing 2003-05-29
  • 打赏
  • 举报
回复
估计还是你的程序有问题。我以前也遇到过类似问题,其它地方的程序运行的好好的,
就这一个地方老是出CORE,我们一开始也怀疑硬件问题。用dbx跟踪也很困难,因为
真正产生core的地方不一定是有问题的地方(特别是每次出core的位置都不同的情况
更是如此),就这样我们陷入了僵局。在一次不经意的代码review中我们发现了一处
内存使用不当之处,我们抱着侥幸的心理将程序修改后反映到现地。
结果几个星期过去后,再也没出问题。
兄弟,努力吧,冷静下来好好分析一下自己的程序,你应该能找到问题的所在。
allan33 2003-05-28
  • 打赏
  • 举报
回复
生成CORE文件了吗?如果有的话,用pstack命令先看看core文件中内核最后记录的堆栈信息是什么再下结论吧,如果有条件的话,带-g编译一个新的执行程序然后,用dbx跟踪一下试试~

23,116

社区成员

发帖
与我相关
我的任务
社区描述
Linux/Unix社区 应用程序开发区
社区管理员
  • 应用程序开发区社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧