This is the mail archive of the glibc-bugs@sourceware.org mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug libc/12401] New: [PATCH] fix assertion in mktime.c


http://sourceware.org/bugzilla/show_bug.cgi?id=12401

           Summary: [PATCH] fix assertion in mktime.c
           Product: glibc
           Version: unspecified
            Status: NEW
          Severity: normal
          Priority: P2
         Component: libc
        AssignedTo: drepper.fsp@gmail.com
        ReportedBy: rmh@gnu.org


Created attachment 5195
  --> http://sourceware.org/bugzilla/attachment.cgi?id=5195
patch 1

The following assertion in mktime.c:

   verify (long_int_year_and_yday_are_wide_enough,
          INT_MAX <= LONG_MAX / 2 || TIME_T_MAX <= UINT_MAX);

is not satisfiable on any ILP32 architecture with 64-bit time_t.

I propose the following patch to fix the problem.  Given the purpose of this
assertion, I've split my patch in 3 to prove that it doesn't introduce any
regression.  Here's my semi-formal proof:

First let A be (INT_MAX <= LONG_MAX / 2).

  - Patch #1: This works on the assumption that for any value of LONG_MAX, the
whole function either works correctly or fails to compile. With my patch, if a
certain condition A is met, every instance of `long' type is replaced with
`time_t', and the assertion that checks for LONG_MAX now checks for TIME_T_MAX
in its place. It must remain true that for any value of TIME_T_MAX, the whole
function either works correctly or fails to compile, regardless of condition A.

  - Patch #2: If condition A is met, clearly the assertion will always suceed,
so it can be removed.

  - Patch #3: If condition A is met, the second assertion is skipped, which is
equivalent to making A one of its options.

(or in plain English, if longs are too short, time_ts can be used instead)

-- 
Configure bugmail: http://sourceware.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]