Quality RTOS & Embedded Software

 Real time embedded FreeRTOS RSS feed 
Real time embedded FreeRTOS mailing list 
Quick Start Supported MCUs PDF Books Trace Tools Ecosystem TCP & FAT Training




Loading

Possible memory leaks when configUSE_NEWLIB_REENTRANT 1

Posted by wella on April 8, 2014

Hello,

before submitting a bug I would like to discuss the following issue. I am using GNU Tools for ARM Embedded Processors with the Newlib libray. I have also enabled the configUSENEWLIBREENTRANT macro to support task concurrency. However during the task deletion (no so much realtime...) the reent xNewLibreent is simply freed with the TCB. As far as I know the reent struct should be reclaimed by calling _reclaimreent at first. However such call is missing in prvDeleteTCB( TCB_t *pxTCB ). There should be

	#if ( configUSE_NEWLIB_REENTRANT == 1 )
	{

		_reclaim_reent(&(pxTCB->xNewLib_reent));
	}
	#endif /* configUSE_NEWLIB_REENTRANT */

before vPortFree( pxTCB ).

This is even more critical with the Newlib compiled with REENTSMALL. There is a workaround to hook to portCLEANUPTCB( pxTCB ) but the user needs to access pxTCB directly.

Anyway thank you for supporting Newlib.

Best Martin


Possible memory leaks when configUSE_NEWLIB_REENTRANT 1

Posted by rtel on April 9, 2014

Thanks for pointing this out. Note the caveats about newlib support, in that it was added following user request, but I don't use it myself, so am reliant on other to point these things out.

Take a look at tasks.c in the head revision to see if it is correctly meeting your needs now.

[don't know why your post got put into the moderation list - I don't seem to be able to turn that feature off but very few posts get trapped there].

Regards.


Possible memory leaks when configUSE_NEWLIB_REENTRANT 1

Posted by wella on April 9, 2014

Hello, thank you. It seems to be correct. However I am using newlib only 3 days so that some opinions from more skilled users than me would be valuable.

I appreciate the newlib support got into mainline. I would rather to open a discussion before first because there are some caveats I am not aware of. E.g. I read a nice article about the Newlib today and there is a suggestion:

When the thread terminates, you should clean up all stdio usage by the thread and call of its own atexit handlers by calling (see "reent.c"): wrapupreent(thread_state); source: http://andrewsterian.com/424/Lecture17.pdf

Later on,

Assuming this function has been really only introduced for RTEMS, and given that it's not used in newlib nor in RTEMS, I just removed it now, as you proposed. source: https://sourceware.org/ml/newlib/2013/msg00372.html

Best Martin


[ Back to the top ]    [ About FreeRTOS ]    [ Sitemap ]    [ ]




Copyright (C) 2004-2010 Richard Barry. Copyright (C) 2010-2016 Real Time Engineers Ltd.
Any and all data, files, source code, html content and documentation included in the FreeRTOSTM distribution or available on this site are the exclusive property of Real Time Engineers Ltd.. See the files license.txt (included in the distribution) and this copyright notice for more information. FreeRTOSTM and FreeRTOS.orgTM are trade marks of Real Time Engineers Ltd.

Latest News:

FreeRTOS V9.0.0 is now available for download.


Free TCP/IP and file system demos for the RTOS


Sponsored Links

⇓ Now With No Code Size Limit! ⇓
⇑ Free Download Without Registering ⇑


FreeRTOS Partners

ARM Connected RTOS partner for all ARM microcontroller cores

Renesas Electronics Gold Alliance RTOS Partner.jpg

Microchip Premier RTOS Partner

RTOS partner of NXP for all NXP ARM microcontrollers

Atmel RTOS partner supporting ARM Cortex-M3 and AVR32 microcontrollers

STMicro RTOS partner supporting ARM7, ARM Cortex-M3, ARM Cortex-M4 and ARM Cortex-M0

Xilinx Microblaze and Zynq partner

Silicon Labs low power RTOS partner

Altera RTOS partner for Nios II and Cortex-A9 SoC

Freescale Alliance RTOS Member supporting ARM and ColdFire microcontrollers

Infineon ARM Cortex-M microcontrollers

Texas Instruments MCU Developer Network RTOS partner for ARM and MSP430 microcontrollers

Cypress RTOS partner supporting ARM Cortex-M3

Fujitsu RTOS partner supporting ARM Cortex-M3 and FM3

Microsemi (previously Actel) RTOS partner supporting ARM Cortex-M3

Atollic Partner

IAR Partner

Keil ARM Partner

Embedded Artists