You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nuttx.apache.org by GitBox <gi...@apache.org> on 2021/01/24 23:57:04 UTC

[GitHub] [incubator-nuttx] masayuki2009 opened a new pull request #2737: sched: task: Fix a potential bug in nxtask_assign_pid()

masayuki2009 opened a new pull request #2737:
URL: https://github.com/apache/incubator-nuttx/pull/2737


   ## Summary
   
   - During reviewing sched_lock() in nxtask_assign_pid(),
     I noticed that g_pidhash is not protected by a critical section
   - Because g_pidhash is accessed in an interrupt context,
     it should be protected by a critical section.
   - Actually, nxsched_foreach(), nxsched_get_tcb() and so on
     use a critical section.
   
   ## Impact
   
   - No impact
   
   ## Testing
   
   - Tested with spresense:wifi (non-SMP) and spresense:wifi_smp
   


----------------------------------------------------------------
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.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [incubator-nuttx] xiaoxiang781216 merged pull request #2737: sched: task: Fix a potential bug in nxtask_assign_pid()

Posted by GitBox <gi...@apache.org>.
xiaoxiang781216 merged pull request #2737:
URL: https://github.com/apache/incubator-nuttx/pull/2737


   


----------------------------------------------------------------
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.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [incubator-nuttx] xiaoxiang781216 commented on a change in pull request #2737: sched: task: Fix a potential bug in nxtask_assign_pid()

Posted by GitBox <gi...@apache.org>.
xiaoxiang781216 commented on a change in pull request #2737:
URL: https://github.com/apache/incubator-nuttx/pull/2737#discussion_r563455905



##########
File path: sched/task/task_setup.c
##########
@@ -121,17 +122,18 @@ static int nxtask_assign_pid(FAR struct tcb_s *tcb)
 #endif
           tcb->pid = next_pid;
 
-          sched_unlock();
-          return OK;
+          ret = OK;
+          goto errout;
         }
     }
 
+errout:
   /* If we get here, then the g_pidhash[] table is completely full.

Review comment:
       Sorry, I don't catch your comment. @masayuki2009 could you create a PR to fix the comment.




----------------------------------------------------------------
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.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [incubator-nuttx] masayuki2009 commented on a change in pull request #2737: sched: task: Fix a potential bug in nxtask_assign_pid()

Posted by GitBox <gi...@apache.org>.
masayuki2009 commented on a change in pull request #2737:
URL: https://github.com/apache/incubator-nuttx/pull/2737#discussion_r563462684



##########
File path: sched/task/task_setup.c
##########
@@ -121,17 +122,18 @@ static int nxtask_assign_pid(FAR struct tcb_s *tcb)
 #endif
           tcb->pid = next_pid;
 
-          sched_unlock();
-          return OK;
+          ret = OK;
+          goto errout;
         }
     }
 
+errout:
   /* If we get here, then the g_pidhash[] table is completely full.

Review comment:
       @btashton 
   > This comment is not correct any more since this is now the return path. Also maybe the label name should change.
   
   Thanks for the comment
   
   @xiaoxiang781216 
   >Sorry, I don't catch your comment. @masayuki2009 could you create a PR to fix the comment.
   
   Yes, I will create a new PR.
   




----------------------------------------------------------------
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.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [incubator-nuttx] btashton commented on a change in pull request #2737: sched: task: Fix a potential bug in nxtask_assign_pid()

Posted by GitBox <gi...@apache.org>.
btashton commented on a change in pull request #2737:
URL: https://github.com/apache/incubator-nuttx/pull/2737#discussion_r563440031



##########
File path: sched/task/task_setup.c
##########
@@ -121,17 +122,18 @@ static int nxtask_assign_pid(FAR struct tcb_s *tcb)
 #endif
           tcb->pid = next_pid;
 
-          sched_unlock();
-          return OK;
+          ret = OK;
+          goto errout;
         }
     }
 
+errout:
   /* If we get here, then the g_pidhash[] table is completely full.

Review comment:
       This comment is not correct any more since this is now _the_ return path.  Also maybe the label name should change.




----------------------------------------------------------------
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.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [incubator-nuttx] xiaoxiang781216 commented on a change in pull request #2737: sched: task: Fix a potential bug in nxtask_assign_pid()

Posted by GitBox <gi...@apache.org>.
xiaoxiang781216 commented on a change in pull request #2737:
URL: https://github.com/apache/incubator-nuttx/pull/2737#discussion_r563455905



##########
File path: sched/task/task_setup.c
##########
@@ -121,17 +122,18 @@ static int nxtask_assign_pid(FAR struct tcb_s *tcb)
 #endif
           tcb->pid = next_pid;
 
-          sched_unlock();
-          return OK;
+          ret = OK;
+          goto errout;
         }
     }
 
+errout:
   /* If we get here, then the g_pidhash[] table is completely full.

Review comment:
       Sorry, I don't catch your comment. @masayuki2009 could you create a PR to fix the comment.




----------------------------------------------------------------
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.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [incubator-nuttx] btashton commented on pull request #2737: sched: task: Fix a potential bug in nxtask_assign_pid()

Posted by GitBox <gi...@apache.org>.
btashton commented on pull request #2737:
URL: https://github.com/apache/incubator-nuttx/pull/2737#issuecomment-766526873


   @xiaoxiang781216  and @masayuki2009  this merged but can you see my comment about the comment needing to be updated. 


----------------------------------------------------------------
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.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [incubator-nuttx] btashton commented on pull request #2737: sched: task: Fix a potential bug in nxtask_assign_pid()

Posted by GitBox <gi...@apache.org>.
btashton commented on pull request #2737:
URL: https://github.com/apache/incubator-nuttx/pull/2737#issuecomment-766526873


   @xiaoxiang781216  and @masayuki2009  this merged but can you see my comment about the comment needing to be updated. 


----------------------------------------------------------------
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.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [incubator-nuttx] xiaoxiang781216 merged pull request #2737: sched: task: Fix a potential bug in nxtask_assign_pid()

Posted by GitBox <gi...@apache.org>.
xiaoxiang781216 merged pull request #2737:
URL: https://github.com/apache/incubator-nuttx/pull/2737


   


----------------------------------------------------------------
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.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [incubator-nuttx] btashton commented on a change in pull request #2737: sched: task: Fix a potential bug in nxtask_assign_pid()

Posted by GitBox <gi...@apache.org>.
btashton commented on a change in pull request #2737:
URL: https://github.com/apache/incubator-nuttx/pull/2737#discussion_r563440031



##########
File path: sched/task/task_setup.c
##########
@@ -121,17 +122,18 @@ static int nxtask_assign_pid(FAR struct tcb_s *tcb)
 #endif
           tcb->pid = next_pid;
 
-          sched_unlock();
-          return OK;
+          ret = OK;
+          goto errout;
         }
     }
 
+errout:
   /* If we get here, then the g_pidhash[] table is completely full.

Review comment:
       This comment is not correct any more since this is now _the_ return path.  Also maybe the label name should change.




----------------------------------------------------------------
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.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [incubator-nuttx] masayuki2009 commented on a change in pull request #2737: sched: task: Fix a potential bug in nxtask_assign_pid()

Posted by GitBox <gi...@apache.org>.
masayuki2009 commented on a change in pull request #2737:
URL: https://github.com/apache/incubator-nuttx/pull/2737#discussion_r563462684



##########
File path: sched/task/task_setup.c
##########
@@ -121,17 +122,18 @@ static int nxtask_assign_pid(FAR struct tcb_s *tcb)
 #endif
           tcb->pid = next_pid;
 
-          sched_unlock();
-          return OK;
+          ret = OK;
+          goto errout;
         }
     }
 
+errout:
   /* If we get here, then the g_pidhash[] table is completely full.

Review comment:
       @btashton 
   > This comment is not correct any more since this is now the return path. Also maybe the label name should change.
   
   Thanks for the comment
   
   @xiaoxiang781216 
   >Sorry, I don't catch your comment. @masayuki2009 could you create a PR to fix the comment.
   
   Yes, I will create a new PR.
   




----------------------------------------------------------------
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.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org