DMARC-Filter: OpenDMARC Filter v1.4.2 delorie.com 62D5G8v7366337
Authentication-Results: delorie.com; dmarc=pass (p=none dis=none) header.from=cygwin.com
Authentication-Results: delorie.com; spf=pass smtp.mailfrom=cygwin.com
DKIM-Filter: OpenDKIM Filter v2.11.0 delorie.com 62D5G8v7366337
Authentication-Results: delorie.com;
	dkim=pass (1024-bit key, unprotected) header.d=cygwin.com header.i=@cygwin.com header.a=rsa-sha256 header.s=default header.b=ubvsuXDp
X-Recipient: archive-cygwin@delorie.com
DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 252204C3185C
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cygwin.com;
	s=default; t=1773378967;
	bh=ZFBRqW28opnfQF7K+jG5mbFd36GU30OYIHvPhGfigvA=;
	h=Date:To:Cc:In-Reply-To:References:Subject:List-Id:
	 List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe:
	 From:Reply-To:From;
	b=ubvsuXDpAihQl1SmjccqsB58vMTe2YNhsVrR1bx0p45E7a292LnSmhAI3zOoCboH+
	 owSWtHjyIR7YEfvW/+fM10P4mGIAyqzpJPTZTNhNO90TY6sONKzh1Dab4lA1GnzXkd
	 FPi52kcyVedFXJEl0tIcS/MbPIKdW6h5r3NUCVCo=
X-Original-To: cygwin@cygwin.com
Delivered-To: cygwin@cygwin.com
DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org C33774C31803
ARC-Filter: OpenARC Filter v1.0.0 sourceware.org C33774C31803
ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1773378918; cv=none;
 b=azHpjYcaRyU7AS1SCwW0k0zO3xr7qZRJoSinc8MMGmNY7SEOCkg88Z/y5ijOWfOf9EFhtv3fonz5LErqUIlE3jrvZyWyZDXr/l/6QHxugeAOxCLmnIo/AUVuEbfwT40ONKmrnVR1K93BPqq1pPZqv7HskZ5+4SbnYtWrRSQ4FTw=
ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key;
 t=1773378918; c=relaxed/simple;
 bh=Ip7ruogkfKvtj/S8beyO7t3gzIvpAEbaEXd+/HwWdMQ=;
 h=DKIM-Signature:Date:From:To:Message-ID:Subject:MIME-Version;
 b=EV1uY5yVyGB+FgUTXO1QqGVToPsd9tPwNHyB7p5VGDXdwbjhemKCRVBELDzRrNH2kgiMISQfdp6viicIb43nVa91c/yeb0bxG1AbnE3rRKsJYHJkVOG0PfXWLQpxLLnwXPX9ZGWXWDSg+9df7Rg6aA7CQsUblPQL92goZN0KrQY=
ARC-Authentication-Results: i=1; server2.sourceware.org
DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org C33774C31803
Date: Thu, 12 Mar 2026 22:15:11 -0700 (PDT)
To: Jon Turney <jon.turney@dronecode.org.uk>
Cc: cygwin@cygwin.com
Message-ID: <533298615.52416.1773378911433@connect.xfinity.com>
In-Reply-To: <abd66c5d-6bcd-40ae-b7c6-a8a3325aca8e@dronecode.org.uk>
References: <547312365.1464244.1771958282029@connect.xfinity.com>
 <aZ7PrbisVR1R4A7v@dimstar.local.net>
 <1670201592.1489273.1772043520008@connect.xfinity.com>
 <e91d8b5b-2690-4271-aa74-e6226440e33d@SystematicSW.ab.ca>
 <1044918836.1507810.1772086967212@connect.xfinity.com>
 <abd66c5d-6bcd-40ae-b7c6-a8a3325aca8e@dronecode.org.uk>
Subject: Re: Memmove causing program crashes, giving SIGTRAP in GDB(?)
MIME-Version: 1.0
X-Priority: 3
Importance: Normal
X-Mailer: Open-Xchange Mailer v7.10.6-Rev83
X-Originating-IP: ::ffff:50.47.202.14
X-Originating-Port: 61420
X-Originating-Client: open-xchange-appsuite
X-CMAE-Envelope: MS4xfMcWuarJ6S7R2/mRPzQmmKmjPth4D59E6spFewpIloZD0afnnF2HpuGJlBUmZOukO1PZITt+QO1TJ8687ZX1d4xjzjpqEKSX2SCZ1onerirwU6Mzvxyr
 cn+YB8lNkE73eJ0f1jgwys06geo6g2YpsTGtmcJPMjbMixkZISsScTrmwJxiipkKUm7R2jfcBXuFgKW3NCqlwQTg4Lk76MklLu73fJOHqmfB/IxofF15EQO4
 ljIxGPDgEFpf6kHk7I+xaomS+0kb+zJXcjLEqT609A8=
X-BeenThere: cygwin@cygwin.com
X-Mailman-Version: 2.1.30
Precedence: list
List-Id: General Cygwin discussions and problem reports <cygwin.cygwin.com>
List-Unsubscribe: <https://cygwin.com/mailman/options/cygwin>,
 <mailto:cygwin-request@cygwin.com?subject=unsubscribe>
List-Archive: <https://cygwin.com/pipermail/cygwin/>
List-Post: <mailto:cygwin@cygwin.com>
List-Help: <mailto:cygwin-request@cygwin.com?subject=help>
List-Subscribe: <https://cygwin.com/mailman/listinfo/cygwin>,
 <mailto:cygwin-request@cygwin.com?subject=subscribe>
From: KENNON J CONRAD via Cygwin <cygwin@cygwin.com>
Reply-To: KENNON J CONRAD <kennonconrad@comcast.net>
Content-Type: text/plain; charset="us-ascii"
Content-Transfer-Encoding: 7bit
Errors-To: cygwin-bounces~archive-cygwin=delorie.com@cygwin.com
Sender: "Cygwin" <cygwin-bounces~archive-cygwin=delorie.com@cygwin.com>

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
