X-Recipient: archive-cygwin@delorie.com
DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org CD6FE3896C06
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cygwin.com;
	s=default; t=1610470516;
	bh=CI0sikDXP0rmOYqi2v6DUwJ/kLgeCiyeaMBcW61rL7k=;
	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=kW/LUR9o6pSaxaKq4comt1FWGa2nKlU8/xcBqPJOG/ZxsUi3ZMrkfr/oyMt9MZh+W
	 zDOxN29aoBeBkGbeiu3tXNdT9ax3H0fYWLmX1y0jNpIfjpfN0O6VsbZhfziZuF9g8H
	 XZ7lNajwAjkI76ylWwDVEBto0svlS8gs8lXKbGbE=
X-Original-To: cygwin@cygwin.com
Delivered-To: cygwin@cygwin.com
DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 83738386F439
ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none;
 b=KDivyEJxb7GnEFWxK+GpY717klpeKmoEemYuTqXEwzYg8D/fxn/CwrP1j2LDmStNg6EinlpRGtObPUq+JUySkRRW30qOxcb8oC08Mng5HK8ceqLR5bEYzk62GNZAizcYIb9lGfkN8nT0/EeEwEHKhIw2Q0YW30F+aHR5/DUsergABDuNHpTLdnOHvfm4XRRe8Msg8OorfjZQczeM+X8UKvuIg8HxG7o6LWyaHv4aCZAZj1eCzB3iytIMT0pN8MgeJiNm1ZANc6QT0qRgVoAtGQIKHG3/p8G9fwRfTfCaszPpZARRQ0gUWI2gxRpi3Ywmc3hsIb/UCvVFGB8O3RQXbg==
ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; 
 s=arcselector9901;
 h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck;
 bh=k/8Tf2ZkcRxT+m9BDW16R7LY+oAlEeyY1G6jHKHDeLM=;
 b=Pr2FLxhbJvqrL2eh7KdwfsRiKaPoCJBdyXWmZ7vgYvjrKUfh8a8CZJKAgZqYoJQBvbCxnG3yPrIenHoItZII7r0tthLRf6aGEaeZLnfqenEIsc3B/XEZXRnNP4t8AkGHz+zZWjGMH6eJyJTRfFblsAalPFMXNfwPnnrFyKWoeTUbsVsFvb330U0xOtYLCZGg+XBiB1QLcFQIUYgzLHRrKXBS6wGJp64K3MLfp/kzOw0JWyfD9N4y1Fbc+VeUdfCfQOjNgMLjqLxRgCgZIG/laThWzZOXQU5xWcghOm8nR+l1Hm3t49zp77aRTglmZ20gdRTdKPSjcoILsEGV8WH/uw==
ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass
 smtp.mailfrom=cornell.edu; dmarc=pass action=none header.from=cornell.edu;
 dkim=pass header.d=cornell.edu; arc=none
Subject: Re: tar 1.33 symlinks : Cannot change mode to...
To: cygwin@cygwin.com
References: <PU1PR04MB25507BD8BECC57FABE96DC8590AB0@PU1PR04MB2550.apcprd04.prod.outlook.com>
 <1dff3bac-a82e-f30a-a86d-a4dcc08c849b@cornell.edu>
Message-ID: <3a435fba-bdd2-535d-2161-f2fb75e2a4af@cornell.edu>
Date: Tue, 12 Jan 2021 11:55:10 -0500
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101
 Thunderbird/78.5.1
In-Reply-To: <1dff3bac-a82e-f30a-a86d-a4dcc08c849b@cornell.edu>
Content-Language: en-US
X-Originating-IP: [65.112.130.200]
X-ClientProxiedBy: BN4PR10CA0002.namprd10.prod.outlook.com (2603:10b6:403::12)
 To BN7PR04MB4388.namprd04.prod.outlook.com
 (2603:10b6:406:f8::19)
MIME-Version: 1.0
X-MS-Exchange-MessageSentRepresentingType: 1
Received: from [10.13.22.4] (65.112.130.200) by
 BN4PR10CA0002.namprd10.prod.outlook.com (2603:10b6:403::12) with Microsoft
 SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id
 15.20.3763.9 via Frontend Transport; Tue, 12 Jan 2021 16:55:11 +0000
X-MS-PublicTrafficType: Email
X-MS-Office365-Filtering-Correlation-Id: b0ddb0ac-25cf-47dc-bbf1-08d8b71ad378
X-MS-TrafficTypeDiagnostic: BN7PR04MB3841:
X-Microsoft-Antispam-PRVS: <BN7PR04MB384137AD38661F9C702DD961D8AA0@BN7PR04MB3841.namprd04.prod.outlook.com>
X-MS-Oob-TLC-OOBClassifiers: OLM:10000;
X-MS-Exchange-SenderADCheck: 1
X-Microsoft-Antispam: BCL:0;
X-Microsoft-Antispam-Message-Info: PbRapYeYtKJTNWCaST/y0USLBjdnu6h/rw/Pb7SsI1JKNxvreYe/pKIaIVc6nzZV+o485ENmtv5wp1dbscOBPbFetoZDRNCr2VynYl6Z2kBU/fcb42E1x+rz50Vby32d5ia2NpFCvKWZPJ7hFr3BdWaEIblEe96nBhonE+g9FVFyIzqTVjsAAwncpg2bh3isZgu/K3goOzYAY2lORthd/ibUCMRuVJp7zNYuUxrVsuAPLoW4N2B9wjqPRvFQE3BXmcO7ubgy6HZ1xcvpoamVVcJACfphL8IDz+nSqiXqBxlS5q3RMCu8N0iZNxSx1Fu0zF7C9MFsYEy5rvhKkcx8pVkaiLEegAWkDzeUs6BkBTt2l4xw7LEvXEgQVK6S9ptvxUNQmvoaomRZ6wdZlXSWsI/94KpVCf+eBkLP2AMCCEKyKkoaKtaGokR3hOKjHSGH/efjZzW5NCOsCm5h3OQdg+Jc+FqB0632fF1LSs+l/Rks5ZGbsp5n6l5FMYoDkh/RuoK9JnpcGkjcCEzerfy4SDzvI7JkydCW+0NAAploWhukEsHZV2w+iKS0CJ7pjIUb
X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:;
 IPV:NLI; SFV:NSPM; H:BN7PR04MB4388.namprd04.prod.outlook.com; PTR:; CAT:NONE;
 SFS:(4636009)(136003)(39860400002)(346002)(366004)(396003)(376002)(52116002)(2906002)(5660300002)(75432002)(86362001)(66476007)(478600001)(6486002)(31696002)(26005)(186003)(16526019)(316002)(36756003)(8676002)(966005)(2616005)(83380400001)(31686004)(66556008)(6916009)(956004)(786003)(16576012)(8936002)(66946007)(53546011)(45980500001)(43740500002);
 DIR:OUT; SFP:1102; 
X-MS-Exchange-AntiSpam-MessageData: =?Windows-1252?Q?bbPJ9xMxnUAagMLrKreH7LsPHuflzhMwB/mfAogh0Nst9JVsp1SlqIhq?=
 =?Windows-1252?Q?ud05gpEc4cfoaEeBl1zbFnSi0bi4J5m7tq9Ef9m3r2pNtMHRPtx2zK3o?=
 =?Windows-1252?Q?wGe0VZbcjItDYU2nqy3/j2wyI43Liat0onPjvpVxHK5Jk566ziXf5v8f?=
 =?Windows-1252?Q?CPH5aKNCL8pfYxc7Apd9UG2zt01h2JevJmER9zjBSk/ZfNbf3QGDes4l?=
 =?Windows-1252?Q?VxGSVSDb+DyRE5IniOAfrR7p30jbT0zehNPFsS9mGEDWiM5VOKCc/VO7?=
 =?Windows-1252?Q?Y16OdqX6wtNQBMK2wMGdDQYV4WFiCgIMN8oQiQWkpgtyviep1aFrv84C?=
 =?Windows-1252?Q?XiizFk7JkBVDn/BIbR8tvPzfSG2Mls4pezNzfZZaTT8xVowJEp7wUWPP?=
 =?Windows-1252?Q?vhkpYjlNXnCILBqHmNFwDKMa3i72kRSWlzD71GBFBF/oms4Ip9mdaId1?=
 =?Windows-1252?Q?rUecSepJg3V3o/pzZ7AvIsoHLUoPYlH/YuukD/WXDhNNEDM9Lgy/48qe?=
 =?Windows-1252?Q?Dc76j53cJf+VxwdXd6s0/Vk6vTj85/ZRozjcZ52HpjV1DVi/ChapTub5?=
 =?Windows-1252?Q?ibiXwMppt0/DSZxCEb6VRb87XJ4+j7uyf/mYuN09CpJnkajQzVoHCfdL?=
 =?Windows-1252?Q?DoOPxs17XraPbcaChY+ikn3EKtew5iEv1YkyDU1zVbFxbrSSbdaBKCjj?=
 =?Windows-1252?Q?bPneiAS4N/Ob4WqKoL0ouiO+6spSwJ7nTyz1IvlR5oXalK093SVwprPI?=
 =?Windows-1252?Q?hx3zKRXZhurZlachPeUZS2dlKhgGLN5BnoIUaPIA4Ei3QTDQCo7nELnq?=
 =?Windows-1252?Q?FUTuBB7drxeyHF9ziyl9IBJfOeoPfg95Fr8DBQ0dVT+olSsogjLUHqkH?=
 =?Windows-1252?Q?kUoWDMf3HeS3cjxEIwksWWkopcl8N7a8UnGdt5ISbVIdQuWGnjQRn1j3?=
 =?Windows-1252?Q?FD/oaRp9nJZin/gKAkAssqroEN/uZ/pDOtvZfKt1DnyJ0iHOPGgTWifD?=
 =?Windows-1252?Q?Ccr0HJzRSom6O2+2HzNknzh/NjDYhMkbwwxXnM4aBWzn0tnJ9mLO0Ysk?=
 =?Windows-1252?Q?TM5yE4Lcp94iN8Uo?=
X-OriginatorOrg: cornell.edu
X-MS-Exchange-CrossTenant-AuthSource: BN7PR04MB4388.namprd04.prod.outlook.com
X-MS-Exchange-CrossTenant-AuthAs: Internal
X-MS-Exchange-CrossTenant-OriginalArrivalTime: 12 Jan 2021 16:55:11.6973 (UTC)
X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted
X-MS-Exchange-CrossTenant-Id: 5d7e4366-1b9b-45cf-8e79-b14b27df46e1
X-MS-Exchange-CrossTenant-Network-Message-Id: b0ddb0ac-25cf-47dc-bbf1-08d8b71ad378
X-MS-Exchange-CrossTenant-MailboxType: HOSTED
X-MS-Exchange-CrossTenant-UserPrincipalName: 5/Whya5A/D95ynHk2Q0gaCSXOvc2huYEWa2wwHXsIAou7trmU7vH69iz2aofWBavzuIRyVOFawZ4rEyq/Ehxvw==
X-MS-Exchange-Transport-CrossTenantHeadersStamped: BN7PR04MB3841
X-Spam-Status: No, score=1.4 required=5.0 tests=BAYES_00, BODY_8BITS,
 DKIM_INVALID, DKIM_SIGNED, KAM_DMARC_STATUS, MSGID_FROM_MTA_HEADER,
 NICE_REPLY_A, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2, SPF_HELO_PASS, SPF_PASS,
 TXREP autolearn=no autolearn_force=no version=3.4.2
X-Spam-Level: *
X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on
 server2.sourceware.org
X-BeenThere: cygwin@cygwin.com
X-Mailman-Version: 2.1.29
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: Ken Brown via Cygwin <cygwin@cygwin.com>
Reply-To: Ken Brown <kbrown@cornell.edu>
Content-Type: text/plain; charset="windows-1252"; Format="flowed"
Errors-To: cygwin-bounces@cygwin.com
Sender: "Cygwin" <cygwin-bounces@cygwin.com>
Content-Transfer-Encoding: 8bit
X-MIME-Autoconverted: from quoted-printable to 8bit by delorie.com id 10CGtgSn018320

On 1/11/2021 6:50 PM, Ken Brown via Cygwin wrote:
> On 1/11/2021 2:57 PM, Morgan King via Cygwin wrote:
>> Hello,
>>
>> I am experiencing the same issue with tar and I am able to reproduce it 
>> following the steps at:
>> https://lists.gnu.org/archive/html/bug-tar/2011-08/msg00006.html
>>
>> This issue only appears to occur when using 32-bit Cygwin, I am unable to 
>> reproduce it using 64-bit Cygwin.
> 
> I can confirm this.  Running the tar command under gdb shows a problem at 
> gnu/fchmodat.c:94:
> 
> 94            if (S_ISLNK (st.st_mode))
> 
> Here st is a stat structure for directory/1, so S_ISLNK() should be true.  It is 
> indeed true on 64-bit Cygwin but not on 32-bit Cygwin.  Someone needs to look 
> more closely and find out why this happened.  I'll try to do it tomorrow if no 
> one beats me to it.

This appears to be a bug in fstat in 32-bit Cygwin.  Here's what I'm seeing in 
gdb, using an unoptimized build of cygwin1.dll.  There is a call to fstatat in 
the tar source file gnu/fchmodat.c:87.  This ultimately leads to a call to 
fstat, whose definition in syscalls.cc is the following in the 32-bit case:

extern "C" int
fstat (int fd, struct stat *buf)
{
   struct stat buf64;
   int ret = fstat64 (fd, &buf64);
   if (!ret)
     stat64_to_stat32 (&buf64, (struct __stat32 *) buf);
   return ret;
}

After the call to fstat64, buf64 looks like this:

(gdb) p/o buf64
$20 = {st_dev = 016465473173, st_ino = 01240000000006533716,
   st_mode = 0120777, st_nlink = 01, st_uid = 0601751, st_gid = 0601001,
   st_rdev = 0, st_size = 01, st_atim = {tv_sec = 013777346014,
     tv_nsec = 03415154434}, st_mtim = {tv_sec = 013777334323, tv_nsec = 0},
   st_ctim = {tv_sec = 013777346014, tv_nsec = 03421004710},
   st_blksize = 0200000, st_blocks = 0, st_birthtim = {tv_sec = 013777346014,
     tv_nsec = 03415154434}}

After the call to stat64_to_stat32, buf looks like this:

(gdb) p/o *buf
$22 = {st_dev = 026106753173, st_ino = 017510000040000120777, st_mode = 01001,
   st_nlink = 01, st_uid = 013777346014, st_gid = 03415154434,
   st_rdev = 013777334323, st_size = 0161040234413777346014, st_atim = {
     tv_sec = 0200000, tv_nsec = 0}, st_mtim = {tv_sec = 01, tv_nsec = 0},
   st_ctim = {tv_sec = 06533716, tv_nsec = 025000000}, st_blksize = 0,
   st_blocks = 0, st_birthtim = {tv_sec = 0, tv_nsec = 03}}

Note that many of the values have been corrupted or shifted.  (A few are 
expected to change.)  I think the problem is the cast in the call

   stat64_to_stat32 (&buf64, (struct __stat32 *) buf);

I don't see how that could be expected to work, since several members of struct 
__stat32 have different sizes than the corresponding members of struct stat.  I 
wonder if it worked by accident in the past, but the problem is just showing up 
with newer gcc because of changes in how it pads the two structs?

Corinna, can you shed some light on this?

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

