delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2025/11/08/12:52:36

DMARC-Filter: OpenDMARC Filter v1.4.2 delorie.com 5A8HqZuw093572
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 5A8HqZuw093572
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=EcG9UB2y
X-Recipient: archive-cygwin AT delorie DOT com
DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 8E75A3858406
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cygwin.com;
s=default; t=1762624353;
bh=FrXjG29jzbpXNSD7BD8SfE0uFZZNmh7h4iHL2AJnJYo=;
h=References:In-Reply-To:Date:Subject:To:List-Id:List-Unsubscribe:
List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:
From;
b=EcG9UB2yaxVL/AQkedBxWypYSygFqgSowThLGR0g4Tpwtt8qXf8omth+Mj1rbewbp
55T7NszqCM+HEGNmY1XXzRB+5Vvlmh55hzka//D66U2e43xrpxZmswXypFgDaKZEqn
mlkQSNEqmwUSE8uLRpLeBSewSSpuZyDOPku7JdzM=
X-Original-To: cygwin AT cygwin DOT com
Delivered-To: cygwin AT cygwin DOT com
DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org D90653858D26
ARC-Filter: OpenARC Filter v1.0.0 sourceware.org D90653858D26
ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1762624289; cv=none;
b=JqbyhfPV+pdemRgnfQLKWU5ZDv96kfQ63gJidHcUv1UnIoBzAyEeQM8/Nw0GBwpnMfITse+r9mg37ymwPlVct3LPl1IIhXlNRgCwEEH/sZO6V4K6xJfUJBpyvXiBbcZayBT6BwSWVMZFrDPfX5VQLluZ0yqbq/LiX5PlFo0MI+A=
ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key;
t=1762624289; c=relaxed/simple;
bh=miKEArEQfJWoLUGt+u/UipOcy5k9x8/aDQjkldzovEQ=;
h=DKIM-Signature:MIME-Version:From:Date:Message-ID:Subject:To;
b=kYWUOI5NQT2zzeXcZ2u+s+q+trX+O5kmaeEotBA+xdqahZ/tVSSb8YXf5s3hqE7AF90RkATYc/ibJMMYCDsMQFw1A0wg7LB+yMvOxY+mwkthXZpP/IUSaKGJ3JXw3Gci9DIeMb+U4wJSJokBLufAOVBazE22bYbJ/U5xQZ+sE9o=
ARC-Authentication-Results: i=1; server2.sourceware.org
DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org D90653858D26
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
d=1e100.net; s=20230601; t=1762624288; x=1763229088;
h=content-transfer-encoding:to:subject:message-id:date:from
:in-reply-to:references:mime-version:x-gm-gg:x-gm-message-state:from
:to:cc:subject:date:message-id:reply-to;
bh=kIEZgDSqyFecDWSRNcnqaT8c8STpUiyJ4aCoDzGJXG8=;
b=qXySCondu4ydajM4gtRaacfxztR44rauSmJHKlQHtYGuHDdnO0UoBJYpMJbXauAd+L
ZsMZh9Q3B1Zr73u5XFepCJ89LblthThUkimr74qbHpGyk+hROvCoKUO+vN5eoEKfLbq8
44HZQde3jyacky8nybff08SsJTRb0hpotxM7ERQPLNB6cYAgocsRsnwtpQBjuM4tmSmz
kQ88hqkKM6wimPQYEs84Ip7vbrWDJb5T2u/TYJvfKYHij5sDNg+te5mlLHvWpSWu9f44
bfADcw1xhnLAeT9RTzSYgYcgE0fMHKd/p13Fqlmt0m03Yv2GymLr9VHgJahRUWnfOhSI
q0Rg==
X-Gm-Message-State: AOJu0YxcWAjPxajvLSc3onwDtDQtcRlgxiSLveT8/ZqitFcMgpSSBwP4
XT9/JolCGPPvHVOmHtSFIiovEHF/KTraxO7/3H/5e943gq0Qjr3UQiNheEWU3j3zN6cVMazwxOK
7RteXeFquWMaaGQLFZMfcevE4vMVR+tGM
X-Gm-Gg: ASbGncsXl5F+bL+ldYt0NR07L+4JB0oCXFpVcomNxjgrsDdLpWNVbe1WplAUaTO9/0t
4lfBmawSSwmFZJEKmHmOK6yGBftvuqYmNcTuxKd18vjpms4gt5QgsuZZJSXcQnuCBP0otFMYzmO
bl3QFmNRaeU7XTGfI+PZ44+vi9TD0+bQVphMOVNCY3rDTSLOkqgr6ZYtxA8G7XHsd87qDaDRIsN
1xdDqfckQItoPsGPyf+WpY2Ypsj4kOT/0wYQa0ycXZct1PqvRZbZRABl1W7l4ahN5N6yK5gCzCK
XTI/AI3HHBIsNKMV6VXY5me8kbn6fWVy8HXV
X-Google-Smtp-Source: AGHT+IGz89GbfEUdkDJ7QB/BzvfC0D8VDiaHXZdolbgPe47+80PzgJcu4YDGdWMkIglnV/+QV3MgKarFDhaqKC3a/cQ=
X-Received: by 2002:a05:690c:2d01:b0:786:5fdc:1d53 with SMTP id
00721157ae682-787d5374d18mr13774957b3.3.1762624288020; Sat, 08 Nov 2025
09:51:28 -0800 (PST)
MIME-Version: 1.0
References: <CA+1R0VjcBajGpLMJ_0Waie0g_5S15_kPfzpT2=GUyN+39RWrMw AT mail DOT gmail DOT com>
<CA+1R0Vg22nR0H7JBXQAuK2OcHZnOkoCOMRJ2PiNvXTPYrBQguw AT mail DOT gmail DOT com>
In-Reply-To: <CA+1R0Vg22nR0H7JBXQAuK2OcHZnOkoCOMRJ2PiNvXTPYrBQguw@mail.gmail.com>
Date: Sat, 8 Nov 2025 09:51:17 -0800
X-Gm-Features: AWmQ_bl0VFeJwcLyM_4LIp8cHZjsquAHi5DbYKNBXj6bnne_aPHDHlMwHjHK5L8
Message-ID: <CA+1R0Vh+3FpxQDgfOJcZfbzq3O63wDO7PSTKrySFgtjrhzd4BA@mail.gmail.com>
Subject: Re: flock/open random error
To: cygwin AT cygwin DOT com
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-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: Nahor via Cygwin <cygwin AT cygwin DOT com>
Reply-To: Nahor <nahor.j+cygwin AT gmail 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 5A8HqZuw093572

Hi,

Any feedback on this please, so we can decide on how to proceed on our side?

Thanks,
Nahor

On Wed, Oct 22, 2025 at 10:21 AM Nahor <nahor.j+cygwin AT gmail DOT com> wrote:
>
> Small simplification and generalization of the issue:
> The location of the directory and the file in relation to each other
> is irrelevant. I can still reproduce the issue with the directory
> being on one drive and the file on another. The flock error ("Bad
> addr") didn't happen in some variations (e.g. directory on C drive and
> file on D drive), but given how rare the error is to begin with, I
> assume it's only a timing issue (my D drive is older than my C for
> instance)
>
> On Tue, Oct 21, 2025 at 5:41 PM Nahor <nahor.j+cygwin AT gmail DOT com> wrote:
> >
> > Hi,
> >
> > There is a test in the Fish shell (tests::history::test_history_races)
> > that systematically fails when I run it. The test simulates multiple
> > processes/threads trying to write to the shell history file at the
> > same time.
> > In my case, the test freezes/deadlocks with errors like "Bad Addr" and
> > "Is Directory".
> > When I add a sleep, the freeze/deadlocks disappear but the test
> > eventually fails because the fake history is not the right size.
> > See https://github.com/fish-shell/fish-shell/issues/11933 for more details.
> >
> > I wrote a test case in pure C (attached) that also triggers the issue
> > although it's not as systematic (30-50%).
> > To compile: gcc main.c -o test.exe
> > To run: ./test.exe
> >
> >
> > Most failures look like this:
> >     ```
> >     $ ./test.exe
> >     tmp_dir: /tmp/flockc2Hz4c
> >     open file error: 21 - Is a directory
> >             /tmp/flockc2Hz4c/append_file
> >     assertion "file_fd >= 0" failed: file "main.c", line 49, function:
> > thread_func
> >     Aborted
> >     ```
> > Occasionally (maybe 10%), it looks like that:
> >     ```
> >     $ ./test.exe
> >     tmp_dir: /tmp/flock5Oly9J
> >     lock error: 14 - Bad address
> >     assertion "lock_res == 0" failed: file "main.c", line 38,
> > function: thread_func
> >     Aborted
> >     ```
> >
> > I believe the freeze/deadlock in the Fish test is because, unlike my
> > test, they don't assert/crash, and the next time they access the
> > history file, there is a bunch of deadlock in cygwin internals.
> > If that helps, this is a partial capture of the stack traces at one such time:
> >     ```
> >     Thread 9
> >     #2  0x00000001800d487f in muto::acquire (this=0x1802c24c0
> > <lock_process::locker>, ms=ms AT entry=4294967295) at
> > /d/S/B/src/msys2-runtime/winsup/cygwin/sync.cc:84
> >     #3  0x00000001800dd6e0 in dtable::lock (this=<optimized out>) at
> > /d/S/B/src/msys2-runtime/winsup/cygwin/local_includes/dtable.h:77
> >     #4  cygheap_fdnew::cygheap_fdnew (this=<synthetic pointer>,
> > seed_fd=-1, lockit=true) at
> > /d/S/B/src/msys2-runtime/winsup/cygwin/local_includes/cygheap.h:593
> >     #5  open (unix_path=0xa0002b3b0
> > "[...]/fish-shell/target/fish-test-home", flags=262144) at
> > /d/S/B/src/msys2-runtime/winsup/cygwin/syscalls.cc:1576
> >
> >     Thread 10
> >     #2  0x00000001800d487f in muto::acquire (this=0x1802c24c0
> > <lock_process::locker>, ms=ms AT entry=4294967295) at
> > /d/S/B/src/msys2-runtime/winsup/cygwin/sync.cc:84
> >     #3  0x00000001800dd6e0 in dtable::lock (this=<optimized out>) at
> > /d/S/B/src/msys2-runtime/winsup/cygwin/local_includes/dtable.h:77
> >     #4  cygheap_fdnew::cygheap_fdnew (this=<synthetic pointer>,
> > seed_fd=-1, lockit=true) at
> > /d/S/B/src/msys2-runtime/winsup/cygwin/local_includes/cygheap.h:593
> >     #5  open (unix_path=0xa0002bfe0
> > "[...]/fish-shell/target/fish-test-home/race_test_history.FwyAgK",
> > flags=264706) at
> > /d/S/B/src/msys2-runtime/winsup/cygwin/syscalls.cc:1576
> >
> >     Thread 11
> >     #2  0x00000001800670bb in inode_t::LOCK (this=0x80000ba20) at
> > /d/S/B/src/msys2-runtime/winsup/cygwin/flock.cc:314
> >     #3  inode_t::get (dev=1881899537, ino=ino AT entry=10977524092162599,
> > create_if_missing=create_if_missing AT entry=false, lock=lock AT entry=true)
> > at /d/S/B/src/msys2-runtime/winsup/cygwin/flock.cc:504
> >     #4  0x0000000180068eb1 in fhandler_base::del_my_locks
> > (this=0x80000b810, from=on_close) at
> > /d/S/B/src/msys2-runtime/winsup/cygwin/flock.cc:402
> >     #5  0x000000018010d5bf in fhandler_base::close_with_arch
> > (this=0x80000b810, flag=flag AT entry=-1) at
> > /d/S/B/src/msys2-runtime/winsup/cygwin/fhandler/base.cc:1306
> >     #6  0x00000001800de36b in __close (fd=5, flag=-1) at
> > /d/S/B/src/msys2-runtime/winsup/cygwin/syscalls.cc:1710
> >     #7  close (fd=5) at /d/S/B/src/msys2-runtime/winsup/cygwin/syscalls.cc:1722
> >
> >     Thread 12
> >     #2  0x00000001800d487f in muto::acquire (this=0x1802c24c0
> > <lock_process::locker>, ms=ms AT entry=4294967295) at
> > /d/S/B/src/msys2-runtime/winsup/cygwin/sync.cc:84
> >     #3  0x00000001800dd6e0 in dtable::lock (this=<optimized out>) at
> > /d/S/B/src/msys2-runtime/winsup/cygwin/local_includes/dtable.h:77
> >     #4  cygheap_fdnew::cygheap_fdnew (this=<synthetic pointer>,
> > seed_fd=-1, lockit=true) at
> > /d/S/B/src/msys2-runtime/winsup/cygwin/local_includes/cygheap.h:593
> >     #5  open (unix_path=0x7ff10b488
> > "[...]/fish-shell/target/fish-test-home/race_test_history.pZO5DS",
> > flags=263169) at
> > /d/S/B/src/msys2-runtime/winsup/cygwin/syscalls.cc:1576
> >     ```
> > The freeze/deadlock can be reproduced in my C code by calling
> > "continue" inside the "if (lock_res != 0) {" instead of triggering the
> > assert just after.
> >
> >
> > I haven't been able to reproduce the missing data in the history file
> > so it's unknown if it's an issue in Fish or flock not locking properly
> > at times. So far the test passes on Linux and MacOS.
> >
> >
> > Thanks,
> > Nahor

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