Results 1 to 3 of 3

Thread: [C++] crash using IceUtil::Timer

  1. #1
    MKroehnert is offline Registered User
    Name: Manfred Kroehnert
    Organization: Karlsruhe Institute of Technology
    Project: Robotic Application Framework
    Join Date
    Sep 2011
    Posts
    3

    [C++] crash using IceUtil::Timer

    Hi,

    we are exploring the possibility to use Ice in our next software project.

    However, we ran across several application crashes which we could boil down to a single line using IceUtil::Timer and it looks like this:

    Code:
    #include <IceUtil/Timer.h>
    
    int main() {
        IceUtil::Timer timer;
        return 0;
    }
    When compiled on OS X 10.6.8 against Ice-3.4.2 (precompiled version) this program crashes with a segmentation fault.

    The corresponding gdb backtrace looks like this:

    Code:
    #0  0x00007fff5fbff740 in ?? ()
    #1  0x000000010078271e in startHook (arg=0x7fff5fbff6b0) at Thread.cpp:407
    #2  0x00007fff802d7fd6 in _pthread_start ()
    #3  0x00007fff802d7e89 in thread_start ()

    We tried to run it on Linux but got a slightly different error (using Ice-3.4.1):

    Code:
    test: /Ice/include/IceUtil/Mutex.h:256: IceUtil::Mutex::~Mutex(): Assertion `rc == 0' failed.
    Aborted.
    I will check against Ice-3.4.2 tomorrow (I know about the support policy).

    Any help or insight on this would be appreciated.

    Best regards,

    Manfred

  2. #2
    mes's Avatar
    mes
    mes is online now ZeroC Staff
    Name: Mark Spruiell
    Organization: ZeroC, Inc.
    Project: Ice Developer
    Join Date
    Feb 2003
    Location
    California
    Posts
    1,445
    Hi Manfred,

    Welcome to the forum.

    The IceUtil::Timer class is a reference-counted class, which is implied by its inheritance from IceUtil::Shared. As you have seen, bad things will happen if you attempt to allocate an instance of such a class on the stack.

    Here is how you should be allocating an instance:

    Code:
    IceUtil::TimerPtr timer = new IceUtil::Timer;
    The TimerPtr type is a smart pointer for instances of Timer.

    Best regards,
    Mark
    Last edited by mes; 09-07-2011 at 12:59 PM.

  3. #3
    MKroehnert is offline Registered User
    Name: Manfred Kroehnert
    Organization: Karlsruhe Institute of Technology
    Project: Robotic Application Framework
    Join Date
    Sep 2011
    Posts
    3
    Hello Mark,

    thanks for your fast response.

    Now that you mention the reference counting the solution seems obvious.
    Somehow we must have overlooked this problem.

    Best regards,

    Manfred

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Timer and Mutex/Monitor Question
    By billg in forum Help Center
    Replies: 1
    Last Post: 07-21-2011, 10:22 AM
  2. Exceptions can escape from IceUtil::Timer::run
    By andy_84 in forum Bug Reports
    Replies: 1
    Last Post: 11-18-2010, 03:33 AM
  3. Monotonic Timer in ICE for .NET
    By kwaclaw in forum Comments
    Replies: 2
    Last Post: 04-03-2008, 10:26 PM
  4. Crash in IceUtil::Time caused by VC6 bug
    By kssreeram in forum Help Center
    Replies: 3
    Last Post: 04-22-2004, 07:07 AM
  5. IceStorm/ Timer Service ideas
    By stephan in forum Help Center
    Replies: 5
    Last Post: 10-27-2003, 05:53 AM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •