Skip to content

[BZ-2434] ACE_Time_Value operations near limit/saturation fail on 64-bit #2434

Open

Description

@jwillemsen
Field Value
Bugzilla ID 2434
Reporter @shuston
Assigned to DOC Center Support List (internal)
Product ACE
Component ACE Core
Version 5.6.2
Platform / OS All / All
Priority P3
Severity normal
Status REOPENED
Resolution
Created 2006-03-03 16:11:31 -0600
Depends on #2563

Originally posted by @shuston on 2006-03-03 16:11:31 -0600


ACE_Time_Value test fails on 64-bit systems (other than Windows, which was
explicitly worked around for other reasons). The operations that manipulate
values, such as operator*, will fail for values near or at the range of a 64-bit
integer.
The root cause is that the operations are done using "double" floating point
operations and a 'double' on most of these systems is 64 bits and, thus, has a
value range less than that of a 64-bit integer.

This report is to capture thinking on this subject so it can be fixed.

Some notes extracted from email regarding this subject:


From J.T. Conklin:

I think the way to do this is to do this in multiprecision integer
arithmetic. The simplest way to do this would be to add/import an
arbitrary precision integer library, but that would probably bloat
the footprint to an undesirable degree. The alternative is to do
it in line, shouldn't take more than a evening with Seminumerical
Algorithms to work it out.


From Steve Huston:

FYI, there's a GNU MP library that can do what we need, I believe. It's LGPL
though (of course).

AIX and Solaris have a mp(3) library that can do mp integer math, but I haven't
found any floating point that works with it.


Rich Seibel also had input that ACE_Time_Value should be split into a relative
and an absolute time class; Carlos O'Ryan suggested looking at how boost does
this for ideas.

Activity

  1. jwillemsen commented on Mar 28, 2026

    @jwillemsen
    MemberAuthor

    Originally posted by @jwillemsen on 2006-06-21 14:33:58 -0500 (Bugzilla comment 1)


    added depends

  2. jwillemsen commented on Mar 28, 2026

    @jwillemsen
    MemberAuthor

    Originally posted by @jwillemsen on 2006-08-09 09:14:37 -0500 (Bugzilla comment 2)


    accept for tao-support

  3. jwillemsen commented on Mar 28, 2026

    @jwillemsen
    MemberAuthor

    Originally posted by @jwillemsen on 2007-01-08 14:20:37 -0600 (Bugzilla comment 3)


    *** Bug #2563 has been marked as a duplicate of this bug. ***

  4. jwillemsen commented on Mar 28, 2026

    @jwillemsen
    MemberAuthor

    Originally posted by @jwillemsen on 2007-03-07 15:32:18 -0600 (Bugzilla comment 4)


    Ossama committed a few fixes yesterday and today, we should watch the test stats
    and see if things are improved

  5. jwillemsen commented on Mar 28, 2026

    @jwillemsen
    MemberAuthor

    Originally posted by @jwillemsen on 2008-02-18 09:04:06 -0600 (Bugzilla comment 5)


    not resolved

    Thu Mar 9 09:44:14 UTC 2007 Ossama Othman <ossama_othman at symantec dot com>

        * ace/Time_Value.cpp (operator *=):
    
          Reverted bulk of the changes.  New implementation will be
          revisited as time permits.
    

    Thu Mar 9 07:44:14 UTC 2007 Ossama Othman ossama_othman@symantec.com

        * tests/Time_Value_Test.cpp (run_main):
    
          Simplified assertions.  Rather than test equality of sec() and
          usec() components separately, just test equality of the
          ACE_Time_Value objects as a whole.
    

    Thu Mar 8 18:06:14 UTC 2007 Ossama Othman <ossama_othman at symantec dot com>

        * ace/Time_Value.cpp (operator *=):
    
          Removed vestigial time value saturation code that does not work
          correctly with latest implementation.
    

    Wed Mar 7 17:32:51 UTC 2007 Ossama Othman <ossama_othman at symantec dot com>

        * ace/Time_Value.cpp (operator*=):
    
          Altered implementation to avoid converting the microseconds
          component of the ACE_Time_Value to a fraction of a second.  In
          the case were the floating point type's mantissa width is the
          same as the width of the time_t (seconds) value, a maxed out
          ACE_Time_Value seconds component would utilize all bits in the
          mantissa, leaving no room for a fraction.  The microseconds
          component would end up not contributing to the multiplication.
          Multiply the seconds and microseconds components separately
          instead.  This also saves us a floating point division, which
          can be expensive.
    

    Tue Mar 6 23:06:15 UTC 2007 Ossama Othman <ossama_othman at symantec dot com>

        * ace/Time_Value.cpp (operator*=):
    
          Use long double for internal computations if double is not large
          enough to retain precision of the time_t/suseconds_t values.
          This will only provide improved behavior with compilers that
          support double-extended precision floating numbers, i.e. >= 79
          bits.
    
          Added comments to explain what is being done in the
          implementation.
    
  6. jwillemsen commented on Mar 28, 2026

    @jwillemsen
    MemberAuthor

    Originally posted by @jwillemsen on 2010-01-21 02:20:05 -0600 (Bugzilla comment 6)


    Thu Jan 21 08:13:30 UTC 2010 Johnny Willemsen jwillemsen@remedy.nl

        * tests/Time_Value_Test.cpp:
        * tests/tests.mpc:
        * tests/run_test.lst:
        * tests/Bug_2434_Regression_Test.cpp:
          Moved the 64bit overflow test which fails on 64bit systems to
          its own file and marked that as not fixed
    
  7. jwillemsen commented on Mar 28, 2026

    @jwillemsen
    MemberAuthor

    Originally posted by Olivier Langlois on 2010-01-27 10:42:18 -0600 (Bugzilla comment 7)


    Created attachment 1245
    svn diff from the trunk to fix the bug.

    Field Value
    Attachment ID 1245
    Filename bug2434_bug3818.patch
    Description svn diff from the trunk to fix the bug.
    Uploaded by Olivier Langlois
    Date 2010-01-27 10:42:18 -0600
    Size 13350 bytes
    Patch yes
    Obsolete no
    Download Download from repository
  8. jwillemsen commented on Mar 28, 2026

    @jwillemsen
    MemberAuthor

    Originally posted by Douglas C. Schmidt on 2010-02-21 15:35:35 -0600 (Bugzilla comment 8)


    Fixed, thanks!

  9. jwillemsen commented on Mar 28, 2026

    @jwillemsen
    MemberAuthor

    Originally posted by @shuston on 2010-02-23 16:03:03 -0600 (Bugzilla comment 9)


    Still broken; Bug_2434_Regression_Test and Time_Value_Test are still failing.

  10. jwillemsen commented on Mar 28, 2026

    @jwillemsen
    MemberAuthor

    Originally posted by @jwillemsen on 2010-02-25 04:32:28 -0600 (Bugzilla comment 10)


    seems to work on a lot of 64bit systems, but 64bit windows is failing

  11. jwillemsen commented on Oct 1, 2026

    @jwillemsen
    MemberAuthor
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions