yamt commented on a change in pull request #5252:
URL: https://github.com/apache/incubator-nuttx/pull/5252#discussion_r792211285



##########
File path: net/tcp/tcp_send_buffered.c
##########
@@ -355,10 +355,39 @@ static uint16_t psock_send_eventhandler(FAR struct 
net_driver_s *dev,
                                         FAR void *pvconn, FAR void *pvpriv,
                                         uint16_t flags)
 {
-  FAR struct tcp_conn_s *conn = (FAR struct tcp_conn_s *)pvconn;
+  /* FAR struct tcp_conn_s *conn = (FAR struct tcp_conn_s *)pvconn;
+   *
+   * Do not use pvconn argument to get the TCP connection pointer (the above
+   * commented line) because pvconn is normally NULL for some events like
+   * NETDEV_DOWN. Instead, the TCP connection pointer can be reliably
+   * obtained from the corresponding TCP socket.
+   */
+
   FAR struct socket *psock = (FAR struct socket *)pvpriv;
+  FAR struct tcp_conn_s *conn;
   bool rexmit = false;
 
+  DEBUGASSERT(psock != NULL);
+
+  /* Get the TCP connection pointer reliably from
+   * the corresponding TCP socket.
+   */
+
+  conn = psock->s_conn;
+  DEBUGASSERT(conn != NULL);
+
+  /* The TCP socket is connected and, hence, should be bound to a device.
+   * Make sure that the polling device is the one that we are bound to.
+   */
+
+  DEBUGASSERT(conn->dev != NULL);

Review comment:
       not that urgent for us.
   
   * it was sim on ubuntu.
   * it was with commit 71d3ff104553aebf4cb938ee8abc6fd7d34fd239
   * it was running an app which does tcp active open. (it's a MQTT client, if 
it matters.)
   * it seems that it doesn't always crash. i dunno a way to reproduce it 
reliably.
   * it crashed after the app decided to reconnect to the server.
   * before the reconnection, probably on the previous tcp connection, mbedtls 
complained something unusual. it might be another issue in the recent tcp 
changes. `mbedtls/library/ssl_msg.c:3566: |1| unknown record type 128`
   * i can't share you the whole config as it is. TCP related options are as 
the following. if you want to know other specific configuration, please ask.
   
   ```
   spacetanuki% grep TCP test-config
   # CONFIG_NET_TCPPROTO_OPTIONS is not set
   # TCP/IP Networking
   CONFIG_NET_TCP=y
   # CONFIG_NET_TCP_NO_STACK is not set
   # CONFIG_NET_TCP_DELAYED_ACK is not set
   # CONFIG_NET_TCP_KEEPALIVE is not set
   # CONFIG_NET_TCPURGDATA is not set
   CONFIG_NET_TCP_CONNS=8
   CONFIG_NET_TCP_NPOLLWAITERS=1
   CONFIG_NET_TCP_RTO=3
   CONFIG_NET_TCP_WAIT_TIMEOUT=120
   CONFIG_NET_TCP_FAST_RETRANSMIT_WATERMARK=3
   # CONFIG_NET_TCP_WINDOW_SCALE is not set
   CONFIG_NET_TCP_NOTIFIER=y
   CONFIG_NET_TCP_WRITE_BUFFERS=y
   CONFIG_NET_TCP_NWRBCHAINS=8
   # CONFIG_NET_TCP_WRBUFFER_DEBUG is not set
   # CONFIG_NET_TCPBACKLOG is not set
   # CONFIG_EXAMPLES_TCPBLASTER is not set
   # CONFIG_EXAMPLES_TCPECHO is not set
   spacetanuki% 
   ```




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to