lwip-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[lwip-devel] [bug #20842] unix sys_arch_protect faulty


From: Thomas Taranowski
Subject: [lwip-devel] [bug #20842] unix sys_arch_protect faulty
Date: Tue, 21 Aug 2007 00:26:36 +0000
User-agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.6) Gecko/20070725 Firefox/2.0.0.6

URL:
  <http://savannah.nongnu.org/bugs/?20842>

                 Summary: unix sys_arch_protect faulty
                 Project: lwIP - A Lightweight TCP/IP stack
            Submitted by: taranowski
            Submitted on: Tuesday 08/21/2007 at 00:26
                Category: Contrib
                Severity: 3 - Normal
              Item Group: Faulty Behaviour
                  Status: None
                 Privacy: Public
             Assigned to: None
             Open/Closed: Open
         Discussion Lock: Any
         Planned Release: 

    _______________________________________________________

Details:

The unix version of sys_arch_protect appears faulty.

Assume the following scenario:
I have two critical sections in different parts of the code, cA and cB, and
two threads, tA and tB.  Thread tA wants to protect cA, etc.

Thread tA calls SYS_ARCH_PROTECT to protect a critical section.  The
lwprot_thread!=current thread, so tA locks the mutex, and bumps the count to
1.

Next, thread tB also calls SYS_ARCH_PROTECT to protect cB.  Since the single
global lwprot_thread!=current thread, it will overwrite the lwprot_thread id
with it's won, and reset the lwprot_count to 1.



Code excerpt below - comments stripped out for readability:

sys_prot_t sys_arch_protect(void)
{
    if (lwprot_thread != pthread_self())
    {
        pthread_mutex_lock(&lwprot_mutex);
        lwprot_thread = pthread_self();
        lwprot_count = 1;
    }
    else
        lwprot_count++;
    return 0;
}




    _______________________________________________________

Reply to this item at:

  <http://savannah.nongnu.org/bugs/?20842>

_______________________________________________
  Message sent via/by Savannah
  http://savannah.nongnu.org/





reply via email to

[Prev in Thread] Current Thread [Next in Thread]