diff options
author | Sverker Eriksson <[email protected]> | 2016-09-16 19:39:24 +0200 |
---|---|---|
committer | Sverker Eriksson <[email protected]> | 2016-10-14 14:29:15 +0200 |
commit | a82be01198c1f3714f29f0a0e3ce3ed6d6bce0a6 (patch) | |
tree | b5d95ca5c9298e51867a9008d600b5270471fe8a /erts/emulator/beam | |
parent | 5e879fb1d4a9273f0a6183da7509dcdbc24f9653 (diff) | |
download | otp-a82be01198c1f3714f29f0a0e3ce3ed6d6bce0a6.tar.gz otp-a82be01198c1f3714f29f0a0e3ce3ed6d6bce0a6.tar.bz2 otp-a82be01198c1f3714f29f0a0e3ce3ed6d6bce0a6.zip |
erts: Fill freed EXEC memory with illegal instructions on DEBUG
to get a nice SIGILL crash.
For x86 and x86_64 only.
Diffstat (limited to 'erts/emulator/beam')
-rw-r--r-- | erts/emulator/beam/erl_alloc.c | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/erts/emulator/beam/erl_alloc.c b/erts/emulator/beam/erl_alloc.c index 3c2c9def3b..d96b90fd55 100644 --- a/erts/emulator/beam/erl_alloc.c +++ b/erts/emulator/beam/erl_alloc.c @@ -4129,12 +4129,20 @@ debug_free(ErtsAlcType_t n, void *extra, void *ptr) ErtsAllocatorFunctions_t *real_af = (ErtsAllocatorFunctions_t *) extra; void *dptr; Uint size; + int free_pattern = n; ASSERT(ERTS_ALC_N_MIN <= n && n <= ERTS_ALC_N_MAX); dptr = check_memory_fence(ptr, &size, n, ERTS_ALC_O_FREE); - sys_memset((void *) dptr, n, size + FENCE_SZ); +#ifdef ERTS_ALC_A_EXEC +# if defined(__i386__) || defined(__x86_64__) + if (ERTS_ALC_T2A(ERTS_ALC_N2T(n)) == ERTS_ALC_A_EXEC) { + free_pattern = 0x0f; /* Illegal instruction */ + } +# endif +#endif + sys_memset((void *) dptr, free_pattern, size + FENCE_SZ); (*real_af->free)(n, real_af->extra, dptr); |