Boost logo

Boost Users :

Subject: Re: [Boost-users] compilation flag effect onboost::condition::timed_wait()
From: Vishal Bayskar (vishal.bayskar_at_[hidden])
Date: 2011-02-04 04:45:46


Hi,

>which boost version are you referring to?
I am using boost 1.41.0

>Also, if you can compile yout code with -g -O0 -DNDEBUG, is the behaviour
>reproducible?
Yes it is always reproducible

>If so, can you step the timed_wait() function in debugger,
>do you see anything strange?

OK I will check it, but I didn't use debugger before well I try it.

Actually I doubt the way I am using exitTime variable. exitTime valiable is defined like below in a class ASemaphore, but it is not initialized with xtime_get() function. I doubt due to this, undefined behaviour(timed_wait is not waiting) is occurring.

class ASemaphore
{
   
protected:

    boost::xtime exitTime;

}

int ASemaphore::waitForAction()
{

        boost::xtime curTime;
        boost::xtime_get(&curTime, boost::TIME_UTC);
        this->exitTime.sec = curTime.sec + argTotalWaitInterval;

        boost::mutex::scoped_lock lock(this->mutex);
        ret = this->condition.timed_wait(lock, this->exitTime);
}

when I use it like below (without using temporary variable curTime and initialize exitTime with xtime_get) timed_wait do what is expected in both the case i.e. with NDEBUG and without NDEBUG

{
        boost::xtime_get(&this->exitTime, boost::TIME_UTC);
        this->exitTime.sec += argTotalWaitInterval;

        boost::mutex::scoped_lock lock(this->mutex);
        ret = this->condition.timed_wait(lock, this->exitTime);
}

Please let me know if you can possibly guess what could be wrong.

>Happy hunting ;)
Yes I like hunting ;)

Thanking you.
Vishal

-----Original Message-----
From: boost-users-bounces_at_[hidden] on behalf of Viatcheslav.Sysoltsev_at_[hidden]
Sent: Thu 2/3/2011 9:05 PM
To: boost-users_at_[hidden]
Subject: Re: [Boost-users] compilation flag effect onboost::condition::timed_wait()
 
> Dear All,
>
> I am getting different behaviour of condition::timed_wait() function
> when I compile my code with NDEBUG flag and without NDEBUG flag.
>
> with using NDEBUG flag, timed_wait() wait for condition (mutext) as
> desired but whey I don't use NDEBUG flag while compiling my code it does
> wait for condition (mutex) but return at the same time when it is
> called. In both the cases return value is 1.
>
> Please note that it is not a race condition but it is happening every
> time.
>
> Also note that I am using other flags too for compiling my code like
>
> -Werror -pthread -fno-strict-aliasing -Wno-unused-variable
> -Wno-unused-parameter -Wno-unused-function -O3 -ggdb3 -m64
>
>
> Please let me know what can be possible impact of NDEBUG flag on
> timed_wait() function.
>
>
> Thanking you
> Vishal

Hi Vishal,

which boost version are you referring to? The 1.45 is a little different
 from previous releases in condition_variable_any.
Also, if you can compile yout code with -g -O0 -DNDEBUG, is the behaviour
reproducible? If so, can you step the timed_wait() function in debugger,
do you see anything strange?

Consider as well, most sort of assert macroses are defined into nothing in
release build, so make sure you don't do anything usefull in assert
expression.

Happy hunting ;)
-- Slava

_______________________________________________
Boost-users mailing list
Boost-users_at_[hidden]
http://lists.boost.org/mailman/listinfo.cgi/boost-users

DISCLAIMER:
-----------------------------------------------------------------------------------------------------------------------
The contents of this e-mail and any attachment(s) are confidential and
intended
for the named recipient(s) only.
It shall not attach any liability on the originator or NECHCL or its
affiliates. Any views or opinions presented in
this email are solely those of the author and may not necessarily reflect the
opinions of NECHCL or its affiliates.
Any form of reproduction, dissemination, copying, disclosure, modification,
distribution and / or publication of
this message without the prior written consent of the author of this e-mail is
strictly prohibited. If you have
received this email in error please delete it and notify the sender
immediately. .
-----------------------------------------------------------------------------------------------------------------------



Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net