DMARC-Filter: OpenDMARC Filter v1.4.2 delorie.com 61QMUwME1270370
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 61QMUwME1270370
Authentication-Results: delorie.com;
	dkim=fail reason="signature verification failed" (1024-bit key, unprotected) header.d=cygwin.com header.i=@cygwin.com header.a=rsa-sha256 header.s=default header.b=JKaPVS4S
X-Recipient: archive-cygwin@delorie.com
DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 18D734BA23CA
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cygwin.com;
	s=default; t=1772145057;
	bh=W43JDXgHT1WRHda28vljAC9WPjFJKmJKOOP0z3QbHuw=;
	h=Date:Subject:To:Cc:References:In-Reply-To:List-Id:
	 List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe:
	 From:Reply-To:From;
	b=JKaPVS4SKUYxw34u8d9HJQsMZGjsb6MkNz3XDBbaOVVnpyupy2XpweKhLiScl9Fkt
	 SXjnNda1DNTXsdF9LCr4rKjcANBaiXnCqoZBdSg27AWGBZfk1jrZMzgtXXRySIp/q4
	 nu0OYjgczRFXrbxHzRgcYZFrlFjpHlrRf4SByEoU=
X-Original-To: cygwin@cygwin.com
Delivered-To: cygwin@cygwin.com
DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org EABD94BA2E11
ARC-Filter: OpenARC Filter v1.0.0 sourceware.org EABD94BA2E11
ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1772145006; cv=none;
 b=pkXMRYx6OBhVvitN7+Pe3Q6Agyequs3aPetKnaQjfSW2hYqMOAQm0oJhtwpdu2Y9q4gt3RwTZdbHCcpK3WCxziHiObOYCaIrTVk/9fMnREV4x7vjKxts6+EvfqRBV5Nz9pHS9r3BU0i2eJEmNTFuwxoKi3uF6gBQQ2m7Pg99wYM=
ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key;
 t=1772145006; c=relaxed/simple;
 bh=mvy7vh4YI8oa3GmWkCHkcSCg9qtxT8TunH+ascnAWjE=;
 h=DKIM-Signature:Message-ID:Date:MIME-Version:Subject:To:From;
 b=B0t2Tpld8dLUFgbXU0Bx52Kc76yz1ccYrE42YQuEmn1WkJE1MqolDqLyH9+4qcdVuqnYiD5homnwtBddsvApzFIrhGz8Goxk6qcrVq9wl0W7AXsqrrLLVAYRhBBWyuE3KeWewcDD2+n9M/MjUg5ZqtF/l7xjuZBhzNye1IG+seg=
ARC-Authentication-Results: i=1; server2.sourceware.org
DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org EABD94BA2E11
X-Barracuda-Envelope-From: moss@cs.umass.edu
X-Barracuda-RBL-Trusted-Forwarder: 128.119.240.136
DKIM-Filter: OpenDKIM Filter v2.11.0 mailsrv.cs.umass.edu B7D995BDCC
X-Barracuda-RBL-Trusted-Forwarder: 172.26.69.67
Message-ID: <399745a1-429a-ebb4-0f67-c32f6282caa6@cs.umass.edu>
Date: Thu, 26 Feb 2026 17:30:04 -0500
MIME-Version: 1.0
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101
 Thunderbird/102.15.1
Subject: Re: Memmove causing program crashes, giving SIGTRAP in GDB(?)
Content-Language: en-US
X-ASG-Orig-Subj: Re: Memmove causing program crashes, giving SIGTRAP in GDB(?)
To: KENNON J CONRAD <kennonconrad@comcast.net>,
        Dimitry Andric <dimitry@unified-streaming.com>
Cc: KENNON J CONRAD via Cygwin <cygwin@cygwin.com>
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>
 <1579472684.1508349.1772092747339@connect.xfinity.com>
 <aaABFf5iEowV1l7I@xps13> <1148572549.1808180.1772097444036@mail.yahoo.com>
 <1901597260.1508573.1772100378936@connect.xfinity.com>
 <0C965DD0-856E-41FF-B5A4-15E472292A32@unified-streaming.com>
 <483908609.1508714.1772103775739@connect.xfinity.com>
 <2346fd41-2500-0db6-5849-6788174b5a1d@cs.umass.edu>
 <1462848037.1521935.1772136952077@connect.xfinity.com>
In-Reply-To: <1462848037.1521935.1772136952077@connect.xfinity.com>
X-Barracuda-Connect: mailsrv.cs.umass.edu[128.119.240.136]
X-Barracuda-Start-Time: 1772145003
X-Barracuda-Encrypted: TLS_AES_256_GCM_SHA384
X-Barracuda-URL: https://barramail.cs.umass.edu:443/cgi-mod/mark.cgi
X-Barracuda-BRTS-Status: 1
X-Virus-Scanned: by bsmtpd at cs.umass.edu
X-Barracuda-Scan-Msg-Size: 2192
X-ASG-Debug-ID: 1772145003-24039d07336b500001-w5GHUG
X-Barracuda-Spam-Score: 0.00
X-Barracuda-Spam-Status: No, SCORE=0.00 using global scores of TAG_LEVEL=3.5
 QUARANTINE_LEVEL=10.0 KILL_LEVEL=9.7 test= 
X-Barracuda-Spam-Report: Code version 3.2, rules version 3.2.3.125474
 Rule breakdown below
 pts rule name              description
 ---- ---------------------- --------------------------------------------------
X-BeenThere: cygwin@cygwin.com
X-Mailman-Version: 2.1.30
List-Id: General Cygwin discussions and problem reports <cygwin.cygwin.com>
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: Eliot Moss via Cygwin <cygwin@cygwin.com>
Reply-To: Eliot Moss <moss@cs.umass.edu>
Content-Transfer-Encoding: 7bit
Content-Type: text/plain; charset="us-ascii"; Format="flowed"
Sender: "Cygwin" <cygwin-bounces~archive-cygwin=delorie.com@cygwin.com>

On 2/26/2026 3:15 PM, KENNON J CONRAD wrote:
> Hello Eliot,
> 
>     Yes, that helps a lot.  With the frame set to the one for memmove, the RSI register contains 0xa00035e0e.  With the candidates_index address of 0xa00034460, that indicates the RSI register is 0x19AE more than the array start index and corresponds to index 3287 of the uint16_t array.  The array index of the rightmost element that should be moved is 3359, so RSI holds an array index that is 72 less than the last index that should be moved.  But since the RSI is already set up for the next iteration of REP MOVSQ, it seems that 68 array elements should have been moved prior to the REP that gets the SIGTRAP.  So I checked the index array, and found it contains duplicate values of 2028 at both array indexes 3291 and 3292 (elements 3292 and above have been copied from elements 3291 and above).  There should not be any duplicate values in the active portion of the array except during the move.  So it seems that 17 REP MOVSQ's were completed successfully before the SIGTRAP prevented the
  18
>   th move from being completed.  It shouldn't stop until the 767th array element is moved, so this is pretty early in the desired REP MOVSQ iterations.  Interestingly, the DF is not set in EFLAGS at the point where the SIGTRAP is issued (eflags 0x246 [ PF ZF IF ]) - I thought it should be set for backward REP MOVSQ's.

I know it's a low probability for a cause, but I wonder if either the
hardware or the OS have some issue with proper restartability of the
REP MOVSQ under some weird circumstance.  If the hardware/firmware
does not save the in-flight register information correct (again, in
some weird and rare situation) then restarting the instruction could
fail.  Might be worth:

(a) trolling the web to see if there are reports of issues around this
     instruction, Intel firmware fixes, etc.  (An instruction like REP
     MOVSQ is almost certainly implemented with a microcode loop, etc.)

(b) trying this exact code with a substantially different CPU model
     (which might tend to avoid any microcode bug in the model you're
     using).

Again, low probability, but ...

Regards - EM

-- 
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
