Skip to content

Commit d7be4ab

Browse files
committed
rt: Fix valgrind stack hints
1 parent 9ea3bc6 commit d7be4ab

File tree

1 file changed

+5
-15
lines changed

1 file changed

+5
-15
lines changed

src/rt/rust_task.h

Lines changed: 5 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -363,28 +363,18 @@ rust_task::return_c_stack() {
363363
// NB: This runs on the Rust stack
364364
inline void *
365365
rust_task::next_stack(size_t stk_sz, void *args_addr, size_t args_sz) {
366-
stk_seg *maybe_next_stack = NULL;
367-
if (stk != NULL) {
368-
maybe_next_stack = stk->prev;
369-
}
370-
371366
new_stack_fast(stk_sz + args_sz);
372367
A(thread, stk->end - (uintptr_t)stk->data >= stk_sz + args_sz,
373368
"Did not receive enough stack");
374369
uint8_t *new_sp = (uint8_t*)stk->end;
375370
// Push the function arguments to the new stack
376371
new_sp = align_down(new_sp - args_sz);
377372

378-
// When reusing a stack segment we need to tell valgrind that this area of
379-
// memory is accessible before writing to it, because the act of popping
380-
// the stack previously made all of the stack inaccessible.
381-
if (maybe_next_stack == stk) {
382-
// I don't know exactly where the region ends that valgrind needs us
383-
// to mark accessible. On x86_64 these extra bytes aren't needed, but
384-
// on i386 we get errors without.
385-
int fudge_bytes = 16;
386-
reuse_valgrind_stack(stk, new_sp - fudge_bytes);
387-
}
373+
// I don't know exactly where the region ends that valgrind needs us
374+
// to mark accessible. On x86_64 these extra bytes aren't needed, but
375+
// on i386 we get errors without.
376+
const int fudge_bytes = 16;
377+
reuse_valgrind_stack(stk, new_sp - fudge_bytes);
388378

389379
memcpy(new_sp, args_addr, args_sz);
390380
record_stack_limit();

0 commit comments

Comments
 (0)