lwip-devel
[Top][All Lists]
Advanced

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

[lwip-devel] [bug #51287] lwip_netconn_do_gethostbyname - signal mutex b


From: Boberek
Subject: [lwip-devel] [bug #51287] lwip_netconn_do_gethostbyname - signal mutex before end.
Date: Wed, 21 Jun 2017 13:07:27 -0400 (EDT)
User-agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:54.0) Gecko/20100101 Firefox/54.0

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

                 Summary: lwip_netconn_do_gethostbyname - signal mutex before
end.
                 Project: lwIP - A Lightweight TCP/IP stack
            Submitted by: bober
            Submitted on: Wed 21 Jun 2017 05:07:26 PM UTC
                Category: DNS
                Severity: 3 - Normal
              Item Group: None
                  Status: None
                 Privacy: Public
             Assigned to: None
             Open/Closed: Open
         Discussion Lock: Any
         Planned Release: None
            lwIP version: 2.0.2

    _______________________________________________________

Details:

In function lwip_netconn_do_gethostbyname we have:

API_EXPR_DEREF(msg->err) = dns_gethostbyname_addrtype(msg->name,
    API_EXPR_REF(msg->addr), lwip_netconn_do_dns_found, msg, 

exist path in call dns_gethostbyname_addrtype with call
lwip_netconn_do_dns_found()[when dhcp is just start working].


Scenario:
1. call netconn_gethostbyname(),send messege (tcpcallback) to tcp_thread and
wait on semaphore for result. 
2. tcp_thread call lwip_netconn_do_gethostbyname
3. lwip_netconn_do_gethostbyname call dns_gethostbyname_addrtype
4. somewhere in dns_gethostbyname_addrtype call lwip_netconn_do_dns_found.
5. lwip_netconn_do_dns_found signal semaphore.
6. In another thread netconn_gethostbyname() can continue (semaphore is
signaled), function netconn_gethostbyname()is finished (address msg and err is
not valid, is somewere in the stack).
7. Assign msg->err in statement: 
API_EXPR_DEREF(msg->err) = dns_gethostbyname_addrtype(msg->name,
    API_EXPR_REF(msg->addr), lwip_netconn_do_dns_found, msg, 
write somewere in memory on the stack.
8. My program crash (tcp_thread write on stack another thread).

Fast my bugfix in netconn_gethostbyname() is add:
  {
    int err1 = tcpip_callback(lwip_netconn_do_nothing, &API_VAR_REF(msg));
    if (err1 == SOK) {
      sys_sem_wait(API_EXPR_REF_SEM(API_VAR_REF(msg).sem));
    }
  }
after:
sys_sem_wait(API_EXPR_REF_SEM(API_VAR_REF(msg).sem));

or wait some ms after:
sys_sem_wait(API_EXPR_REF_SEM(API_VAR_REF(msg).sem));






    _______________________________________________________

Reply to this item at:

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

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




reply via email to

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