Search code examples
c++cruntime-errorlibgit2

runtime error: load of misaligned address


I recently encountered this error. The full error is the following.

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

I am using libgit2 library and the runtime error happens in the library code, so I do not post any code. The thing is the programm continues to run fine. What exactly does this error mean ? and how can I fix it at all ?


Solution

  • 0x6110000205f5 is not an aligned address. (It is one byte off to 4 byte alignment). This will happen, if you pass an unaligned pointer to the code.

    You could either to this manually or use functions from the memalign family or for windows _aligned_alloc