Results 1 to 4 of 4

Thread: Unhandled CL_Exception from CL_Event::wait bug description and patch

  1. #1

    Default [Resolved] Unhandled CL_Exception from CL_Event::wait bug description and patch

    So I've been playing around with Clanlib for a few weeks now. I generally develop on a rather speedy computer, so I am guessing that is why this bug didn't crop up until I ran it on another computer. Note that the bug is *nix specific.

    The bug is that, when using the Sound subsystem (which spawns its own thread(s) it seems), under random circumstances a call to CL_Event::wait will fail. This would cause an unhandled exception termination from my program, as C++ doesn't do cross-thread exceptions. I traced the throwing of the exception to Core/System/event.cpp which uses a "slow" unix function. If the thread receives a signal while the syscall is running, it will return -1 like it is an error. The appropriate way to handle this is to check errno == EINTR and if that is true, then run the syscall again. That is what this patch adds. I have done basic tests but would appreciate a broader test range.

    Also in the patch is a minor addition to the exception thrower to give a more meaningful error message.

    Helpful links:
    The code for the project that was experiencing this bug (run it on unpatched Clanlib to reproduce).
    Output of my program after getting the bug.
    My patch proposal.
    Info about EINTR

    Edit: Patch had a tiny (single character) bug in it (grabbed patch from wrong tree). Re-uped fixed patch.
    Last edited by nitori; 09-22-2011 at 02:10 PM. Reason: Resolved

  2. #2
    ClanLib Developer
    Join Date
    May 2007
    Posts
    1,824

    Default

    The patch looks good.

    I'll apply it later this week.

    Many thanks

  3. #3
    ClanLib Developer
    Join Date
    May 2007
    Posts
    1,824

    Default

    Patch applied (to 2.2, 2.3 and 2.4 svn)

    Many thanks

  4. #4
    ClanLib Developer
    Join Date
    May 2007
    Posts
    1,824

    Default

    For reference.

    ClanLib 2.2, 2.3 and 2.4 patched with this fix:

    "Fixed regression in CL_Event from r5858 making infinite CL_Event::wait calls time out after 24 days"

Similar Threads

  1. Global CL_Exception catch optimizations and more (ClanLib 2.2)
    By user in forum Official ClanLib SDK Forums
    Replies: 4
    Last Post: 07-22-2011, 08:01 AM
  2. Wait for a window's response.
    By Pierroz in forum Official ClanLib SDK Forums
    Replies: 2
    Last Post: 03-13-2010, 10:09 AM
  3. CL_Exception::what() returns invalid pointer if UNICODE is #defined
    By Deewiant in forum Official ClanLib SDK Forums
    Replies: 2
    Last Post: 10-20-2009, 10:08 AM
  4. Locating master server, please wait...
    By mrbiginthepants in forum Funeral Quest
    Replies: 2
    Last Post: 04-26-2003, 03:47 AM
  5. Can't wait for Teenage Lawn Mower!
    By jason in forum RTsoft Tavern
    Replies: 2
    Last Post: 07-22-2002, 04:21 AM

Bookmarks

Bookmarks

Posting Permissions

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