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



##########
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:
       > > it rarely happens in our CI. actually i have noticed it only once.
   > 
   > Do you have CONFIG_DEBUG_INFO=y in your CI config? Beside the debug assert 
I am going to add logging some variables that may help.
   
   the current setting is like the following.
   i can change them unless too verbose.
   i guess you want to use ninfo right?
   ```
   spacetanuki% grep CONFIG_DEBUG test-config
   CONFIG_DEBUG_ALERT=y
   CONFIG_DEBUG_FEATURES=y
   CONFIG_DEBUG_ERROR=y
   CONFIG_DEBUG_WARN=y
   CONFIG_DEBUG_INFO=y
   CONFIG_DEBUG_ASSERTIONS=y
   CONFIG_DEBUG_BINFMT=y
   CONFIG_DEBUG_BINFMT_ERROR=y
   CONFIG_DEBUG_BINFMT_WARN=y
   # CONFIG_DEBUG_BINFMT_INFO is not set
   # CONFIG_DEBUG_FS is not set
   # CONFIG_DEBUG_GRAPHICS is not set
   # CONFIG_DEBUG_LIB is not set
   # CONFIG_DEBUG_MM is not set
   # CONFIG_DEBUG_NET is not set
   # CONFIG_DEBUG_POWER is not set
   # CONFIG_DEBUG_BATTERY is not set
   # CONFIG_DEBUG_SCHED is not set
   # CONFIG_DEBUG_IRQ is not set
   # CONFIG_DEBUG_GPIO is not set
   # CONFIG_DEBUG_RTC is not set
   # CONFIG_DEBUG_TIMER is not set
   # CONFIG_DEBUG_TCBINFO is not set
   CONFIG_DEBUG_SYMBOLS=y
   CONFIG_DEBUG_NOOPT=y
   # CONFIG_DEBUG_FULLOPT 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