X-Recipient: archive-cygwin@delorie.com
DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org B62353858C52
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cygwin.com;
	s=default; t=1696965745;
	bh=p/KgBaPaFcMoksvOyWDynY443/1iytCVcLW5ewufriQ=;
	h=Date:To:Subject:List-Id:List-Unsubscribe:List-Archive:List-Post:
	 List-Help:List-Subscribe:From:Reply-To:From;
	b=g1ZN9+js4XKIIqVhfq5nZsQcfycGGmrbxJstnW++mATzSslfB3ZLb9mun9PlzfUc3
	 WBMznnyTWclB7JKcNGA/icgv86GQ6Z4q/3M3eRDrL2RiDGzGD08w/gGjr87ybOWH5u
	 xfRsqS02yvYQXwSvLMSpNnjXywLl2eEE6xqkpUBA=
X-Original-To: cygwin@cygwin.com
Delivered-To: cygwin@cygwin.com
DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 3B8D43858CDB
Date: Tue, 10 Oct 2023 19:22:03 +0000
To: "cygwin@cygwin.com" <cygwin@cygwin.com>
Subject: Freezing because cwdstuff::set has excessive release_write
Message-ID: <FBphpN4LL2Dqry5xVx3GF2FZQd7TMNO4Tqmk06glsEus-YNDU5epdecaqha2X9O3uJAlJVomBeZK3NCZ9boqvaW8SafM9dbfGBsHhEcBSC4=@proton.me>
Feedback-ID: 63211331:user:proton
MIME-Version: 1.0
X-Spam-Status: No, score=-2.8 required=5.0 tests=BAYES_00, DKIM_SIGNED,
 DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, KAM_INFOUSMEBIZ, RCVD_IN_MSPIKE_H4,
 RCVD_IN_MSPIKE_WL, SPF_HELO_PASS, SPF_PASS,
 TXREP autolearn=no autolearn_force=no version=3.4.6
X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on
 server2.sourceware.org
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: tryandbuy via Cygwin <cygwin@cygwin.com>
Reply-To: tryandbuy <tryandbuy@proton.me>
Content-Type: text/plain; charset="us-ascii"
Content-Transfer-Encoding: 7bit
Sender: "Cygwin" <cygwin-bounces+archive-cygwin=delorie.com@cygwin.com>

I think that there is an excessive release_write() in cwdstuff::set.
A link to the call:
https://github.com/cygwin/cygwin/blob/fe5886a500e66cddf0f57eea3049d25d5f8765e9/winsup/cygwin/path.cc#L4871C13-L4871C13

This call leads to a double release of SRW lock which causes deadlocks in some cases.

Test cases to this issue:
1) using Cygwin terminal
  1.  open Cygwin terminal
  2.  mkdir test; cd test; echo 123 > 1.txt
  3.  chmod -x .
  4.  strace cat 1.txt  # <-- freeze
      # cd ..; strace cat test/1.txt  # <-- no freeze

2) using windows console
  1. open cmd.exe
  2. cd <path to the previously created test directory>
  3. C:\cygwin64\bin\cat.exe 1.txt  & rem <-- freeze
     rem cd ..; C:\cygwin64\bin\cat.exe test\1.txt <-- no freeze


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