From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [216.205.24.124]) by sourceware.org (Postfix) with ESMTP id A3D993857807 for ; Mon, 8 Mar 2021 10:57:50 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org A3D993857807 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-295-CCPo_bUuNs2QP8XN4bGIvg-1; Mon, 08 Mar 2021 05:57:48 -0500 X-MC-Unique: CCPo_bUuNs2QP8XN4bGIvg-1 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 5A2EF8B8D00; Mon, 8 Mar 2021 10:57:47 +0000 (UTC) Received: from localhost (unknown [10.33.37.30]) by smtp.corp.redhat.com (Postfix) with ESMTP id D42E860C04; Mon, 8 Mar 2021 10:57:46 +0000 (UTC) Date: Mon, 8 Mar 2021 10:57:46 +0000 From: Jonathan Wakely To: Chen Li Cc: gcc-patches@gcc.gnu.org, libstdc++@gcc.gnu.org Subject: Re: [PATCH] skip testing time before epoch on mips Message-ID: References: <87ft16ywyr.wl-chenli@uniontech.com> MIME-Version: 1.0 In-Reply-To: <87ft16ywyr.wl-chenli@uniontech.com> X-Clacks-Overhead: GNU Terry Pratchett X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset=utf-8; format=flowed Content-Disposition: inline Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-8.3 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 08 Mar 2021 10:57:51 -0000 On 08/03/21 14:35 +0800, Chen Li wrote: > >When execute libstdc++ testcases on mips, I notice that last_write_time >alawys failed, and the failed VERIFY is "VERIFY( >approx_equal(last_write_time(f.path), time) );" where testing time before >than epoch. > >Below is the minimal case: > >``` >// gcc a.c >int main() >{ > struct timespec times[2] = {{1, UTIME_OMIT}, {-1201, 985000000}}; > utimensat(AT_FDCWD, "test", times, 0); > >} >``` > >$ touch test && gcc a.c && ./a.out && stat test > File: test > Size: 0 Blocks: 0 IO Block: 4096 regular empty file >Device: 805h/2053d Inode: 1056841 Links: 1 >Access: (0644/-rw-r--r--) Uid: ( 1000/ deepin) Gid: ( 1000/ deepin) >Access: 2021-03-08 13:52:55.966354501 +0800 >Modify: 2106-02-07 14:08:15.985000000 +0800 >Change: 2021-03-08 13:52:56.907782193 +0800 > Birth: - > >Undoubtedly, mtime's type is unsigned somewhere on mips. > >After debuging kernel, it turns out that mtime is always -1201 in >ext4_setattr, cp_new_stat, newlstat and etc, so the problem should not >occur in kernel space. > >go back to user space via copy_to_user, I finally found mips used >"unsigned int st_mtime_sec;" in struct kernel_stat, which is used to >receive -1201 from kernel. I can't reproduce this on a mips64 machine: jwakely@erpro8-fsf2:~$ uname -a Linux erpro8-fsf2 4.1.4 #1 SMP PREEMPT Mon Aug 3 14:22:54 PDT 2015 mips64 GNU/Linux jwakely@erpro8-fsf2:~$ apt list libc6 Listing... Done libc6/oldstable,now 2.19-18+deb8u10 mipsel [installed] jwakely@erpro8-fsf2:~$ touch test && ./a.out && TZ= stat test File: ‘test’ Size: 0 Blocks: 0 IO Block: 131072 regular empty file Device: 21h/33d Inode: 36596524 Links: 1 Access: (0644/-rw-r--r--) Uid: ( 1049/ jwakely) Gid: ( 1049/ jwakely) Access: 2021-03-08 10:52:06.855991946 +0000 Modify: 1969-12-31 23:39:59.985000000 +0000 Change: 2021-03-08 10:52:06.859992051 +0000 Birth: - This is an ext4 filesystem. Do I need to compile a 64-bit executable? In any case, shouldn't this be fixed in glibc to return EINVAL instead of setting a bogus time? That would make the std::filesystem library report an error. >Maybe sparc also suffers from this problem, but I have no machine to >verify. Your test case works correctly for me on sparc-linux (both 32-bit and 64-bit on ext4 and xfs filesystems): $ uname -a Linux gcc202 5.10.0-4-sparc64-smp #1 SMP Debian 5.10.19-1 (2021-03-02) sparc64 GNU/Linux $ apt list libc6 Listing... Done libc6/unstable,now 2.31-4 sparc64 [installed] $ ./a.out $ TZ= stat test File: test Size: 0 Blocks: 0 IO Block: 8192 regular empty file Device: fd01h/64769d Inode: 657291843 Links: 1 Access: (0644/-rw-r--r--) Uid: ( 1049/ jwakely) Gid: ( 1049/ jwakely) Access: 2021-03-08 10:25:43.593819539 +0000 Modify: 1969-12-31 23:39:59.985000000 +0000 Change: 2021-03-08 10:34:13.711287778 +0000 Birth: 2021-03-08 10:24:27.106598699 +0000