Skip to content

Commit f107fa4

Browse files
committed
---
yaml --- r: 5705 b: refs/heads/master c: 8d8b48a h: refs/heads/master i: 5703: 3978e89 v: v3
1 parent d5d6822 commit f107fa4

File tree

3 files changed

+17
-2
lines changed

3 files changed

+17
-2
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
---
2-
refs/heads/master: cf3e7f2f0bc560f761c4663b11abe41f844e09a2
2+
refs/heads/master: 8d8b48a90196fdb52e4832b38a90340c4ea27048

trunk/mk/platform.mk

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,10 @@ CFG_GCCISH_LINK_FLAGS :=
77
# embedded into the executable, so use a no-op command.
88
CFG_DSYMUTIL := true
99

10+
ifneq ($(CFG_VALGRIND),)
11+
CFG_GCCISH_CFLAGS += -DHAVE_VALGRIND
12+
endif
13+
1014
ifneq ($(findstring freebsd,$(CFG_OSTYPE)),)
1115
CFG_LIB_NAME=lib$(1).so
1216
CFG_GCCISH_CFLAGS += -fPIC -march=i686 -I/usr/local/include

trunk/src/rt/arch/i386/context.h

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,10 @@
77
#include <inttypes.h>
88
#include <stdint.h>
99

10+
#ifdef HAVE_VALGRIND
11+
#include <valgrind/memcheck.h>
12+
#endif
13+
1014
template<typename T>
1115
T align_down(T sp)
1216
{
@@ -44,7 +48,14 @@ class context {
4448
// function being called causes the task to fail, then we have to avoid
4549
// leaking space on the C stack.
4650
inline void *alloc_stack(size_t nbytes) {
47-
return (void *)(align_down(regs.esp - nbytes));
51+
uint32_t bot = regs.esp;
52+
uint32_t top = align_down(bot - nbytes);
53+
54+
#ifdef HAVE_VALGRIND
55+
(void)VALGRIND_MAKE_MEM_UNDEFINED(top - 4, bot - top + 4);
56+
#endif
57+
58+
return reinterpret_cast<void *>(top);
4859
}
4960
};
5061

0 commit comments

Comments
 (0)