delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2026/03/02/08:32:14

DMARC-Filter: OpenDMARC Filter v1.4.2 delorie.com 622DWECR3945000
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 622DWECR3945000
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=HoGYKr+Y
X-Recipient: archive-cygwin AT delorie DOT com
DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 73B514BA23E8
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cygwin.com;
s=default; t=1772458332;
bh=RSfgsHYuQkQ08EY1w4a+NYHO0GYjYYuKsJcaE67j4Ow=;
h=Subject:To:References:Date:In-Reply-To:List-Id:List-Unsubscribe:
List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:
From;
b=HoGYKr+YU7dw7ARY+5XFqEsN2sABxIISU/CnQVk08TiOI5v77MkzgayVZN+Kh2dJD
uCl9n+y5tgnp/t+7IIyRcix/scfUsrUQqqi9q+9oZj+IKZl0LlQBZFdZeXF1aeVwOp
DCHyFskHtDmwjkMiCGPg38z2CN+U9WvzMdPOD8wA=
X-Original-To: cygwin AT cygwin DOT com
Delivered-To: cygwin AT cygwin DOT com
DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 987164BA2E13
ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 987164BA2E13
ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1772458312; cv=none;
b=faTuX3liDywlOufvZt2GApDcN486vNR3c4TcNBKDFfMs48VfrMJkRqMK9GsOyMTluAkk8IASEuRRHl6LpfT07pAFH0k6v67ud/L+GL2cmPcohk0ma0CCTJdC4kcr9pNUCkR4JUniqXAoLuyKMqJJXWSsWHfxGzbEkausU3bGVxM=
ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key;
t=1772458312; c=relaxed/simple;
bh=Y2/lXpFHSbyO1dKMvCI5LRATqjSS5n40FastwkaVBWM=;
h=DKIM-Signature:Subject:To:From:Message-ID:Date:MIME-Version;
b=PKD38WmpI94K/0iNpBio3PmOtvlnjA0SoxaJ+8p4+SX3kCpb1aqNvJvqqM8wdzCRxQPdXHchZiHK8mUXVpQzyMdA5F6gBkFJc+Fs275Jdddxd0oZKHCABiGS1EPEWH7KbPVptLUUKzLCoeykYLrHhHty7BN23oBUglcIuH2q4mU=
ARC-Authentication-Results: i=1; server2.sourceware.org
DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 987164BA2E13
Subject: Re: Memmove causing program crashes, giving SIGTRAP in GDB(?)
To: cygwin AT cygwin DOT com
References: <547312365 DOT 1464244 DOT 1771958282029 AT connect DOT xfinity DOT com>
<aZ7PrbisVR1R4A7v AT dimstar DOT local DOT net>
<1670201592 DOT 1489273 DOT 1772043520008 AT connect DOT xfinity DOT com>
<e91d8b5b-2690-4271-aa74-e6226440e33d AT SystematicSW DOT ab DOT ca>
<1044918836 DOT 1507810 DOT 1772086967212 AT connect DOT xfinity DOT com>
<1579472684 DOT 1508349 DOT 1772092747339 AT connect DOT xfinity DOT com>
<aaABFf5iEowV1l7I AT xps13> <1148572549 DOT 1808180 DOT 1772097444036 AT mail DOT yahoo DOT com>
<1901597260 DOT 1508573 DOT 1772100378936 AT connect DOT xfinity DOT com>
<0C965DD0-856E-41FF-B5A4-15E472292A32 AT unified-streaming DOT com>
<483908609 DOT 1508714 DOT 1772103775739 AT connect DOT xfinity DOT com>
<2346fd41-2500-0db6-5849-6788174b5a1d AT cs DOT umass DOT edu>
<1462848037 DOT 1521935 DOT 1772136952077 AT connect DOT xfinity DOT com>
<609655EE-8E9D-4522-A05C-F74C3FC89583 AT unified-streaming DOT com>
<957583332 DOT 1523179 DOT 1772138829815 AT connect DOT xfinity DOT com>
<6E812632-0E73-464A-AAB9-DC5BC5546B4C AT unified-streaming DOT com>
Organization: WiseMo A/S
Message-ID: <769c6fb0-9021-671e-80b3-c1822fbdecef@wisemo.com>
Date: Mon, 2 Mar 2026 14:31:46 +0100
X-Mailer: Epyrus/2.1.3
MIME-Version: 1.0
In-Reply-To: <6E812632-0E73-464A-AAB9-DC5BC5546B4C@unified-streaming.com>
X-Content-Filtered-By: Mailman/MimeDel 2.1.30
X-BeenThere: cygwin AT cygwin DOT com
X-Mailman-Version: 2.1.30
List-Id: General Cygwin discussions and problem reports <cygwin.cygwin.com>
List-Unsubscribe: <https://cygwin.com/mailman/options/cygwin>,
<mailto:cygwin-request AT cygwin DOT com?subject=unsubscribe>
List-Archive: <https://cygwin.com/pipermail/cygwin/>
List-Post: <mailto:cygwin AT cygwin DOT com>
List-Help: <mailto:cygwin-request AT cygwin DOT com?subject=help>
List-Subscribe: <https://cygwin.com/mailman/listinfo/cygwin>,
<mailto:cygwin-request AT cygwin DOT com?subject=subscribe>
From: Jakob Bohm via Cygwin <cygwin AT cygwin DOT com>
Reply-To: Jakob Bohm <jb AT wisemo DOT com>
Errors-To: cygwin-bounces~archive-cygwin=delorie DOT com AT cygwin DOT com
Sender: "Cygwin" <cygwin-bounces~archive-cygwin=delorie DOT com AT cygwin DOT com>
X-MIME-Autoconverted: from base64 to 8bit by delorie.com id 622DWECR3945000

Hi,

This is patent disinformation.  On any decent x86 operating system, the 
CPU scheduler that switches between threads preserves all registers and 
flags in a per thread context structure somewhere in the OS kernel.  The 
only thing another thread can do to interfere with a running REP MOVS is 
to deallocate / protect the address ranges accessed, and or use low 
level thread functions to change the saved registers of a non-running 
thread using OS calls such as (on Win32) SetThreadContext(), 
TerminateThread() and/or DebugActiveProcess() .

Also, a famous feature of x86 CPUs is that they will happily access 
unaligned memory using the basic integer instruction set, which includes 
REP MOVSQ, but not some of the wide MMX/SSE instructions that can be 
used for optimal memcpy/memmove implementations according to AMD and Intel.

Then there is of cause the ever-present spectre of a buggy CPU not doing 
what the code tells it to do.  Somewhere else in this thread, someone 
mentioned a specific such bug but stated the affected CPU models only in 
terms of code names.

On 26/02/2026 22:42, Dimitry Andric via Cygwin wrote:
> If such a crash occurs, can you do a "thread apply all bt" in gdb? This will show what all the other threads are doing. I'm betting some other thread is calling memcpy or some other function that is messing with the direction flag.
>
> -Dimitry
>
>> On 26 Feb 2026, at 21:47, KENNON J CONRAD <kennonconrad AT comcast DOT net> wrote:
>>
>> Yes, lots.  7 threads were running at the point of the crash  87% load on my i7-4790k.  I did a little research since the last post.  The memmove code where the crash occurs is:
>>
>>    0x00007ff96ba812a8 <+136>: std
>> => 0x00007ff96ba812a9 <+137>: rep movsq %ds:(%rsi),%es:(%rdi)
>>    0x00007ff96ba812ac <+140>: cld
>>
>> This sets the direction flag immediately before the rep movsq and clears the direction flag immediately after the rep movsq.  Yet when gdb breaks it shows the direction flag is not set:
>>
>> eflags         0x246               [ PF ZF IF ]
>>
>>   Would a forward move on overlapping data cause the SIGTRAP?  Could the code have moved to a different core?  Or could it have been interrupted by some other task that corrupts the flag?  As I mentioned earlier, the rep movsq is only failing once per several million times memmove is called so it seems likely to be something along those lines.
>>
>> -Kennon
>>
>>
>>> On 02/26/2026 12:20 PM PST Dimitry Andric <dimitry AT unified-streaming DOT com> wrote:
>>>
>>>
>>> Is there some concurrency going on? Maybe some other part of the program is flipping the direction flag?
>>>
>>> -Dimitry
>>>
>

-- 
Jakob Bohm, CIO, partner, WiseMo A/S. https://www.wisemo.com
Transformervej 29, 2860 Soborg, Denmark. direct: +45 31 13 16 10 
<tel:+4531131610>
This message is only for its intended recipient, delete if misaddressed.
WiseMo - Remote Service Management for PCs, Phones and Embedded

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

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019