public inbox for glibc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "adhemerval.zanella at linaro dot org" <sourceware-bugzilla@sourceware.org>
To: glibc-bugs@sourceware.org
Subject: [Bug libc/28880] Program crashes if date beyone 2038
Date: Fri, 11 Feb 2022 11:55:11 +0000	[thread overview]
Message-ID: <bug-28880-131-rG0uyGmbLV@http.sourceware.org/bugzilla/> (raw)
In-Reply-To: <bug-28880-131@http.sourceware.org/bugzilla/>

https://sourceware.org/bugzilla/show_bug.cgi?id=28880

Adhemerval Zanella <adhemerval.zanella at linaro dot org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Target Milestone|---                         |2.36
           Assignee|unassigned at sourceware dot org   |adhemerval.zanella at linaro dot o
                   |                            |rg
     Ever confirmed|0                           |1
             Status|UNCONFIRMED                 |ASSIGNED
   Last reconfirmed|                            |2022-02-11
                 CC|                            |adhemerval.zanella at linaro dot o
                   |                            |rg

--- Comment #1 from Adhemerval Zanella <adhemerval.zanella at linaro dot org> ---

(In reply to Vignesh from comment #0)
> Hi,
> 
> I am trying to set a date (beyond 2038) and use the following example
> program.
> 
> https://stackoverflow.com/questions/70491311/after-update-glibc-to-version-2-
> 34-sem-open-failed-sem-open-fail-read-only
> If I set the date below 2038 the program executes well, and if I set 2039 it
> throws the below error
> 
> WORKS:
> root@(none):/home$ date -s "5 MAR 2037 18:00:00"                            
> 
> Thu Mar  5 18:00:00  2037
> root@(none):/home$ ./sem abc
> 
> FAILS:
> root@(none):/home$ date
> Sat Mar  5 18:00:12  2039
> root@(none):/home$ ./sem foo
> sem_open fail: Value too large for defined data type
> 
> All the userspace applications and the example program were compiled with
> these tokens
> -D_TIME_BITS=64 -D_FILE_OFFSET_BITS=64

It is a missing spot from my fix 52a5fe70a2c to use 64 bit stat internally, the
following makes the programs pass:

diff --git a/sysdeps/pthread/sem_routines.c b/sysdeps/pthread/sem_routines.c
index 9e1924398d..877e1e8556 100644
--- a/sysdeps/pthread/sem_routines.c
+++ b/sysdeps/pthread/sem_routines.c
@@ -25,7 +25,7 @@
 struct inuse_sem
 {
   dev_t dev;
-  ino_t ino;
+  ino64_t ino;
   int refcnt;
   sem_t *sem;
   char name[];
@@ -34,7 +34,7 @@ struct inuse_sem
 struct search_sem
 {
   dev_t dev;
-  ino_t ino;
+  ino64_t ino;
   int refcnt;
   sem_t *sem;
   char name[NAME_MAX + 1];
@@ -77,8 +77,8 @@ __sem_check_add_mapping (const char *name, int fd, sem_t
*existing)
   sem_t *result = SEM_FAILED;

   /* Get the information about the file.  */
-  struct stat64 st;
-  if (__fstat64 (fd, &st) == 0)
+  struct __stat64_t64 st;
+  if (__fstat64_time64 (fd, &st) == 0)
     {
       /* Get the lock.  */
       lll_lock (sem_mappings_lock, LLL_PRIVATE);

> 
> But the glibc 2.34 wasn't compiled with those.
> 
> My understanding is that glibc also sholud be compiled with -D_TIME_BITS=64
> -D_FILE_OFFSET_BITS=64

No, these flags should be used only the programs to select the time_t and LFS
support. glibc from 2.34 always provide both 32-bit and 64-bit time_t ABI,
there is no need to enable it either through configure or extra cflags.

-- 
You are receiving this mail because:
You are on the CC list for the bug.

  reply	other threads:[~2022-02-11 11:55 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-02-11  4:17 [Bug libc/28880] New: " drvignesh1992 at gmail dot com
2022-02-11 11:55 ` adhemerval.zanella at linaro dot org [this message]
2022-02-16 13:45 ` [Bug libc/28880] " adhemerval.zanella at linaro dot org

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=bug-28880-131-rG0uyGmbLV@http.sourceware.org/bugzilla/ \
    --to=sourceware-bugzilla@sourceware.org \
    --cc=glibc-bugs@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).