Opened 10 years ago

Closed 9 years ago

Last modified 5 years ago

#8006 closed Support Requests (fixed)

Boost::Chrono Assertion at startup — at Version 8

Reported by: meckschlager@… Owned by: viboes
Milestone: Component: chrono
Version: Boost 1.50.0 Severity: Problem
Keywords: Cc:

Description (last modified by viboes)

steady_clock::time_point now = steady_clock::now(); sometimes causes

Assertion failed: 0 && "Boost::Chrono - Internal Error", file C:\Projects\Librari
es\src\boost\boost_1_48_0\boost/chrono/detail/inlined/win/chrono.hpp, line 44
on Windows XP, boost 1.48

Change History (8)

comment:1 by meckschlager@…, 10 years ago

Now I see, boost::chrono is all thread unsafe and I was reading the time from 2 threads simultaneously (I guess that's so not uncommon) Is that really good? Locking the time reading method seems a bit weird to me...

in reply to:  1 comment:2 by viboes, 10 years ago

Replying to meckschlager@…:

Now I see, boost::chrono is all thread unsafe and I was reading the time from 2 threads simultaneously (I guess that's so not uncommon)

Why do you think that the code is thread unsafe?

Is that really good? Locking the time reading method seems a bit weird to me...

What is weird for you?

in reply to:  description comment:3 by viboes, 10 years ago

Replying to meckschlager@…:

steady_clock::time_point now = steady_clock::now(); sometimes causes Assertion failed: 0 && "Boost::Chrono - Internal Error", file C:\Projects\Librari es\src\boost\boost_1_48_0\boost/chrono/detail/inlined/win/chrono.hpp, line 44 on Windows XP, boost 1.48

The code in question is

    if ( (nanosecs_per_tic <= 0.0L) ||
            (!boost::detail::win32::QueryPerformanceCounter( &pcount )) )
    {
      BOOST_ASSERT(0 && "Boost::Chrono - Internal Error");
      return steady_clock::time_point();
    }

could you check which condition is true?

comment:4 by meckschlager@…, 10 years ago

Hi, thanks embracing that issue up!

Why do you think that the code is thread unsafe?

It states so in the chrono users guide "All functions in the library are thread-unsafe except when noted explicitly." (http://www.boost.org/doc/libs/1_52_0/doc/html/chrono/users_guide.html) thats why I came to the working solution

lock steady_clock::time_point now = steady_clock::now(); unlock

Now, it just seems unnecessary that multiple threads might have to wait to get the current time, which many os methods would return without requiring a lock.

cheers m.

in reply to:  4 comment:5 by viboes, 10 years ago

Replying to meckschlager@…:

Hi, thanks embracing that issue up!

Why do you think that the code is thread unsafe?

It states so in the chrono users guide "All functions in the library are thread-unsafe except when noted explicitly." (http://www.boost.org/doc/libs/1_52_0/doc/html/chrono/users_guide.html) thats why I came to the working solution

lock steady_clock::time_point now = steady_clock::now(); unlock

Now, it just seems unnecessary that multiple threads might have to wait to get the current time, which many os methods would return without requiring a lock.

Hrr! I would fix this on the documentation, call to Clock::now() should be thread safe.

Thanks for the report.

comment:6 by viboes, 10 years ago

Status: newassigned

I have fixed the documentation in revision [83511]. have you analyzed which condition was failing?

in reply to:  6 comment:7 by viboes, 10 years ago

Replying to viboes:

I have fixed the documentation in revision [83511]. have you analyzed which condition was failing?

Could you tell me which is the result of

boost::detail::win32::QueryPerformanceCounter( &pcount ) 

when the program asserts?

comment:8 by viboes, 9 years ago

Description: modified (diff)
Resolution: worksforme
Status: assignedclosed

I can not reproduce this error. Without your help I'm unable to help you? Reopen it if you have some insight.

Note: See TracTickets for help on using tickets.