First, the address 0xa0000008
does not look misaligned, and SEGV_ACCERR
does not mean an alignment problem, but a memory access permission problem (from sys/signal.h):
#define SEGV_ACCERR 2 /* [XSI] invalid permission for mapped object */
Considering you are using class_addMethod()
and the crash is in _cache_getImp()
, which is part of retrieving a method, my largely unfounded suspicion would be that you passed some invalid pointers to class_addMethod()
, or overwrote that information later on.
Something to check would be whether you are using either globals or malloc()
ed memory, because the runtime functions do not make copies for you.
Second, the crash you are seeing is secondary, you are crashing while running the top-level exception handler that is already terminating (_objc_terminate()
) your program from an earlier exception, but in this case it's not a Unix signal, but an Objective-C exception: objc_exception_rethrow()
.
So you probably need to figure out that primary error first, for example from logs of the exception (just a backtrace isn't enough in many cases).