summaryrefslogtreecommitdiff
path: root/nuttx/sched
diff options
context:
space:
mode:
authorpatacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3>2013-02-02 23:56:54 +0000
committerpatacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3>2013-02-02 23:56:54 +0000
commitbed10d9288e1c61599580049d63fe74873c08b37 (patch)
treec2045a94c067d8c6d0bf486449349494b9f1c1ff /nuttx/sched
parent2cc0db0c264e064ee203c2f19b91f7ba013fdf25 (diff)
downloadpx4-nuttx-bed10d9288e1c61599580049d63fe74873c08b37.tar.gz
px4-nuttx-bed10d9288e1c61599580049d63fe74873c08b37.tar.bz2
px4-nuttx-bed10d9288e1c61599580049d63fe74873c08b37.zip
Correct a memory leak in NSH
git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@5600 42af7a65-404d-4744-a932-0658087f49c3
Diffstat (limited to 'nuttx/sched')
-rw-r--r--nuttx/sched/sched_getfiles.c16
-rw-r--r--nuttx/sched/task_posixspawn.c12
-rw-r--r--nuttx/sched/task_spawn.c27
3 files changed, 45 insertions, 10 deletions
diff --git a/nuttx/sched/sched_getfiles.c b/nuttx/sched/sched_getfiles.c
index 17ca2bbf6..95f5c44ec 100644
--- a/nuttx/sched/sched_getfiles.c
+++ b/nuttx/sched/sched_getfiles.c
@@ -72,8 +72,20 @@ FAR struct filelist *sched_getfiles(void)
FAR _TCB *rtcb = (FAR _TCB*)g_readytorun.head;
FAR struct task_group_s *group = rtcb->group;
- DEBUGASSERT(group);
- return &group->tg_filelist;
+ /* The group may be NULL under certain conditions. For example, if
+ * debug output is attempted from the IDLE thead before the group has
+ * been allocated. I have only seen this case when memory management
+ * debug is enabled.
+ */
+
+ if (group)
+ {
+ return &group->tg_filelist;
+ }
+
+ /* Higher level logic must handle the NULL gracefully */
+
+ return NULL;
}
#endif /* CONFIG_NFILE_DESCRIPTORS */
diff --git a/nuttx/sched/task_posixspawn.c b/nuttx/sched/task_posixspawn.c
index f26391500..1b3afdaf3 100644
--- a/nuttx/sched/task_posixspawn.c
+++ b/nuttx/sched/task_posixspawn.c
@@ -166,6 +166,16 @@ errout:
* Description:
* Perform file_actions, then execute the task from the file system.
*
+ * Do we really need this proxy task? Isn't that wasteful?
+ *
+ * Q: Why not use a starthook so that there is callout from task_start()
+ * to perform these operations after the file is loaded from
+ * the file system?
+ * A: That existing task_starthook() implementation cannot be used in
+ * this context; any of task_starthook() will also conflict with
+ * binfmt's use of the start hook to call C++ static initializers.
+ * task_restart() would also be an issue.
+ *
* Input Parameters:
* Standard task start-up parameters
*
@@ -399,7 +409,7 @@ int posix_spawn(FAR pid_t *pid, FAR const char *path,
return errcode;
}
- /* Disable pre-emption so that the proxy does not run until we waitpid
+ /* Disable pre-emption so that the proxy does not run until waitpid
* is called. This is probably unnecessary since the posix_spawn_proxy has
* the same priority as this thread; it should be schedule behind this
* task in the ready-to-run list.
diff --git a/nuttx/sched/task_spawn.c b/nuttx/sched/task_spawn.c
index 04a3944bf..61a835c91 100644
--- a/nuttx/sched/task_spawn.c
+++ b/nuttx/sched/task_spawn.c
@@ -110,8 +110,6 @@ static int task_spawn_exec(FAR pid_t *pidp, FAR const char *name,
int pid;
int ret = OK;
- DEBUGASSERT(path);
-
/* Disable pre-emption so that we can modify the task parameters after
* we start the new task; the new task will not actually begin execution
* until we re-enable pre-emption.
@@ -159,6 +157,23 @@ errout:
* Description:
* Perform file_actions, then execute the task from the file system.
*
+ * Do we really need a proxy task in this case? Isn't that wasteful?
+ *
+ * Q: Why can we do what we need to do here and the just call the
+ * new task's entry point.
+ * A: This would require setting up the name, priority, and stacksize from
+ * the task_spawn, but it do-able. The only issue I can think of is
+ * that NuttX supports task_restart(), and you would never be able to
+ * restart a task from this point.
+ *
+ * Q: Why not use a starthook so that there is callout from task_start()
+ * to perform these operations?
+ * A: Good idea, except that existing task_starthook() implementation
+ * cannot be used here unless we get rid of task_create and, instead,
+ * use task_init() and task_activate(). start_taskhook() could then
+ * be called between task_init() and task)activate(). task_restart()
+ * would still be an issue.
+ *
* Input Parameters:
* Standard task start-up parameters
*
@@ -303,10 +318,8 @@ int task_spawn(FAR pid_t *pid, FAR const char *name, main_t entry,
#endif
int ret;
- DEBUGASSERT(path);
-
- svdbg("pid=%p path=%s file_actions=%p attr=%p argv=%p\n",
- pid, path, file_actions, attr, argv);
+ svdbg("pid=%p name=%s entry=%p file_actions=%p attr=%p argv=%p\n",
+ pid, name, entry, file_actions, attr, argv);
/* If there are no file actions to be performed and there is no change to
* the signal mask, then start the new child task directly from the parent task.
@@ -359,7 +372,7 @@ int task_spawn(FAR pid_t *pid, FAR const char *name, main_t entry,
return errcode;
}
- /* Disable pre-emption so that the proxy does not run until we waitpid
+ /* Disable pre-emption so that the proxy does not run until waitpid
* is called. This is probably unnecessary since the task_spawn_proxy has
* the same priority as this thread; it should be schedule behind this
* task in the ready-to-run list.