Modify

Opened 5 years ago

Closed 5 years ago

#6361 closed Bugs (fixed)

integer overflow in boost::chrono::process_real_cpu_clock::now() under Windows 32bits

Reported by: ivan.lelann@… Owned by: viboes
Milestone: Boost 1.50.0 Component: chrono
Version: Boost 1.48.0 Severity: Problem
Keywords: Cc:

Description

As of 1.48 Boost.Chrono contains code below for boost::chrono::process_real_cpu_clock::now() (boost\chrono\detail\inlined\win\process_cpu_clocks.hpp)

clock_t c = ::clock(); /* ... */ return time_point(

duration(c*(1000000000l/CLOCKS_PER_SEC))

);

duration::rep is int64/nanoseconds, clock_t is long. This is under VS2008, Win XP 32bits. I think "c" should be cast to duration::rep before being multiplied.

C-style cast fixed the problem for me. Howard Hinnant suggested following cleaner fix on the mailing list :

typedef ratio_divide<giga, ratio<CLOCKS_PER_SEC>>::type R; return time_point(

duration(static_cast<rep>(c)*R::num/R::den)

);

NB: This appears at least twice in this file. It also appears in "mac" and "posix" folders though I cannot say if it is problematic on this platforms.

Attachments (1)

6361.patch (977 bytes) - added by viboes 5 years ago.

Download all attachments as: .zip

Change History (4)

comment:1 Changed 5 years ago by viboes

  • Milestone changed from To Be Determined to Boost 1.50.0
  • Status changed from new to assigned

Sorry, I forget this issue. I will take care of it as soon as I have access to a windows machine.

Changed 5 years ago by viboes

comment:2 Changed 5 years ago by viboes

Committed in trunk At revision: [77545]

Last edited 5 years ago by viboes (previous) (diff)

comment:3 Changed 5 years ago by viboes

  • Resolution set to fixed
  • Status changed from assigned to closed

(In [77694]) Chrono Fix #6361,#6628,#6666

Add Comment

Modify Ticket

Change Properties
Set your email in Preferences
Action
as closed The owner will remain viboes.
The resolution will be deleted. Next status will be 'reopened'.
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.