这个问题可能是因为不兼容的代码导致的。在 Apple Silicon M1 上,代码必须包含适当的对齐指令或指针才能成功运行。如果代码没有正确对齐,它可能会导致 SIGBUS 崩溃。要解决这个问题,您可以使用特殊的 attribute 指令来强制对齐变量或结构体。下面是一个示例代码:
struct __attribute__((aligned(16))) aligned_struct {
int a;
double b;
};
int main() {
struct aligned_struct my_struct;
// Your code here
return 0;
}
在这个示例中,我们使用了 __attribute__((aligned(16)))
来指定结构体需要以 16 字节的边界对齐。这样,即使在 M1 处理器上,代码也不会出现 SIGBUS 崩溃的问题。