Where is EXC_BAD_ACCESS documented? [closed]

空扰寡人 提交于 2019-12-02 12:51:37

问题


One of the more commonplace debugging errors in my own development (Mac, iOS) is EXC_BAD_ACCESS. Despite its commonness, its origin and precise meaning remain mysterious. Google lists many occurrences of the error, but the only explanation I could find is informal and incomplete.

I know that this exception (if that's the proper term for it) means that the code has attempted to access an address to which it does not have read and/or write privileges—the null address, for example, or an address outside of the process's address space. But this is an intuitive interpretation based on my prior experience with virtual memory and protected memory systems. I have never seen EXC_BAD_ACCESS documented anywhere, and indeed I'm not sure "who" is sending me this exception—the CPU, Mac OS, UNIX, the runtime, the debugger?—so I don't know who to ask (that is, what class of documentation to consult). I would like to know, for example, what the "code" that is listed with the exception means. Or another example: what other classes of similar exceptions (presumably also tagged with "EXC_") might also come from the same source?

Where can I find an explanation of EXC_BAD_ACCESS, its codes and general semantics, from an authoritative source? What is the authoritative source—who is actually detecting and throwing the exception?


回答1:


The only official documentation I've been able to find for EXC_BAD_ACCESS is a Technical Q&A called Finding EXC_BAD_ACCESS bugs in a Cocoa project. It's dated and only confirms what you already know:

This kind of problem is usually the result of over-releasing an object. It can be very confusing, since the failure tends to occur well after the mistake is made. The crash can also occur while the program is deep in framework code, often with none of your own code visible in the stack.

Indeed, it can be very confusing. At least Apple acknowledges that much. :)



来源:https://stackoverflow.com/questions/15254163/where-is-exc-bad-access-documented

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!