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


Crash on vPortFree

Posted by athos1984 on March 20, 2016

Hi all,

I'm facing a crash (HardFault) into my project within pvPortMalloc/vPortFree functions. heap_4 management, queues 16 in length, latest stable FreeRTOS Release.

Task#1 (Priority 2): - addr = pvPortMalloc() - q1_xQueueSend(addr) - Force ISR#1 - ... - addr2 = pvPortMalloc() - ... - vPortFree(addr2)

ISR#1: - q1_xQueueReceiveFromISR(addr) - Force ISR#2

ISR#2: - q2_xQueueSendFromISR(addr)

Task#2 (Priority 4): - top: - q2_xQueueReceive(addr) - vPortFree(addr) - goto top

Some debug infos: - No crash if code runs @ lower MCU speed (64MHz vs 180MHz, STM32F1 vs STM32F4) - No crash removing vPortFree from Task#2 - No crash if vPortFree inside Task#2 is delayed after xQueueReceive (by printf, or by vTaskDelay, or other) - configASSERT inside pvPortMalloc tells me that "blocks are NOT aligned to the required number of bytes" - configASSERT inside vPortFree tells me that "block is NOT actually allocated"

I tried: - different priorities - different ISR preemption priorities

What can I do? Any idea? Thanks j

Crash on vPortFree

Posted by rtel on March 20, 2016

It is difficult to say what could be wrong without seeing how the queue is created and how the addr is passed into the queue. Is the queue created to hold pointers? Are you reading the value out of the queue into a pointer?

Crash on vPortFree

Posted by athos1984 on March 20, 2016

Both queues are used to send/receive addresses of dynamically allocated objects (structures): xQueueCreate(16, sizeof(struct object *))

T1 struct object *o = pvPortMalloc(sizeof(struct object)) xQueueSend(q1, &o, portMAXDELAY)

struct object *i (global var) ISR1 xQueueReceiveFromISR(q1, &i, &higherWoken) ISR2 xQueueSendFromISR(q2, &i, &higherWoken)

T2 struct object *f xQueueReceive(q2, &f, portMAXDELAY) vPortFree(f)

Crash on vPortFree

Posted by edwards3 on March 20, 2016

Maybe just a typing error in your post or sourceforge formatting, but shouldnt that be

~~~~ xQueueCreate(16, sizeof(struct object*)) // with * ~~~~

if sending and receiving addresses?

Crash on vPortFree

Posted by edwards3 on March 20, 2016

Our posts overlapped, looks like you just edited that.

[ 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