public inbox for glibc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug libc/28880] New: Program crashes if date beyone 2038
@ 2022-02-11  4:17 drvignesh1992 at gmail dot com
  2022-02-11 11:55 ` [Bug libc/28880] " adhemerval.zanella at linaro dot org
  2022-02-16 13:45 ` adhemerval.zanella at linaro dot org
  0 siblings, 2 replies; 3+ messages in thread
From: drvignesh1992 at gmail dot com @ 2022-02-11  4:17 UTC (permalink / raw)
  To: glibc-bugs

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

            Bug ID: 28880
           Summary: Program crashes if date beyone 2038
           Product: glibc
           Version: 2.34
            Status: UNCONFIRMED
          Severity: critical
          Priority: P2
         Component: libc
          Assignee: unassigned at sourceware dot org
          Reporter: drvignesh1992 at gmail dot com
                CC: drepper.fsp at gmail dot com
  Target Milestone: ---

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

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

But when I try to compile glibc 2.34 with those tokens I am getting build error
like below.


| arm-poky-linux-gnueabi-gcc  -march=armv7-a -mthumb -mfpu=neon
-mfloat-abi=hard 
--sysroot=/home/vignesh.r/factory/yocto/bbb-bits-time/poky/build/tmp/work/armv7at2hf-neon-poky-linux-gnueabi/glibc/2.34-r0/recipe-sysroot
init-first.c -c -std=gnu11 -fgnu89-inline  -O2 -pipe -g
-feliminate-unused-debug-types
-fmacro-prefix-map=/home/vignesh.r/factory/yocto/bbb-bits-time/poky/build/tmp/work/armv7at2hf-neon-poky-linux-gnueabi/glibc/2.34-r0=/usr/src/debug/glibc/2.34-r0
-fdebug-prefix-map=/home/vignesh.r/factory/yocto/bbb-bits-time/poky/build/tmp/work/armv7at2hf-neon-poky-linux-gnueabi/glibc/2.34-r0=/usr/src/debug/glibc/2.34-r0
-fdebug-prefix-map=/home/vignesh.r/factory/yocto/bbb-bits-time/poky/build/tmp/work/armv7at2hf-neon-poky-linux-gnueabi/glibc/2.34-r0/recipe-sysroot=
-fdebug-prefix-map=/home/vignesh.r/factory/yocto/bbb-bits-time/poky/build/tmp/work/armv7at2hf-neon-poky-linux-gnueabi/glibc/2.34-r0/recipe-sysroot-native=
-D_TIME_BITS=64 -D_FILE_OFFSET_BITS=64 -Wall -Wwrite-strings -Wundef -Werror
-fmerge-all-constants -frounding-math -fno-stack-protector -fno-common
-Wstrict-prototypes -Wold-style-definition -fmath-errno   -fPIC    
-ftls-model=initial-exec      -I../include
-I/home/vignesh.r/factory/yocto/bbb-bits-time/poky/build/tmp/work/armv7at2hf-neon-poky-linux-gnueabi/glibc/2.34-r0/build-arm-poky-linux-gnueabi/csu

-I/home/vignesh.r/factory/yocto/bbb-bits-time/poky/build/tmp/work/armv7at2hf-neon-poky-linux-gnueabi/glibc/2.34-r0/build-arm-poky-linux-gnueabi
 -I../sysdeps/unix/sysv/linux/arm/le  -I../sysdeps/unix/sysv/linux/arm 
-I../sysdeps/arm/nptl  -I../sysdeps/unix/sysv/linux/include
-I../sysdeps/unix/sysv/linux  -I../sysdeps/nptl  -I../sysdeps/pthread 
-I../sysdeps/gnu  -I../sysdeps/unix/inet  -I../sysdeps/unix/sysv 
-I../sysdeps/unix/arm  -I../sysdeps/unix  -I../sysdeps/posix 
-I../sysdeps/arm/le/armv7/multiarch  -I../sysdeps/arm/armv7/multiarch 
-I../sysdeps/arm/le/armv7  -I../sysdeps/arm/armv7  -I../sysdeps/arm/armv6t2 
-I../sysdeps/arm/armv6  -I../sysdeps/arm/le  -I../sysdeps/arm/include
-I../sysdeps/arm  -I../sysdeps/wordsize-32  -I../sysdeps/ieee754/flt-32 
-I../sysdeps/ieee754/dbl-64  -I../sysdeps/ieee754  -I../sysdeps/generic  -I..
-I../libio -I. -nostdinc -isystem
/home/vignesh.r/factory/yocto/bbb-bits-time/poky/build/tmp/work/armv7at2hf-neon-poky-linux-gnueabi/glibc/2.34-r0/recipe-sysroot-native/usr/bin/arm-poky-linux-gnueabi/../../lib/arm-poky-linux-gnueabi/gcc/arm-poky-linux-gnueabi/11.2.0/include
-isystem
/home/vignesh.r/factory/yocto/bbb-bits-time/poky/build/tmp/work/armv7at2hf-neon-poky-linux-gnueabi/glibc/2.34-r0/recipe-sysroot-native/usr/bin/arm-poky-linux-gnueabi/../../lib/arm-poky-linux-gnueabi/gcc/arm-poky-linux-gnueabi/11.2.0/include-fixed
-isystem
/home/vignesh.r/factory/yocto/bbb-bits-time/poky/build/tmp/work/armv7at2hf-neon-poky-linux-gnueabi/glibc/2.34-r0/recipe-sysroot/usr/include
-D_LIBC_REENTRANT -include
/home/vignesh.r/factory/yocto/bbb-bits-time/poky/build/tmp/work/armv7at2hf-neon-poky-linux-gnueabi/glibc/2.34-r0/build-arm-poky-linux-gnueabi/libc-modules.h
-DMODULE_NAME=libc -include ../include/libc-symbols.h  -DPIC -DSHARED    
-DTOP_NAMESPACE=glibc -o
/home/vignesh.r/factory/yocto/bbb-bits-time/poky/build/tmp/work/armv7at2hf-neon-poky-linux-gnueabi/glibc/2.34-r0/build-arm-poky-linux-gnueabi/csu/init-first.os
-MD -MP -MF
/home/vignesh.r/factory/yocto/bbb-bits-time/poky/build/tmp/work/armv7at2hf-neon-poky-linux-gnueabi/glibc/2.34-r0/build-arm-poky-linux-gnueabi/csu/init-first.os.dt
-MT
/home/vignesh.r/factory/yocto/bbb-bits-time/poky/build/tmp/work/armv7at2hf-neon-poky-linux-gnueabi/glibc/2.34-r0/build-arm-poky-linux-gnueabi/csu/init-first.os
| In file included from ../sysdeps/generic/hp-timing.h:23,
|                  from ../nptl/descr.h:27,
|                  from ../sysdeps/arm/nptl/tls.h:42,
|                  from ../sysdeps/unix/sysv/linux/arm/tls.h:23,
|                  from ../sysdeps/unix/sysv/linux/arm/sysdep.h:30,
|                  from init-first.c:23:
| ../include/time.h:20:1: error: 'asm' declaration ignored due to conflict with
previous rename [-Werror=pragmas]
|    20 | libc_hidden_proto (mktime)
|       | ^~~~~~~~~~~~~~~~~
| ../include/time.h:21:1: error: 'asm' declaration ignored due to conflict with
previous rename [-Werror=pragmas]
|    21 | libc_hidden_proto (timelocal)
|       | ^~~~~~~~~~~~~~~~~
| ../include/time.h:22:1: error: 'asm' declaration ignored due to conflict with
previous rename [-Werror=pragmas]
|    22 | libc_hidden_proto (localtime)
|       | ^~~~~~~~~~~~~~~~~
| cc1: all warnings being treated as errors







Then I tried to build without Werror, and ended up with another error.

| arm-poky-linux-gnueabi-gcc  -march=armv7-a -mthumb -mfpu=neon
-mfloat-abi=hard 
--sysroot=/home/vignesh.r/factory/yocto/bbb-bits-time/poky/build/tmp/work/armv7at2hf-neon-poky-linux-gnueabi/glibc/2.34-r0/recipe-sysroot
iofgetpos.c -c -std=gnu11 -fgnu89-inline  -O2 -pipe -g
-feliminate-unused-debug-types
-fmacro-prefix-map=/home/vignesh.r/factory/yocto/bbb-bits-time/poky/build/tmp/work/armv7at2hf-neon-poky-linux-gnueabi/glibc/2.34-r0=/usr/src/debug/glibc/2.34-r0
-fdebug-prefix-map=/home/vignesh.r/factory/yocto/bbb-bits-time/poky/build/tmp/work/armv7at2hf-neon-poky-linux-gnueabi/glibc/2.34-r0=/usr/src/debug/glibc/2.34-r0
-fdebug-prefix-map=/home/vignesh.r/factory/yocto/bbb-bits-time/poky/build/tmp/work/armv7at2hf-neon-poky-linux-gnueabi/glibc/2.34-r0/recipe-sysroot=
-fdebug-prefix-map=/home/vignesh.r/factory/yocto/bbb-bits-time/poky/build/tmp/work/armv7at2hf-neon-poky-linux-gnueabi/glibc/2.34-r0/recipe-sysroot-native=
-D_TIME_BITS=64 -D_FILE_OFFSET_BITS=64 -Wall -Wwrite-strings -Wundef
-fmerge-all-constants -frounding-math -fno-stack-protector -fno-common
-Wstrict-prototypes -Wold-style-definition -fmath-errno    -fexceptions 
-ftls-model=initial-exec      -I../include
-I/home/vignesh.r/factory/yocto/bbb-bits-time/poky/build/tmp/work/armv7at2hf-neon-poky-linux-gnueabi/glibc/2.34-r0/build-arm-poky-linux-gnueabi/libio

-I/home/vignesh.r/factory/yocto/bbb-bits-time/poky/build/tmp/work/armv7at2hf-neon-poky-linux-gnueabi/glibc/2.34-r0/build-arm-poky-linux-gnueabi
 -I../sysdeps/unix/sysv/linux/arm/le  -I../sysdeps/unix/sysv/linux/arm 
-I../sysdeps/arm/nptl  -I../sysdeps/unix/sysv/linux/include
-I../sysdeps/unix/sysv/linux  -I../sysdeps/nptl  -I../sysdeps/pthread 
-I../sysdeps/gnu  -I../sysdeps/unix/inet  -I../sysdeps/unix/sysv 
-I../sysdeps/unix/arm  -I../sysdeps/unix  -I../sysdeps/posix 
-I../sysdeps/arm/le/armv7/multiarch  -I../sysdeps/arm/armv7/multiarch 
-I../sysdeps/arm/le/armv7  -I../sysdeps/arm/armv7  -I../sysdeps/arm/armv6t2 
-I../sysdeps/arm/armv6  -I../sysdeps/arm/le  -I../sysdeps/arm/include
-I../sysdeps/arm  -I../sysdeps/wordsize-32  -I../sysdeps/ieee754/flt-32 
-I../sysdeps/ieee754/dbl-64  -I../sysdeps/ieee754  -I../sysdeps/generic  -I..
-I../libio -I. -nostdinc -isystem
/home/vignesh.r/factory/yocto/bbb-bits-time/poky/build/tmp/work/armv7at2hf-neon-poky-linux-gnueabi/glibc/2.34-r0/recipe-sysroot-native/usr/bin/arm-poky-linux-gnueabi/../../lib/arm-poky-linux-gnueabi/gcc/arm-poky-linux-gnueabi/11.2.0/include
-isystem
/home/vignesh.r/factory/yocto/bbb-bits-time/poky/build/tmp/work/armv7at2hf-neon-poky-linux-gnueabi/glibc/2.34-r0/recipe-sysroot-native/usr/bin/arm-poky-linux-gnueabi/../../lib/arm-poky-linux-gnueabi/gcc/arm-poky-linux-gnueabi/11.2.0/include-fixed
-isystem
/home/vignesh.r/factory/yocto/bbb-bits-time/poky/build/tmp/work/armv7at2hf-neon-poky-linux-gnueabi/glibc/2.34-r0/recipe-sysroot/usr/include
-D_LIBC_REENTRANT -include
/home/vignesh.r/factory/yocto/bbb-bits-time/poky/build/tmp/work/armv7at2hf-neon-poky-linux-gnueabi/glibc/2.34-r0/build-arm-poky-linux-gnueabi/libc-modules.h
-DMODULE_NAME=libc -include ../include/libc-symbols.h  -DPIC    
-DTOP_NAMESPACE=glibc -D_IO_MTSAFE_IO -o
/home/vignesh.r/factory/yocto/bbb-bits-time/poky/build/tmp/work/armv7at2hf-neon-poky-linux-gnueabi/glibc/2.34-r0/build-arm-poky-linux-gnueabi/libio/iofgetpos.o
-MD -MP -MF
/home/vignesh.r/factory/yocto/bbb-bits-time/poky/build/tmp/work/armv7at2hf-neon-poky-linux-gnueabi/glibc/2.34-r0/build-arm-poky-linux-gnueabi/libio/iofgetpos.o.dt
-MT
/home/vignesh.r/factory/yocto/bbb-bits-time/poky/build/tmp/work/armv7at2hf-neon-poky-linux-gnueabi/glibc/2.34-r0/build-arm-poky-linux-gnueabi/libio/iofgetpos.o
| In file included from <command-line>:
| iofgetpos.c:84:40: error: conflicting types for 'fgetpos'; have 'int(FILE *,
__fpos_t *)' {aka 'int(struct _IO_FILE *, struct _G_fpos_t *)'}
|    84 | versioned_symbol (libc, __new_fgetpos, fgetpos, GLIBC_2_2);
|       |                                        ^~~~~~~
| ./../include/libc-symbols.h:155:26: note: in definition of macro
'_weak_alias'
|   155 |   extern __typeof (name) aliasname __attribute__ ((weak, alias
(#name))) \
|       |                          ^~~~~~~~~
| ../include/shlib-compat.h:117:3: note: in expansion of macro 'weak_alias'
|   117 |   weak_alias (local, symbol)
|       |   ^~~~~~~~~~
| iofgetpos.c:84:1: note: in expansion of macro 'versioned_symbol'
|    84 | versioned_symbol (libc, __new_fgetpos, fgetpos, GLIBC_2_2);
|       | ^~~~~~~~~~~~~~~~
| In file included from ../include/sys/cdefs.h:3,
|                  from ../include/features.h:488,
|                  from ../stdlib/errno.h:25,
|                  from ../include/errno.h:2,
|                  from libioP.h:40,
|                  from iofgetpos.c:34:
| ../libio/stdio.h:762:24: note: previous declaration of 'fgetpos' with type
'int(FILE * restrict,  fpos_t * restrict)' {aka 'int(struct _IO_FILE *
restrict,  struct _G_fpos64_t * restrict)'}
|   762 | extern int __REDIRECT (fgetpos, (FILE *__restrict __stream,
|       |                        ^~~~~~~
| ../misc/sys/cdefs.h:198:41: note: in definition of macro '__REDIRECT'
|   198 | # define __REDIRECT(name, proto, alias) name proto __asm__ (__ASMNAME
(#alias))
|       |                                         ^~~~


and also
| In file included from ../sysdeps/generic/hp-timing.h:23:0,
| from ../nptl/descr.h:27,
| from ../sysdeps/arm/nptl/tls.h:42,
| from ../sysdeps/unix/sysv/linux/arm/tls.h:23,
| from ../sysdeps/unix/sysv/linux/arm/sysdep.h:30,
| from ../sysdeps/unix/sysv/linux/libc_sigaction.c:22,
| from ../sysdeps/unix/sysv/linux/arm/libc_sigaction.c:39:
| ../include/time.h:20:1: warning: asm declaration ignored due to conflict with
previous rename [-Wpragmas]
| libc_hidden_proto (mktime)
| ^~~~~~~~~~~~~~~~~
| ../include/time.h:21:1: warning: asm declaration ignored due to conflict with
previous rename [-Wpragmas]
| libc_hidden_proto (timelocal)
| ^~~~~~~~~~~~~~~~~
| ../include/time.h:22:1: warning: asm declaration ignored due to conflict with
previous rename [-Wpragmas]
| libc_hidden_proto (localtime)
| ^~~~~~~~~~~~~~~~~
| {standard input}: Assembler messages:
| {standard input}:284: Error: symbol `__sigtimedwait64' is already defined
Any inputs on this, how to compile glibc with those tokens.
or there is no need of compiling glibc with the tokens. If so, why are those
example programs failing?
Please guide me how to proceed with this.

I am using yocto master branch for poky, meta-arm and meta-ti
BTW I am trying to build for beaglebone board.

some others also facing the same kind of
issuehttps://stackoverflow.com/questions/70292503/do-i-have-to-re-compile-glibc-2-34-itself-for-full-64-bit-time-t-support-for-32

Thanks
Vignesh R

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

^ permalink raw reply	[flat|nested] 3+ messages in thread

* [Bug libc/28880] Program crashes if date beyone 2038
  2022-02-11  4:17 [Bug libc/28880] New: Program crashes if date beyone 2038 drvignesh1992 at gmail dot com
@ 2022-02-11 11:55 ` adhemerval.zanella at linaro dot org
  2022-02-16 13:45 ` adhemerval.zanella at linaro dot org
  1 sibling, 0 replies; 3+ messages in thread
From: adhemerval.zanella at linaro dot org @ 2022-02-11 11:55 UTC (permalink / raw)
  To: glibc-bugs

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.

^ permalink raw reply	[flat|nested] 3+ messages in thread

* [Bug libc/28880] Program crashes if date beyone 2038
  2022-02-11  4:17 [Bug libc/28880] New: Program crashes if date beyone 2038 drvignesh1992 at gmail dot com
  2022-02-11 11:55 ` [Bug libc/28880] " adhemerval.zanella at linaro dot org
@ 2022-02-16 13:45 ` adhemerval.zanella at linaro dot org
  1 sibling, 0 replies; 3+ messages in thread
From: adhemerval.zanella at linaro dot org @ 2022-02-16 13:45 UTC (permalink / raw)
  To: glibc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|ASSIGNED                    |RESOLVED
         Resolution|---                         |FIXED

--- Comment #2 from Adhemerval Zanella <adhemerval.zanella at linaro dot org> ---
Fixed on 2.36.

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

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2022-02-16 13:45 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-02-11  4:17 [Bug libc/28880] New: Program crashes if date beyone 2038 drvignesh1992 at gmail dot com
2022-02-11 11:55 ` [Bug libc/28880] " adhemerval.zanella at linaro dot org
2022-02-16 13:45 ` adhemerval.zanella at linaro dot org

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