diff options
-rw-r--r-- | ChangeLog | 9 | ||||
-rw-r--r-- | bignum.c | 2 | ||||
-rw-r--r-- | gc.c | 13 | ||||
-rw-r--r-- | internal.h | 13 |
4 files changed, 24 insertions, 13 deletions
@@ -1,3 +1,12 @@ +Tue Aug 6 12:23:12 2013 Tanaka Akira <akr@fsij.org> + + * bignum.c (rb_big_realloc): Use VALGRIND_MAKE_MEM_UNDEFINED to + declare undefined memory area. + (bignew_1): Ditto. + + * internal.h (VALGRIND_MAKE_MEM_DEFINED): Moved from gc.c + (VALGRIND_MAKE_MEM_UNDEFINED): Ditto. + Tue Aug 6 01:40:37 2013 Zachary Scott <e@zzak.io> * process.c: [DOC] Document caveats of command form of Process.spawn @@ -2886,6 +2886,7 @@ rb_big_realloc(VALUE big, long len) ds = RBIGNUM(big)->as.heap.digits; RBASIC(big)->flags |= RBIGNUM_EMBED_FLAG; RBIGNUM_SET_LEN(big, len); + (void)VALGRIND_MAKE_MEM_UNDEFINED((void*)RBIGNUM(big)->as.ary, sizeof(RBIGNUM(big)->as.ary)); if (ds) { MEMCPY(RBIGNUM(big)->as.ary, ds, BDIGIT, len); xfree(ds); @@ -2917,6 +2918,7 @@ bignew_1(VALUE klass, long len, int sign) if (len <= RBIGNUM_EMBED_LEN_MAX) { RBASIC(big)->flags |= RBIGNUM_EMBED_FLAG; RBIGNUM_SET_LEN(big, len); + (void)VALGRIND_MAKE_MEM_UNDEFINED((void*)RBIGNUM(big)->as.ary, sizeof(RBIGNUM(big)->as.ary)); } else { RBIGNUM(big)->as.heap.digits = ALLOC_N(BDIGIT, len); @@ -52,19 +52,6 @@ #include <malloc.h> #endif -#ifdef HAVE_VALGRIND_MEMCHECK_H -# include <valgrind/memcheck.h> -# ifndef VALGRIND_MAKE_MEM_DEFINED -# define VALGRIND_MAKE_MEM_DEFINED(p, n) VALGRIND_MAKE_READABLE((p), (n)) -# endif -# ifndef VALGRIND_MAKE_MEM_UNDEFINED -# define VALGRIND_MAKE_MEM_UNDEFINED(p, n) VALGRIND_MAKE_WRITABLE((p), (n)) -# endif -#else -# define VALGRIND_MAKE_MEM_DEFINED(p, n) 0 -# define VALGRIND_MAKE_MEM_UNDEFINED(p, n) 0 -#endif - #define rb_setjmp(env) RUBY_SETJMP(env) #define rb_jmp_buf rb_jmpbuf_t diff --git a/internal.h b/internal.h index 03acd3f8e1..a4cf43b939 100644 --- a/internal.h +++ b/internal.h @@ -19,6 +19,19 @@ extern "C" { #endif #endif +#ifdef HAVE_VALGRIND_MEMCHECK_H +# include <valgrind/memcheck.h> +# ifndef VALGRIND_MAKE_MEM_DEFINED +# define VALGRIND_MAKE_MEM_DEFINED(p, n) VALGRIND_MAKE_READABLE((p), (n)) +# endif +# ifndef VALGRIND_MAKE_MEM_UNDEFINED +# define VALGRIND_MAKE_MEM_UNDEFINED(p, n) VALGRIND_MAKE_WRITABLE((p), (n)) +# endif +#else +# define VALGRIND_MAKE_MEM_DEFINED(p, n) 0 +# define VALGRIND_MAKE_MEM_UNDEFINED(p, n) 0 +#endif + #define numberof(array) ((int)(sizeof(array) / sizeof((array)[0]))) #define STATIC_ASSERT(name, expr) typedef int static_assert_##name##_check[1 - 2*!(expr)] |