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
improve Valgrind integration, and figure out where it fits in #3
Comments
Now other Stack / StackSource implementations can use the same Valgrind code. Ref #3.
Either way, it seems like a good idea to expose a use valgrind;
pub struct Id(valgrind::stack_id_t);
impl Id {
pub fn register(start: *const u8, end: *const u8) -> StackId {
StackId(valgrind::stack_register(start, end))
}
}
impl Drop for Id {
fn drop(&mut self) {
valgrind::stack_deregister(self.0)
}
} |
Registration of stacks could be encouraged by adding |
Additionally, the aforementioned |
Focusing on Valgrind might be way too specific — there are many other tools that care about stacks, and there is much more information one might want to attach to them. |
I've decided that since segmented stacks are unsupported in regular Rust anyway, we'll leave stack resizing alone for now. |
Now other Stack / StackSource implementations can use the same Valgrind code. Ref #3.
fix #3 This takes all Valgrind functionality private again. Valgrind stack registrations are now associated with a Context, not with a Stack. This makes sense, since it's only actually a stack when a Context is running on it. Perhaps Valgrind will even be able to detect early stack frees now.
Currently,
os::Stack
uses the native functions provided by platform.c to register the allocated stacks with Valgrind. We don't currently expose these functions.Having them as
extern "C"
functions instead of inline assembly in Rust is also suboptimal, but might save us some implementation complexity. Performing a Valgrind call while running natively only takes about 2ns.Stacks should always be registered with Valgrind, even if a custom
StackSource
is being used — the cost is minimal, and this should work fine even in freestanding environments.I'm not sure if this responsibility should lie with the
Stack
, or with theContext
. Technically, it isn't stack memory until the context is invoked, and it only ceases to be stack memory when the context finishes execution. However, theContext
's main function is intended to never return (this causes an intentional abort when the trampoline function returns), so the point for stack deregistration is unclear in this case.The text was updated successfully, but these errors were encountered: