Skip to content

Add a write method to the memory manager#2830

Merged
stevenengler merged 2 commits intoshadow:mainfrom
stevenengler:ptr-types
Apr 3, 2023
Merged

Add a write method to the memory manager#2830
stevenengler merged 2 commits intoshadow:mainfrom
stevenengler:ptr-types

Conversation

@stevenengler
Copy link
Copy Markdown
Contributor

This is similar to the existing read method, and I think it is a little nicer to use than copy_to_ptr in simpler cases.

(Also I'm not sure that the pid address write in reap_thread() is correct since I think it's supposed to write a pointer, not a pid_t, but for now I'm leaving this the same as it was before.)

@stevenengler stevenengler requested a review from sporksmith April 3, 2023 18:44
@stevenengler stevenengler self-assigned this Apr 3, 2023
@github-actions github-actions bot added Component: Main Composing the core Shadow executable labels Apr 3, 2023
@sporksmith
Copy link
Copy Markdown
Contributor

(Also I'm not sure that the pid address write in reap_thread() is correct since I think it's supposed to write a pointer, not a pid_t, but for now I'm leaving this the same as it was before.)

I'm pretty sure it writes a pid_t. From man set_tid_address:

When set_child_tid is set, the very first thing the new thread does is to write its thread ID at this address.
...
When a thread whose clear_child_tid is not NULL terminates, then, if the thread is sharing memory with other threads, then 0 is written at the address specified in clear_child_tid and the kernel performs the following operation

@stevenengler
Copy link
Copy Markdown
Contributor Author

(Also I'm not sure that the pid address write in reap_thread() is correct since I think it's supposed to write a pointer, not a pid_t, but for now I'm leaving this the same as it was before.)

I'm pretty sure it writes a pid_t. From man set_tid_address:

When set_child_tid is set, the very first thing the new thread does is to write its thread ID at this address.
...
When a thread whose clear_child_tid is not NULL terminates, then, if the thread is sharing memory with other threads, then 0 is written at the address specified in clear_child_tid and the kernel performs the following operation

Ah okay, I think I was getting confused by the prctl PR_GET_TID_ADDRESS, which writes the value of the ForeignPtr pointer (not the value pointed to by the ForeignPtr). I'll make a PR to try and add types here.

@stevenengler stevenengler force-pushed the ptr-types branch 4 times, most recently from eb1b45e to c4a5abe Compare April 3, 2023 20:37
@stevenengler stevenengler merged commit 458bbfe into shadow:main Apr 3, 2023
@stevenengler stevenengler deleted the ptr-types branch April 3, 2023 21:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Component: Main Composing the core Shadow executable

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants