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

[Bug] _z_common_transport_clear() should call _z_task_free() #864

Open
pdematteis opened this issue Jan 28, 2025 · 2 comments · May be fixed by #867
Open

[Bug] _z_common_transport_clear() should call _z_task_free() #864

pdematteis opened this issue Jan 28, 2025 · 2 comments · May be fixed by #867
Assignees
Labels
bug Something isn't working

Comments

@pdematteis
Copy link

Describe the bug

_z_common_transport_clear() in transport/common/transport.c call z_free() to cleanup tasks but _z_task_free() should be called instead, I think.
z_free() only releases memory, while _z_task_free() also close handles and other platform-specific resources, for example it calls vEventGroupDelete(ptr->join_event) in FreeRTOS.

To reproduce

.

System info

.

@pdematteis pdematteis added the bug Something isn't working label Jan 28, 2025
@sashacmc
Copy link
Member

@pdematteis, thanks, we'll look into it.

@sashacmc sashacmc self-assigned this Jan 28, 2025
@sashacmc sashacmc linked a pull request Jan 28, 2025 that will close this issue
@pdematteis
Copy link
Author

Just found that by calling _z_task_free() a little change is needed to make Windows implementation working properly:

z_result_t _z_task_detach(_z_task_t *task) {
    z_result_t ret = _Z_RES_OK;
    CloseHandle(*task);
    *task = NULL; // <== avoid closing the handle multiple times
    return ret;
}

Will check Linux as well.

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

Successfully merging a pull request may close this issue.

2 participants