简体   繁体   中英

strcpy misalignment __strcpy_sse2_unaligned()

What should be the correct approach(es) to solve __strcpy_sse2_unaligned() problems? ie. strcpy(enc_buf, base64_encode(buf)); leads to __strcpy_sse2_unaligned() in gdb So what are the precautionary measures to prevent such things?

The compiler is unable to determine whether your source and destination char* are aligned (usually word or even quad-word aligned) and therefore is backing up to the unaligned yet possibly optimized strcpy routine. You'd need to explicitly hint about the missed guess it is doing; otherwise, it'll just give up: unaligned access is often disallowed for SSE or still very slow.

But , if you're getting a segfault it is very unlikely it's a library issue (it's a largely used function) and it just cannot be due to misalignment. It's much likely your code exhibits undefined behavior somewhere, due to buffer overrun, for example. Check your pointers with valgrind or -fsanitize=address .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM