This is the mail archive of the ecos-patches@sourceware.org mailing list for the eCos project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

dlmalloc assert check for the size of the arena


Hi,

When modifying the linker script to adjust the location of RAM, it is
easy to forget to change the size of the heap in the eCos memory
layout file. This value is being passed to the memory allocator. If
the size if negative, the dlmalloc doesn't complain.
The attached patch checks the size on an assert.

Regards,
Edgar

-- 
Edgar Grimberg
System Developer
Zylin AS

ZY1000 JTAG Debugger http://www.zylin.com/zy1000.html
Phone: (+47) 51 63 25 00
# HG changeset patch
# User Edgar Grimberg <edgar.grimberg@zylin.com>
# Date 1276596038 -7200
# Node ID 831d5e603f1f9037db95bbf0362cfd224eb2e170
# Parent  eb303059b6e55fe739866837ef0e6c970873b45e
Add an assert to check for invalid size of the arena.

diff -r eb303059b6e5 -r 831d5e603f1f packages/services/memalloc/common/current/ChangeLog
--- a/packages/services/memalloc/common/current/ChangeLog	Thu Jun 10 20:46:18 2010 +0000
+++ b/packages/services/memalloc/common/current/ChangeLog	Tue Jun 15 12:00:38 2010 +0200
@@ -1,3 +1,8 @@
+2010-06-15 Edgar Grimberg <edgar.grimberg@zylin.com>
+
+	* src/dlmalloc.cxx Cyg_Mempool_dlmalloc_Implementation:
+	Add an assert to check for invalid size of the arena.
+
 2009-09-01  Bart Veer  <bartv@ecoscentric.com>
 
 	* src/heapgen.tcl (tcl_path): use the makefile's HOST instead of
diff -r eb303059b6e5 -r 831d5e603f1f packages/services/memalloc/common/current/src/dlmalloc.cxx
--- a/packages/services/memalloc/common/current/src/dlmalloc.cxx	Thu Jun 10 20:46:18 2010 +0000
+++ b/packages/services/memalloc/common/current/src/dlmalloc.cxx	Tue Jun 15 12:00:38 2010 +0200
@@ -948,6 +948,8 @@
                                             cyg_uint8 *base, cyg_int32 size,
                                             CYG_ADDRWORD /* argthru */ )
 {
+	CYG_ASSERT(size > 0, "Invalid arena size." );
+
     arenabase = base;
     arenasize = size;
 

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]