Results 1 to 4 of 4

Thread: patch #3 for Ice 3.2: Fix for condition variable implementation under Windows.

  1. #1
    matthew's Avatar
    matthew is offline ZeroC Staff
    Name: Matthew Newhook
    Organization: ZeroC, Inc.
    Project: Internet Communications Engine
    Join Date
    Feb 2003
    Location
    NL, Canada
    Posts
    1,458

    patch #3 for Ice 3.2: Fix for condition variable implementation under Windows.

    This patch fixes a bug with IceUtil::Cond under Windows which could cause a deadlock if signal was used in conjunction multiple waiting threads where at least one thread is using timedWait. Note that this bug also affects IceUtil::Monitor since this uses IceUtil::Cond.

    This bug was originally reported in this thread: monitor util thread block at windows system

    The patch is fully binary compatible with Ice 3.2. Note that this is a Windows problem only, Unix platforms are not affected. To apply the patch to a fresh Ice 3.2 source distribution:

    Code:
      C:\> cd Ice-3.2.0
      C:\Ice-3.2.0> patch -p0 < patch.txt
    Attached Files Attached Files

  2. #2
    Matt Nassr is offline Registered User
    Name: Matthew Nassr
    Organization: Argon ST
    Project: Audio Middleware
    Join Date
    Aug 2008
    Posts
    2
    I'm curious about what this patch fixes because I am getting the same problem with the patched version (it looks like the patch is merged into all versions of Ice after 3.2.0) of Cond.cpp.

    To be specific, I have multiple waiting threads (one of them on a timedWait), and the deadlock occurs in the postWait method on the _queue.wait() semaphore call. This comment, which is part of the patch, is above the wait statement:

    // Consume the queue post to prevent spurious wakeup. Note
    // that although the internal mutex could be released
    // prior to this wait() call, doing so gains nothing since
    // this wait() MUST return immediately (if it does not
    // there is a major bug and the entire application will
    // deadlock).
    //

    _queue.wait();

    It appears that this wait() is not returning immediately and there is a 'major bug' since the 'entire application deadlocks'. I am trying to trace when this _queue semaphore is supposed to be posted to figure out why this is not happening and the consumption comes up empty.

    I would like to know why this patch is only applicable to Windows, since that would shed light on what is actually going on here. I have made a workaround in my code by spacing the waiting threads out with small sleep statements, but this is obviously non-ideal. I imagine a code example would help, but this is inside a very large application. I could go about creating one, but I would like to know a little bit more about this patch first.

    Thanks!
    Last edited by Matt Nassr; 08-08-2008 at 12:53 PM.

  3. #3
    bernard's Avatar
    bernard is offline ZeroC Staff
    Name: Bernard Normier
    Organization: ZeroC, Inc.
    Project: Ice
    Join Date
    Feb 2003
    Location
    Palm Beach Gardens, FL
    Posts
    1,294
    Hi Matt,

    This was a patch for our implementation of condition variables on Windows. Other platforms (Linux, Mac OS X, Solaris...) have native condition variables, so there is no need to implement condition variables there.

    When you wait on a condition variable, blocking is expected. We use this condition variable implementation frequently, and while a bug is always possible, it sounds unlikely.

    If you can get the stack of all active threads when this deadlock occurs, it could help pinpoint the exact issue.

    Best regards,
    Bernard
    Bernard Normier
    ZeroC, Inc.

  4. #4
    Matt Nassr is offline Registered User
    Name: Matthew Nassr
    Organization: Argon ST
    Project: Audio Middleware
    Join Date
    Aug 2008
    Posts
    2
    Bernard, thank you for your quick response. As it turned out, the hang in Ice was due to memory corruption elsewhere in the program, there is nothing I can find wrong with the CV implementation.

    Thanks,
    Matt

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Patch #2 for Ice 3.3.0: fix for slice2cs
    By dwayne in forum Patches
    Replies: 0
    Last Post: 08-07-2008, 09:23 AM
  2. Patch #4 for Ice 3.2.1: fix for slice2cs
    By michi in forum Patches
    Replies: 0
    Last Post: 10-11-2007, 01:38 AM
  3. Patch #3 for Ice 3.2.1: fix for slice2cs
    By michi in forum Patches
    Replies: 0
    Last Post: 09-24-2007, 03:40 AM
  4. Replies: 0
    Last Post: 05-16-2007, 12:21 PM
  5. Replies: 1
    Last Post: 08-01-2006, 06:26 AM

Posting Permissions

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