runtime error: load of misaligned address

runtime error: load of misaligned address

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

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 库,库代码中出现 运行time 错误,所以我没有 post 任何代码。问题是程序继续 运行 正常。这个错误到底是什么意思?我该如何解决它?

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

您可以手动执行此操作,也可以使用 memalign family or for windows _aligned_alloc

中的函数