cancel
Showing results for 
Search instead for 
Did you mean: 

Using queue from a C++ class running in a ThreadX thread causes task to overflow memory. Bug? (workaround exists)

Harvey White
Senior III

STM32L5x2xx processor.

STM32CubeIDE

Version: 1.10.1

Build: 12716_20220707_0928 (UTC)

Program structure:

Main.c calls CPP_LINK (a C++ routine) that enables system level drivers (with ThreadX mutexes), then starts main ThreadX task.

C++ classes own ThreadX objects (mutex, queue, task pointer). Class init routine creates ThreadX objects. ThreadX task is not inside class, but is outside.

Packet class owns TX_QUEUE, initializes it. Queue object size is less than 16 32 bit words.

Instance of packet class creates queue properly (using common byte pool in processor memory). When packet class instance runs, all is good until packet is placed on queue. Thread monitor immediately shows entire allocated stack for that task as occupied. This is regardless of actual number (2046 fills up as does 24000).

Rest of system behaves badly after this.

Actual problem can be isolated to the macro where the ThreadX queue actually transfers from the source (which is correct), to the destination (which matches pointers in queue structure. That macro running seems to kill everything. I suspect that the "to" pointer owned by the queue is incorrect.

WORKAROUND: Create TX_QUEUE as global object and initialize/create from C routine (not part of ThreadX task, not C++ code, is created in bridge routine that eventually initializes main system task. Stack does not overflow in this instance.

Philosophy of the program is to bridge to C++. Program is uses many queues and C++ classes to do graphics, and main routine is responsible for creating (as configured) these queues. Note that this all works under FreeRTOS without a problem.

Comments welcome:

1 REPLY 1
Amel NASRI
ST Employee

Hi @Harvey White​,

As this is out of my area of expertise, I share the problem you described as well as the suggested workaround with our AzureRTOS experts.

I'll keep you informed as soon as I receive news on this regard.

Internal ticket number: 139995 (This is an internal tracking number and is not accessible or usable by customers).

-Amel

To give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.