Memmove causing program crashes, giving SIGTRAP in GDB(?)

KENNON J CONRAD kennonconrad@comcast.net
Fri Mar 13 05:23:20 GMT 2026


Corrections:

Elements 973 - 976 would be moved on the next iteration of the REP MOVSQ.
REP MOVSQ made it through 17 iterations

> On 03/12/2026 10:15 PM PDT KENNON J CONRAD via Cygwin <cygwin@cygwin.com> wrote:
> 
>  
> Thanks, Jon.  Setting cygwin-exceptions on does change the picture considerably,
> but the picture of exactly what is happening is still cloudy for me.
> 
> The program breaks at the same spot in memmove, which is now in frame 0:
> REP MOVSQ %ds(%rsi),%es(%rdi)
> 
> but now GDB says "received signal SIGSEGV, Segmentation fault."
> 
> The EFLAGS register value is 0x10687 [ CF PF SF IF DF RF ].
> So DF is set (as it should be), which is different than without exceptions on.
> 
> ds contains 0x2b (not relevant?)
> es contains 0x2b (not relevant?)
> rsi contains 0xa00034c1a
> rdi contains 0xa00034c1c
> The uint16_t array starts at address 0xa00034480
> Array elements 781 - 1045 are being moved to 782 - 1046 (backward move).
> Elements 973 - 980 would be moved on the next iteration of the REP MOVSQ.
> 
> I see no obvious reason for the segmentation fault.  The array address looks correct,
> the array indexes are valid, and the REP MOVSQ made it through 8 iterations before
> the SIGSEGV happened, and the program does not crash using alternative code in place
> of the memmove call.
> 
> Is it possible some interrupt routine doesn't handle DF being set when it starts and
> gets a segmentation fault that GDB would detect at this point in the code?
> 
> 
> > I'd add to that a reference to [1]
> > 
> > [1] https://cygwin.com/faq.html#faq.programming.debugging-cygwin
> > 
> > Unfortunately, when investigating exceptions inside the cygwin dll, it's 
> > necessary to 'set cygwin-exceptions on', which will cause the debugger 
> > to actually stop at the point of the exception.
> > 
> > (This explains why the specific exception is SIGTRAP, and why you get 
> > the all the extra frames for exception handling below memmove in the 
> > backtrace)
> >
> 
> -- 
> Problem reports:      https://cygwin.com/problems.html
> FAQ:                  https://cygwin.com/faq/
> Documentation:        https://cygwin.com/docs.html
> Unsubscribe info:     https://cygwin.com/ml/#unsubscribe-simple


More information about the Cygwin mailing list