Skip to content
Snippets Groups Projects
Commit d19441d7 authored by Cheng Shao's avatar Cheng Shao Committed by Marge Bot
Browse files

rts: assert pointer is indeed heap allocated in Bdescr()

This commit adds an assertion to Bdescr() to assert the pointer is
indeed heap allocated. This is useful to rule out RTS bugs that
attempt to access non-existent block descriptor of a static closure, #24492
being one such example.
parent dedcf102
No related branches found
No related tags found
No related merge requests found
......@@ -10,6 +10,10 @@
#include "ghcconfig.h"
#if !defined(CMINUSMINUS)
#include "rts/storage/HeapAlloc.h"
#endif
/* The actual block and megablock-size constants are defined in
* rts/include/Constants.h, all constants here are derived from these.
*/
......@@ -190,6 +194,7 @@ typedef struct bdescr_ {
EXTERN_INLINE bdescr *Bdescr(StgPtr p);
EXTERN_INLINE bdescr *Bdescr(StgPtr p)
{
ASSERT(HEAP_ALLOCED_GC(p));
return (bdescr *)
((((W_)p & MBLOCK_MASK & ~BLOCK_MASK) >> (BLOCK_SHIFT-BDESCR_SHIFT))
| ((W_)p & ~MBLOCK_MASK)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment