[bug #56487] [v2.1.2] crash when TCP continuous write encounter wifi disconnect

classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

[bug #56487] [v2.1.2] crash when TCP continuous write encounter wifi disconnect

David GIRAULT-2
URL:
  <https://savannah.nongnu.org/bugs/?56487>

                 Summary: [v2.1.2] crash when TCP continuous write  encounter
wifi disconnect
                 Project: lwIP - A Lightweight TCP/IP stack
            Submitted by: pusong666
            Submitted on: Thu 13 Jun 2019 08:19:56 AM UTC
                Category: sockets/netconn
                Severity: 3 - Normal
              Item Group: Crash Error
                  Status: None
                 Privacy: Public
             Assigned to: None
             Open/Closed: Open
         Discussion Lock: Any
         Planned Release: None
            lwIP version: 2.1.1

    _______________________________________________________

Details:

reproduce ratio:
seldom

lwip option:
enable socket etc.
enable LWIP_TCPIP_CORE_LOCKING

reproduce step:
1. TCP Socket write large data continuously
2. disconnect wifi, then our code will handle "wifi_disconnect" event to
netif_set_addr(sta_if, IP4_ADDR_ANY, IP4_ADDR_ANY, IP4_ADDR_ANY)

result:
crash due to conn->pcb or conn->current_msg == NULL in
lwip_netconn_do_writemore






    _______________________________________________________

Reply to this item at:

  <https://savannah.nongnu.org/bugs/?56487>

_______________________________________________
  Message sent via Savannah
  https://savannah.nongnu.org/


_______________________________________________
lwip-devel mailing list
[hidden email]
https://lists.nongnu.org/mailman/listinfo/lwip-devel
Reply | Threaded
Open this post in threaded view
|

[bug #56487] [v2.1.2] crash when TCP continuous write encounter wifi disconnect

David GIRAULT-2
Follow-up Comment #1, bug #56487 (project lwip):

Further explanation:

1. TCP Socket write large data in TaskA
2. disconnect wifi -> "wifi_disconnect" callback then netif_set_addr(sta_if,
IP4_ADDR_ANY, IP4_ADDR_ANY, IP4_ADDR_ANY) in TaskB(wifi task is higher
priority.)
3. TaskA may be switch to TaskB when TaskA is running
lwip_netconn_do_writemore  "conn->current_msg->msg.w.offset += len" or
"sys_sem_t *op_completed_sem = LWIP_API_MSG_SEM(conn->current_msg)".
But TaskB
netif_set_addr->netif_do_ip_addr_changed->tcp_netif_ip_addr_changed_pcblist->tcp_abort->err_tcp->conn->current_msg=NULL.

    _______________________________________________________

Reply to this item at:

  <https://savannah.nongnu.org/bugs/?56487>

_______________________________________________
  Message sent via Savannah
  https://savannah.nongnu.org/


_______________________________________________
lwip-devel mailing list
[hidden email]
https://lists.nongnu.org/mailman/listinfo/lwip-devel
Reply | Threaded
Open this post in threaded view
|

[bug #56487] [v2.1.2] crash when TCP continuous write encounter wifi disconnect

David GIRAULT-2
Follow-up Comment #2, bug #56487 (project lwip):

`netif_set_addr()` calls LWIP_ASSERT_CORE_LOCKED(). So this function MUST be
called from the Lwip task, not your wifi task.

Use `netifapi_netif_set_addr` is you require changing the ipaddr from another
task.

    _______________________________________________________

Reply to this item at:

  <https://savannah.nongnu.org/bugs/?56487>

_______________________________________________
  Message posté via Savannah
  https://savannah.nongnu.org/


_______________________________________________
lwip-devel mailing list
[hidden email]
https://lists.nongnu.org/mailman/listinfo/lwip-devel
Reply | Threaded
Open this post in threaded view
|

Re: [bug #56487] [v2.1.2] crash when TCP continuous write encounter wifi disconnect

308257860
Got it. thanks!



发自我的小米手机
在 David GIRAULT <[hidden email]>,2019年6月21日 21:57写道:

Follow-up Comment #2, bug #56487 (project lwip):

`netif_set_addr()` calls LWIP_ASSERT_CORE_LOCKED(). So this function MUST be
called from the Lwip task, not your wifi task.

Use `netifapi_netif_set_addr` is you require changing the ipaddr from another
task.

    _______________________________________________________

Reply to this item at:

  <https://savannah.nongnu.org/bugs/?56487>

_______________________________________________
  Message posté via Savannah
  https://savannah.nongnu.org/



_______________________________________________
lwip-devel mailing list
[hidden email]
https://lists.nongnu.org/mailman/listinfo/lwip-devel
Reply | Threaded
Open this post in threaded view
|

[bug #56487] [v2.1.2] crash when TCP continuous write encounter wifi disconnect

David GIRAULT-2
In reply to this post by David GIRAULT-2
Update of bug #56487 (project lwip):

                  Status:                    None => Invalid                
             Open/Closed:                    Open => Closed                

    _______________________________________________________

Follow-up Comment #3:

As David already said it, you're doing things wrong. Closing as invalid.

    _______________________________________________________

Reply to this item at:

  <https://savannah.nongnu.org/bugs/?56487>

_______________________________________________
  Message sent via Savannah
  https://savannah.nongnu.org/


_______________________________________________
lwip-devel mailing list
[hidden email]
https://lists.nongnu.org/mailman/listinfo/lwip-devel