Correct a memory leak in NSH

git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@5600 42af7a65-404d-4744-a932-0658087f49c3
This commit is contained in:
patacongo 2013-02-02 23:56:54 +00:00
parent 329328e5df
commit 30a0cdf33e
48 changed files with 119 additions and 72 deletions

View File

@ -490,7 +490,7 @@ Amber Web Server Configuration Options
Configurations
^^^^^^^^^^^^^^
Each Amber Web Server configuration is maintained in a sudirectory and can
Each Amber Web Server configuration is maintained in a sub-directory and can
be selected as follow:
cd tools

View File

@ -431,7 +431,7 @@ AVR32DEV1 Configuration Options
Configurations
^^^^^^^^^^^^^^
Each Atmel AVR32DEV configuration is maintained in a sudirectory and
Each Atmel AVR32DEV configuration is maintained in a sub-directory and
can be selected as follow:
cd tools

View File

@ -726,7 +726,7 @@ Cloudctrl-specific Configuration Options
Configurations
==============
Each Cloudctrl configuration is maintained in a sudirectory and
Each Cloudctrl configuration is maintained in a sub-directory and
can be selected as follow:
cd tools

View File

@ -358,7 +358,7 @@ HCS12/DEMO9S12NEC64-specific Configuration Options
Configurations
^^^^^^^^^^^^^^
Each Freescale HCS12 configuration is maintained in a sudirectory and
Each Freescale HCS12 configuration is maintained in a sub-directory and
can be selected as follow:
cd tools

View File

@ -605,7 +605,7 @@ ARM/EA3131-specific Configuration Options
Configurations
^^^^^^^^^^^^^^
Each EA3131 configuration is maintained in a sudirectory and can be
Each EA3131 configuration is maintained in a sub-directory and can be
selected as follow:
cd tools

View File

@ -411,7 +411,7 @@ ARM/EA3152-specific Configuration Options
Configurations
^^^^^^^^^^^^^^
Each EA3152 configuration is maintained in a sudirectory and can be
Each EA3152 configuration is maintained in a sub-directory and can be
selected as follow:
cd tools

View File

@ -383,7 +383,7 @@ Eagle100-specific Configuration Options
Configurations
^^^^^^^^^^^^^^
Each Eagle-100 configuration is maintained in a sudirectory and
Each Eagle-100 configuration is maintained in a sub-directory and
can be selected as follow:
cd tools

View File

@ -402,7 +402,7 @@ Configurations
^^^^^^^^^^^^^^
Each Stellaris EKK-LM3S9b96 Evaluation Kit configuration is maintained in a
sudirectory and can be selected as follow:
sub-directory and can be selected as follow:
cd tools
./configure.sh ekk-lm3s9b96/<subdir>

View File

@ -810,7 +810,7 @@ M3 Wildfire-specific Configuration Options
Configurations
==============
Each M3 Wildfire configuration is maintained in a sudirectory and
Each M3 Wildfire configuration is maintained in a sub-directory and
can be selected as follow:
cd tools

View File

@ -560,7 +560,7 @@ HY-Mini specific Configuration Options
Configurations
==============
Each HY-MiniSTM32V configuration is maintained in a sudirectory and
Each HY-MiniSTM32V configuration is maintained in a sub-directory and
can be selected as follow:
cd tools

View File

@ -511,7 +511,7 @@ KwikStik-K40-specific Configuration Options
Configurations
==============
Each KwikStik-K40 configuration is maintained in a sudirectory and
Each KwikStik-K40 configuration is maintained in a sub-directory and
can be selected as follow:
cd tools

View File

@ -473,7 +473,7 @@ the mountpoint /mnt/flash.
Configurations
^^^^^^^^^^^^^^
Each Lincoln 60 configuration is maintained in a sudirectory and can be selected
Each Lincoln 60 configuration is maintained in a sub-directory and can be selected
as follow:
cd tools

View File

@ -405,7 +405,7 @@ Configurations
^^^^^^^^^^^^^^
Each Stellaris MDL-S2E Reference Design configuration is maintained in a
sudirectory and can be selected as follow:
sub-directory and can be selected as follow:
cd tools
./configure.sh lm3s6432-s2e/<subdir>

View File

@ -545,7 +545,7 @@ Configurations
^^^^^^^^^^^^^^
Each Stellaris LM3S6965 Evaluation Kit configuration is maintained in a
sudirectory and can be selected as follow:
sub-directory and can be selected as follow:
cd tools
./configure.sh lm3s6965-ek/<subdir>

View File

@ -449,7 +449,7 @@ Configurations
^^^^^^^^^^^^^^
Each Stellaris LM3S8962 Evaluation Kit configuration is maintained in a
sudirectory and can be selected as follow:
sub-directory and can be selected as follow:
cd tools
./configure.sh lm3s8962-ek/<subdir>

View File

@ -893,7 +893,7 @@ LPC4330-Xplorer Configuration Options
Configurations
==============
Each LPC4330-Xplorer configuration is maintained in a sudirectory and can be selected
Each LPC4330-Xplorer configuration is maintained in a sub-directory and can be selected
as follow:
cd tools

View File

@ -734,7 +734,7 @@ LPCXpresso Configuration Options
Configurations
^^^^^^^^^^^^^^
Each LPCXpresso configuration is maintained in a sudirectory and can be
Each LPCXpresso configuration is maintained in a sub-directory and can be
selected as follow:
cd tools

View File

@ -444,7 +444,7 @@ the mountpoint /mnt/flash.
Configurations
^^^^^^^^^^^^^^
Each mbed configuration is maintained in a sudirectory and can be selected
Each mbed configuration is maintained in a sub-directory and can be selected
as follow:
cd tools

View File

@ -320,7 +320,7 @@ ARM/LPC214X-specific Configuration Options
Configurations
^^^^^^^^^^^^^^
Each NXP LPC214x configuration is maintained in a sudirectory and
Each NXP LPC214x configuration is maintained in a sub-directory and
can be selected as follow:
cd tools

View File

@ -510,7 +510,7 @@ Micropendous3 Configuration Options
Configurations
^^^^^^^^^^^^^^
Each Micropendous3 configuration is maintained in a sudirectory and can
Each Micropendous3 configuration is maintained in a sub-directory and can
be selected as follow:
cd tools

View File

@ -849,7 +849,7 @@ PIC32MX Configuration Options
Configurations
==============
Each PIC32MX configuration is maintained in a sudirectory and can be
Each PIC32MX configuration is maintained in a sub-directory and can be
selected as follow:
cd tools

View File

@ -121,7 +121,7 @@ ARM/i.MX1-specific Configuration Options
Configurations
^^^^^^^^^^^^^^
Each MX1ADS configuration is maintained in a sudirectory and
Each MX1ADS configuration is maintained in a sub-directory and
can be selected as follow:
cd tools

View File

@ -465,7 +465,7 @@ HCS12/NE64BADGE-specific Configuration Options
Configurations
^^^^^^^^^^^^^^
Each Freescale HCS12 configuration is maintained in a sudirectory and
Each Freescale HCS12 configuration is maintained in a sub-directory and
can be selected as follow:
cd tools

View File

@ -282,7 +282,7 @@ ARM/DM320-specific Configuration Options
Configurations
^^^^^^^^^^^^^^
Each Neuros OSD configuration is maintained in a sudirectory and
Each Neuros OSD configuration is maintained in a sub-directory and
can be selected as follow:
cd tools

View File

@ -521,7 +521,7 @@ Configurations
^^^^^^^^^^^^^^
Each Nucleus 2G configuration is maintained in a
sudirectory and can be selected as follow:
sub-directory and can be selected as follow:
cd tools
./configure.sh nucleus2g/<subdir>

View File

@ -849,7 +849,7 @@ Configurations
^^^^^^^^^^^^^^
Each Olimex LPC1766-STK configuration is maintained in a
sudirectory and can be selected as follow:
sub-directory and can be selected as follow:
cd tools
./configure.sh olimex-lpc1766stk/<subdir>

View File

@ -159,7 +159,7 @@ MAX3232 Connection
RX -- Pin 52: U1RX/RF2
GND -- POWER POINT: GND
Vcc -- POWER POINT: Vdd (3.3V) -- Or P32_VBUS (+5V)
-- Or +5V from a USB PC port.
Or +5V from a USB PC port.
Toolchains
==========
@ -524,7 +524,7 @@ PIC32MX Configuration Options
Configurations
==============
Each PIC32MX configuration is maintained in a sudirectory and can be
Each PIC32MX configuration is maintained in a sub-directory and can be
selected as follow:
cd tools

View File

@ -40,25 +40,25 @@
/* LCD pin mapping (see configs/pcblogic-pic32mx/README.txt)
*
* ----------------------------------- ---------- ----------------------------------
* PIC32 LCD1602 UBW32 PIN
* PIC32 LCD1602 PCBLogic PIN
* PIN SIGNAL NAME PIN NAME(s)
* ----------------------------------- ---------- ----------------------------------
* 1. Vss GND
* 2. Vdd Vcc (5V)
* 3. Vee To ground via 10K potentiometer
* 4 AN15/OCFB/PMALL/PMA0/CN12/RB15 4. RS PMA0, Selects registers
* 82 PMRD/CN14/RD5 5. RW PMRD/PMWR, Selects read or write
* 81 OC5/PMWR/CN13/RD4 6. E PMENB, Starts data read/write
* 93 PMD0/RE0 7. D0 PMD0
* 94 PMD1/RE1 8. D1 PMD1
* 98 PMD2/RE2 9. D2 PMD2
* 99 PMD3/RE3 10. D3 PMD3
* 100 PMD4/RE4 11. D4 PMD4
* 3 PMD5/RE5 12. D5 PMD5
* 4 PMD6/RE6 13. D6 PMD6
* 5 PMD7/RE7 14. D7 PMD7
* 15. A To Vcc (5V) via 10K potentiometer
* 16. K GND
* 1. Vss --> Powerpoint GND
* 2. Vdd --> Powerpoint USB+5V
* 3. Vee N/C To ground via 10K potentiometer
* 4 AN15/OCFB/PMALL/PMA0/CN12/RB15 4. RS 4 PMA0, Selects registers
* 82 PMRD/CN14/RD5 5. RW 82 PMRD/PMWR, Selects read or write
* 81 OC5/PMWR/CN13/RD4 6. E 81 PMENB, Starts data read/write
* 93 PMD0/RE0 7. D0 93 PMD0
* 94 PMD1/RE1 8. D1 94 PMD1
* 98 PMD2/RE2 9. D2 98 PMD2
* 99 PMD3/RE3 10. D3 99 PMD3
* 100 PMD4/RE4 11. D4 100 PMD4
* 3 PMD5/RE5 12. D5 3 PMD5
* 4 PMD6/RE6 13. D6 4 PMD6
* 5 PMD7/RE7 14. D7 5 PMD7
* 15. A N/C To Vcc (5V) via 10K potentiometer
* 16. K --> Powerpoint GND
* ----------------------------------- ---------- ----------------------------------
*/

View File

@ -1021,7 +1021,7 @@ PIC32MX specific PHY/Ethernet device driver settings
Configurations
==============
Each PIC32MX configuration is maintained in a sudirectory and can be
Each PIC32MX configuration is maintained in a sub-directory and can be
selected as follow:
cd tools

View File

@ -599,7 +599,7 @@ PIC32MX specific PHY/Ethernet device driver settings
Configurations
==============
Each PIC32MX configuration is maintained in a sudirectory and can be
Each PIC32MX configuration is maintained in a sub-directory and can be
selected as follow:
cd tools

View File

@ -355,7 +355,7 @@ SAM3U-EK-specific Configuration Options
Configurations
^^^^^^^^^^^^^^
Each SAM3U-EK configuration is maintained in a sudirectory and
Each SAM3U-EK configuration is maintained in a sub-directory and
can be selected as follow:
cd tools

View File

@ -743,7 +743,7 @@ Shenzhou-specific Configuration Options
Configurations
==============
Each Shenzhou configuration is maintained in a sudirectory and
Each Shenzhou configuration is maintained in a sub-directory and
can be selected as follow:
cd tools

View File

@ -680,7 +680,7 @@ STM3210E-EVAL-specific Configuration Options
Configurations
==============
Each STM3210E-EVAL configuration is maintained in a sudirectory and
Each STM3210E-EVAL configuration is maintained in a sub-directory and
can be selected as follow:
cd tools

View File

@ -776,7 +776,7 @@ STM3220G-EVAL-specific Configuration Options
Configurations
==============
Each STM3220G-EVAL configuration is maintained in a sudirectory and
Each STM3220G-EVAL configuration is maintained in a sub-directory and
can be selected as follow:
cd tools

View File

@ -912,7 +912,7 @@ STM3240G-EVAL-specific Configuration Options
Configurations
==============
Each STM3240G-EVAL configuration is maintained in a sudirectory and
Each STM3240G-EVAL configuration is maintained in a sub-directory and
can be selected as follow:
cd tools

View File

@ -454,7 +454,7 @@ configured on pins PA3 and PA2, respectively.
Configurations
==============
Each STMicro STM32F100RC generic configuration is maintained in a sudirectory
Each STMicro STM32F100RC generic configuration is maintained in a sub-directory
and can be selected as follow:
cd tools

View File

@ -1003,7 +1003,7 @@ STM32F4Discovery-specific Configuration Options
Configurations
==============
Each STM32F4Discovery configuration is maintained in a sudirectory and
Each STM32F4Discovery configuration is maintained in a sub-directory and
can be selected as follow:
cd tools

View File

@ -596,7 +596,7 @@ PIC32MX Configuration Options
Configurations
==============
Each PIC32MX configuration is maintained in a sudirectory and can be
Each PIC32MX configuration is maintained in a sub-directory and can be
selected as follow:
cd tools

View File

@ -513,7 +513,7 @@ Teensy++ Configuration Options
Configurations
^^^^^^^^^^^^^^
Each Teensy++ configuration is maintained in a sudirectory and can
Each Teensy++ configuration is maintained in a sub-directory and can
be selected as follow:
cd tools

View File

@ -645,7 +645,7 @@ TWR-K60N512-specific Configuration Options
Configurations
==============
Each TWR-K60N512 configuration is maintained in a sudirectory and
Each TWR-K60N512 configuration is maintained in a sub-directory and
can be selected as follow:
cd tools

View File

@ -569,7 +569,7 @@ PIC32MX Configuration Options
Configurations
==============
Each PIC32MX configuration is maintained in a sudirectory and can be
Each PIC32MX configuration is maintained in a sub-directory and can be
selected as follow:
cd tools

View File

@ -55,7 +55,7 @@ shterm
Configurations
^^^^^^^^^^^^^^
Each SH-1 configuration is maintained in a sudirectory and
Each SH-1 configuration is maintained in a sub-directory and
can be selected as follow:
cd tools

View File

@ -290,7 +290,7 @@ VSN-specific Configuration Options
Configurations
^^^^^^^^^^^^^^
Each VSN configuration is maintained in a sudirectory and
Each VSN configuration is maintained in a sub-directory and
can be selected as follow:
cd tools

View File

@ -282,7 +282,7 @@ Using OpenOCD and GDB with an FT2232 JTAG emulator
Configurations:
===============
Each NXP LPC214x configuration is maintained in a sudirectory and
Each NXP LPC214x configuration is maintained in a sub-directory and
can be selected as follow:
cd tools

View File

@ -637,9 +637,21 @@ static ssize_t fat_write(FAR struct file *filep, const char *buffer,
int sectorindex;
int ret;
/* Sanity checks */
/* Sanity checks. I have seen the following assertion misfire if
* CONFIG_DEBUG_MM is enabled while re-directing output to a
* file. In this case, the debug output can get generated while
* the file is being opened, FAT data structures are being allocated,
* and things are generally in a perverse state.
*/
#ifdef CONFIG_DEBUG_MM
if (filep->f_priv == NULL || filep->f_inode == NULL)
{
return -ENXIO;
}
#else
DEBUGASSERT(filep->f_priv != NULL && filep->f_inode != NULL);
#endif
/* Recover our private data from the struct file instance */

View File

@ -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 */

View File

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

View File

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