[英]strcpy misalignment __strcpy_sse2_unaligned()
What should be the correct approach(es) to solve __strcpy_sse2_unaligned()
problems? 解决__strcpy_sse2_unaligned()
问题的正确方法应该是什么? ie. 即。 strcpy(enc_buf, base64_encode(buf));
leads to __strcpy_sse2_unaligned()
in gdb So what are the precautionary measures to prevent such things? 导致gdb中的__strcpy_sse2_unaligned()
那么,预防这种情况的预防措施是什么?
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. 编译器无法确定源char*
和目标char*
是否对齐(通常是字对齐,甚至是四字对齐),因此正在备份到未对齐但可能已优化的strcpy
例程。 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. 否则,它只会放弃:SSE通常不允许未对齐的访问,或者访问速度仍然很慢。
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. 但是 ,如果你得到一个segfault这是不太可能它是一个库的问题(这是一个主要使用功能),它只是不能因错位。 It's much likely your code exhibits undefined behavior somewhere, due to buffer overrun, for example. 例如,由于缓冲区溢出,您的代码很可能在某些地方表现出未定义的行为。 Check your pointers with valgrind
or -fsanitize=address
. 使用valgrind
或-fsanitize=address
检查指针。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.