提问者:小点点

运行时错误:加载未对齐的地址


我最近遇到了这个错误。 完整错误如下所示。

external/libgit2/src/hash/sha1/sha1dc/sha1.c:438:2: runtime error: load of misaligned address 0x6110000205f5 for type 'const uint32_t', which requires 4 byte alignment
0x6110000205f5: note: pointer points here
 65 6e 74 20 64 35 63  30 62 31 35 64 61 30 36  33 38 65 35 31 61 64 31  38 66 37 64 35 37 31 37  36

我使用的是libgit2库,运行时错误发生在库代码中,所以我没有发布任何代码。 问题是程序继续运行良好。 这个错误到底是什么意思? 我怎么才能修好它呢?


共1个答案

匿名用户

0x6110000205F5不是对齐地址。 (从一个字节到4个字节对齐)。 如果您将一个未对齐的指针传递到代码,就会发生这种情况。

您可以手动或使用memalign系列或Windows_Aligned_Alloc中的函数