亚洲av成人无遮挡网站在线观看,少妇性bbb搡bbb爽爽爽,亚洲av日韩精品久久久久久,兔费看少妇性l交大片免费,无码少妇一区二区三区

  免費(fèi)注冊(cè) 查看新帖 |

Chinaunix

  平臺(tái) 論壇 博客 文庫
最近訪問板塊 發(fā)新帖
查看: 21223 | 回復(fù): 9
打印 上一主題 下一主題

core dump 與bus error是什么樣的錯(cuò)誤? [復(fù)制鏈接]

論壇徽章:
0
跳轉(zhuǎn)到指定樓層
1 [收藏(0)] [報(bào)告]
發(fā)表于 2005-06-25 23:21 |只看該作者 |倒序?yàn)g覽
應(yīng)該從哪些方面考慮解決?




我是絕對(duì)的菜鳥!

論壇徽章:
2
亥豬
日期:2014-03-19 16:36:35午馬
日期:2014-11-23 23:48:46
2 [報(bào)告]
發(fā)表于 2005-06-26 09:29 |只看該作者

core dump 與bus error是什么樣的錯(cuò)誤?


  1. If the program displays this message:

  2.         Bus error
  3. or
  4.         Segmentation fault

  5. ... then the program was trying to access a memory location outside its
  6. address space.  The computer detected this problem and sent a signal to your
  7. program, which caused it to abort.

  8. Things that cause bus errors and segmentation violations are typically
  9. out-of-bounds array references and/or references through uninitialized or
  10. mangled pointers.
  11. If you need to debug your program, you may want to enable a core dump.
  12. Usually, those two messages above would also have "(core dumped)" by them,
  13. indicating that the program wrote an image of its current memory into a file
  14. called "core" in that directory.
復(fù)制代碼

論壇徽章:
0
3 [報(bào)告]
發(fā)表于 2005-06-26 13:45 |只看該作者

core dump 與bus error是什么樣的錯(cuò)誤?

core dump一般應(yīng)是內(nèi)存溢出
bus error 應(yīng)該是字節(jié)對(duì)齊問題

論壇徽章:
2
亥豬
日期:2014-03-19 16:36:35午馬
日期:2014-11-23 23:48:46
4 [報(bào)告]
發(fā)表于 2005-06-26 16:34 |只看該作者

core dump 與bus error是什么樣的錯(cuò)誤?

亂說

論壇徽章:
0
5 [報(bào)告]
發(fā)表于 2005-06-26 18:18 |只看該作者

core dump 與bus error是什么樣的錯(cuò)誤?

我有一個(gè)程序,遞歸轉(zhuǎn)非遞歸,自己定義棧,在Linux下運(yùn)行沒有問題,但是在FreeBSD下有時(shí)Bus Error,有時(shí)segmentation fault,都是用GCC3編譯的,奇怪。

論壇徽章:
0
6 [報(bào)告]
發(fā)表于 2005-06-26 18:26 |只看該作者

core dump 與bus error是什么樣的錯(cuò)誤?

[quote]原帖由 "ryuken2008"]我有一個(gè)程序,遞歸轉(zhuǎn)非遞歸,自己定義棧,在Linux下運(yùn)行沒有問題,但是在FreeBSD下有時(shí)Bus Error,有時(shí)segmentation fault,都是用GCC3編譯的,奇怪。[/quote 發(fā)表:


猜一下,在有內(nèi)存對(duì)齊的地方加上__attribute__((packed))或者_(dá)_attribute__((align(16)))看看行不?Linux上的GCC是默認(rèn)16字節(jié)對(duì)齊的。

論壇徽章:
0
7 [報(bào)告]
發(fā)表于 2005-06-26 19:11 |只看該作者

core dump 與bus error是什么樣的錯(cuò)誤?

[quote]原帖由 "ryuken2008"]我有一個(gè)程序,遞歸轉(zhuǎn)非遞歸,自己定義棧,在Linux下運(yùn)行沒有問題,但是在FreeBSD下有時(shí)Bus Error,有時(shí)segmentation fault,都是用GCC3編譯的,奇怪。[/quote 發(fā)表:


我的blog上有篇文章講這個(gè)的,

SIGSEGV就是指針地址是非法引起的

SIGBUS, 在不同的系統(tǒng)上定義是不同的,
SIGBUS sparc是字節(jié)對(duì)齊問題,

在x86/FreeBSD、x86/NetBSD、x86/OpenBSD平臺(tái)上,越過棧底的地址訪問導(dǎo)致SIGBUS信號(hào),而不是SIGSEGV信號(hào)

論壇徽章:
0
8 [報(bào)告]
發(fā)表于 2014-07-04 09:27 |只看該作者
今天恰巧遇到了,就把我的例子寫出來:
  1. #include <stdio.h>
  2. #include <sys/types.h>
  3. #include <sys/stat.h>
  4. #include <fcntl.h>
  5. #include <unistd.h>
  6. #include <sys/mman.h>
  7. #include <string.h>

  8. int main()
  9. {
  10.   int fd;
  11.   char *start;
  12.   char buf[100];

  13.   fd = open("testfile", O_RDWR);
  14.   if(fd < 0)
  15.   {
  16.     printf("fd < 0\n");
  17.     return 0;
  18.   }
  19.   start = mmap(NULL, 100, PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0);

  20.   strcpy(buf, start);

  21.   printf("buf = %s\n", buf);

  22.   strcpy(start, "Buf Is Not Null!");

  23.   munmap(start, 100);

  24.   close(fd);

  25.   return 0;
  26. }
復(fù)制代碼
如果如上的testfile為空的話就會(huì)出現(xiàn)(注意:這里的為空是換行符都不能有):
Bus error (core dumped)

測試環(huán)境:
Linux ubuntu 3.5.0-40-generic #62-Ubuntu SMP Thu Aug 22 00:57:36 UTC 2013 i686 i686 i686 GNU/Linux

論壇徽章:
1
2015年亞洲杯之中國
日期:2015-02-25 15:48:22
9 [報(bào)告]
發(fā)表于 2015-10-27 15:05 |只看該作者
請(qǐng)問這個(gè)錯(cuò)誤發(fā)生的原因找到了嗎? 回復(fù) 8# kangear


   

論壇徽章:
84
每日論壇發(fā)貼之星
日期:2015-12-29 06:20:00每日論壇發(fā)貼之星
日期:2016-01-16 06:20:00每周論壇發(fā)貼之星
日期:2016-01-17 22:22:00程序設(shè)計(jì)版塊每日發(fā)帖之星
日期:2016-01-20 06:20:00每日論壇發(fā)貼之星
日期:2016-01-20 06:20:00程序設(shè)計(jì)版塊每日發(fā)帖之星
日期:2016-01-21 06:20:00每日論壇發(fā)貼之星
日期:2016-01-21 06:20:00程序設(shè)計(jì)版塊每日發(fā)帖之星
日期:2016-01-23 06:20:00程序設(shè)計(jì)版塊每日發(fā)帖之星
日期:2016-01-31 06:20:00數(shù)據(jù)庫技術(shù)版塊每日發(fā)帖之星
日期:2016-01-16 06:20:00程序設(shè)計(jì)版塊每日發(fā)帖之星
日期:2016-01-16 06:20:00程序設(shè)計(jì)版塊每日發(fā)帖之星
日期:2016-01-14 06:20:00
10 [報(bào)告]
發(fā)表于 2015-10-27 16:58 |只看該作者
竟然是十年前的帖子
    gvim  albcamus  好熟悉的ID

溫習(xí)一下:
GNU libc 手冊(cè)的解釋:
http://www.gnu.org/software/libc ... -Error-Signals.html
  1.     Macro: int SIGSEGV

  2.     This signal is generated when a program tries to read or write outside the memory that is allocated for it, or to write memory that can only be read. (Actually, the signals only occur when the program goes far enough outside to be detected by the system’s memory protection mechanism.) The name is an abbreviation for “segmentation violation”.

  3.     Common ways of getting a SIGSEGV condition include dereferencing a null or uninitialized pointer, or when you use a pointer to step through an array, but fail to check for the end of the array. It varies among systems whether dereferencing a null pointer generates SIGSEGV or SIGBUS.

  4. Macro: int SIGBUS

  5.     This signal is generated when an invalid pointer is dereferenced. Like SIGSEGV, this signal is typically the result of dereferencing an uninitialized pointer. The difference between the two is that SIGSEGV indicates an invalid access to valid memory, while SIGBUS indicates an access to an invalid address. In particular, SIGBUS signals often result from dereferencing a misaligned pointer, such as referring to a four-word integer at an address not divisible by four. (Each kind of computer has its own requirements for address alignment.)

  6.     The name of this signal is an abbreviation for “bus error”.
復(fù)制代碼
您需要登錄后才可以回帖 登錄 | 注冊(cè)

本版積分規(guī)則 發(fā)表回復(fù)

  

北京盛拓優(yōu)訊信息技術(shù)有限公司. 版權(quán)所有 京ICP備16024965號(hào)-6 北京市公安局海淀分局網(wǎng)監(jiān)中心備案編號(hào):11010802020122 niuxiaotong@pcpop.com 17352615567
未成年舉報(bào)專區(qū)
中國互聯(lián)網(wǎng)協(xié)會(huì)會(huì)員  聯(lián)系我們:huangweiwei@itpub.net
感謝所有關(guān)心和支持過ChinaUnix的朋友們 轉(zhuǎn)載本站內(nèi)容請(qǐng)注明原作者名及出處

清除 Cookies - ChinaUnix - Archiver - WAP - TOP