What is a bus error?

“总线错误”消息的含义是什么,它与段错误有什么不同?


Bus errors are rare nowadays on x86 and occur when your processor cannot even attempt the memory access requested, typically:

  • using a processor instruction with an address that does not satisfy its alignment requirements.
  • Segmentation faults occur when accessing memory which does not belong to your process, they are very common and are typically the result of:

  • using a pointer to something that was deallocated.
  • using an uninitialized hence bogus pointer.
  • using a null pointer.
  • overflowing a buffer.
  • PS: To be more precise this is not manipulating the pointer itself that will cause issues, it's accessing the memory it points to (dereferencing).


    A segfault is accessing memory that you're not allowed to access. It's read-only, you don't have permission, etc...

    A bus error is trying to access memory that can't possibly be there. You've used an address that's meaningless to the system, or the wrong kind of address for that operation.


    I believe the kernel raises SIGBUS when an application exhibits data misalignment on the data bus. I think that since most[?] modern compilers for most processors pad / align the data for the programmers, the alignment troubles of yore (at least) mitigated, and hence one does not see SIGBUS too often these days (AFAIK).

    From: Here

    链接地址: http://www.djcxy.com/p/35370.html

    上一篇: 我如何在Xcode 4中设置NSZombieEnabled?

    下一篇: 什么是巴士错误?