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

Thread creation: Don't rely on TCB being inside stack #23

Open
chrysn opened this issue Oct 13, 2022 · 1 comment
Open

Thread creation: Don't rely on TCB being inside stack #23

chrysn opened this issue Oct 13, 2022 · 1 comment

Comments

@chrysn
Copy link
Member

chrysn commented Oct 13, 2022

riot-rs has its thread_t somewhere else than in the stack.

The conclusion of RIOT-OS/RIOT#17542 is that for creating a thread and getting its thread_t, creating it stopped (no-one goes around unstopping nascent threads unless they're it by what this mechanisms avoids), and looking at its thread_t before it's had an opportunity to stop, then run it.

This doesn't solve the issue on its own (because now that the thread_t may is not owned by us, we can't be sure it's not repurposed), but rather than doing a test for identity we can still check whether the sp is within the stack we allocated, so we can know whether it's still our thread.

Then again, this could become moot with anything that's more along the lines of a thread not being reaped until it's reaped by someone responsible, but right now nothing along these lines is available.

@chrysn
Copy link
Member Author

chrysn commented Jan 24, 2023

There's two things wrong with the current TrackedThread:

  • It looks at the TCB, which may be outside the stack
  • Even if it looked at the stack instead, the stack (or the current TCB pointer) is a lifetimeless pointer, so if the thread's stack gets deallocated and reused, there'd still be confusion about the tracked thread's status. Either the type needs to inherit some of the stack's lifetime (as to be sure that the stack was not reused), or needs to work in a completely different fashion.

SimonIT pushed a commit to ATACAMA-Project/rust-riot-wrappers that referenced this issue Oct 9, 2023
Add wrapper around periph_timer

Closes RIOT-OS#23

See merge request atacama/rust-riot-wrappers!29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant