[Bug 1472] malloc_boundary.c:89: warning: left shift count >= width of type
bugzilla-daemon at rtems.org
bugzilla-daemon at rtems.org
Fri Jun 25 07:31:28 UTC 2010
https://www.rtems.org/bugzilla/show_bug.cgi?id=1472
--- Comment #5 from Sebastian Huber <sebastian.huber at embedded-brains.de> 2010-06-25 02:31:27 CDT ---
(In reply to comment #4)
> (In reply to comment #3)
> > I have a debug support for the super core heap handler. It covers boundary
> > violations, general heap block corruption, double free and usage of freed
> > memory. The space overhead is 4 words per heap block. The time overhead is
> > minimal for allocations and during free it depends on the allocation size (the
> > freed memory will be marked with a pattern).
>
> Nice. Is this plugable ? It would be nice to take a known working RTEMS and
> turn this on when needed by an application.
It is plugable:
typedef struct {
void *handler_data;
void (*init_block)(Heap_Control *heap, Heap_Block *block);
bool (*check_block)(Heap_Control *heap, Heap_Block *block);
void (*block_error)(Heap_Control *heap, Heap_Block *block);
Heap_Block *first_delayed_free_block;
Heap_Block *last_delayed_free_block;
uintptr_t delayed_free_block_count;
} Heap_Protection;
If enable, this structure is a part of Heap_Control. The handler functions
will be called by the general heap code.
In order to check if a heap block (Heap_Block) is valid I added protector
fields (the previous value of a 4 word overhead was incorrect, we have 6
words):
typedef struct {
uintptr_t protector [HEAP_PROTECTOR_COUNT];
Heap_Block *next_delayed_free_block;
Thread_Control *task;
} Heap_Block_protection_begin;
typedef struct {
uintptr_t protector [HEAP_PROTECTOR_COUNT];
} Heap_Block_protection_end;
struct Heap_Block {
uintptr_t prev_size;
#ifdef HEAP_PROTECTION
Heap_Block_protection_begin Protection_begin;
#endif
uintptr_t size_and_flag;
#ifdef HEAP_PROTECTION
Heap_Block_protection_end Protection_end;
#endif
Heap_Block *next;
Heap_Block *prev;
};
They will catch a boundary violation with a high probability. Here we have a
space overhead which may be to much for certain applications, thus I would not
enable this feature by default.
--
Configure bugmail: https://www.rtems.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are watching all bug changes.
More information about the bugs
mailing list