Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Threadx modules kernel stack memory leakage #400

Open
amgross opened this issue Jul 29, 2024 · 1 comment
Open

Threadx modules kernel stack memory leakage #400

amgross opened this issue Jul 29, 2024 · 1 comment
Labels
bug Something isn't working hardware New hardware or architecture support request

Comments

@amgross
Copy link

amgross commented Jul 29, 2024

Describe the bug
tx_thread_module_kernel_stack_start is allocated at _txm_module_manager_thread_create from the object pool, but is not released at thread delete function (it is deleted upon module stop when all objects of the module are deleted)

To Reproduce
Run from module:

    while(1)
    {
		status = txm_module_object_allocate(<thread_ptr>, sizeof(TX_THREAD));
		assert(TX_SUCCESS == status);

		status = tx_thread_create(<thread_ptr>, "my thread", <my_thread_func>, 0, <stack_ptr>,
                <stack size>, <priority>, <priority>, <time slice>, TX_DONT_START);
		assert(TX_SUCCESS == status);

		status = tx_thread_terminate(<thread_ptr>);
		assert(TX_SUCCESS == status);

		// This system call deallocating also <thread_ptr>, so will need to allocate it afterward
		tx_thread_delete(<thread_ptr>);
		assert(TX_SUCCESS == status);
    }

Expected behavior
tx_thread_module_kernel_stack_start should be released upon thread delete.

Impact
Can leak object pool out of memory, which cause no more option to create OS objects from module

Logs and console output

Additional context

@amgross amgross added bug Something isn't working hardware New hardware or architecture support request labels Jul 29, 2024
@amgross
Copy link
Author

amgross commented Jul 29, 2024

Workaround: add to tx_port.h (or tx_user.h)

extern UINT  _txm_module_manager_object_deallocate(VOID *object_ptr);
#define TX_THREAD_DELETE_PORT_COMPLETION(t) _txm_module_manager_object_deallocate(t -> tx_thread_module_kernel_stack_start);

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working hardware New hardware or architecture support request
Projects
None yet
Development

No branches or pull requests

1 participant