Memmove causing program crashes, giving SIGTRAP in GDB(?)
KENNON J CONRAD
kennonconrad@comcast.net
Thu Feb 26 11:02:55 GMT 2026
Thanks for checking and sharing your thoughts. This is what I would expect, so at least I'm not crazy :)
I really need to see the values of the registers in memmove, hopefully it's just a matter of continuing to learn gdb.
Appreciate it!
Regards,
Kennon
> On 02/26/2026 2:50 AM PST Dimitry Andric <dimitry@unified-streaming.com> wrote:
>
>
> Most memcpy/memmove implementations consist of an initial part that copies/moves any number of leading unaligned bytes, if necessary, followed by a main loop that copies/movies the bulk as words (32 or 64 bit depending on the architecture), and finally a part that copies/moves any number of tailing unaligned bytes.
>
> The implementation you showed in assembly does just that. The main loop will use instructions that are supposed to only be used on aligned memory, but since the leader and trailer are handled separately, you should never run into an alignment exception at that point. My guess is that there is some sort of buffer overrun instead. If the overrun stays within a memory page, you won't notice it, but unrelated data will have been clobbered. However, if the overrun goes over a page boundary, you will get a page fault.
>
> -Dimitry
>
More information about the Cygwin
mailing list